Skip to content

Commit 701e2ec

Browse files
gui: Fix network details display in Options Dialog
- Ensured that the proxy IP is displayed correctly in the UI when using an IPv6 address. - Fixed the checkboxes for reachable networks so they accurately reflect the network configuration. No functionality impact; changes only affect UI display.
1 parent 0c4ff18 commit 701e2ec

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/qt/optionsdialog.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -466,13 +466,13 @@ void OptionsDialog::updateDefaultProxyNets()
466466
bool has_proxy;
467467

468468
has_proxy = model->node().getProxy(NET_IPV4, proxy);
469-
ui->proxyReachIPv4->setChecked(has_proxy && proxy.ToString() == proxyIpText);
469+
ui->proxyReachIPv4->setChecked((has_proxy && proxy.ToString() == proxyIpText) && g_reachable_nets.Contains(NET_IPV4));
470470

471471
has_proxy = model->node().getProxy(NET_IPV6, proxy);
472-
ui->proxyReachIPv6->setChecked(has_proxy && proxy.ToString() == proxyIpText);
472+
ui->proxyReachIPv6->setChecked((has_proxy && proxy.ToString() == proxyIpText) && g_reachable_nets.Contains(NET_IPV6));
473473

474474
has_proxy = model->node().getProxy(NET_ONION, proxy);
475-
ui->proxyReachTor->setChecked(has_proxy && proxy.ToString() == proxyIpText);
475+
ui->proxyReachTor->setChecked((has_proxy && proxy.ToString() == proxyIpText) && g_reachable_nets.Contains(NET_ONION));
476476
}
477477

478478
ProxyAddressValidator::ProxyAddressValidator(QObject *parent) :

src/qt/optionsmodel.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,14 @@ static ProxySetting ParseProxyString(const QString& proxy)
320320
if (proxy.isEmpty()) {
321321
return default_val;
322322
}
323-
// contains IP at index 0 and port at index 1
324-
QStringList ip_port = GUIUtil::SplitSkipEmptyParts(proxy, ":");
325-
if (ip_port.size() == 2) {
326-
return {true, ip_port.at(0), ip_port.at(1)};
323+
uint16_t port{0};
324+
std::string hostname;
325+
if (!SplitHostPort(proxy.toStdString(), port, hostname) || port != 0) {
326+
// Check if the hostname contains a colon, indicating an IPv6 address
327+
if (hostname.find(":") != std::string::npos) {
328+
hostname = "[" + hostname + "]"; // Wrap IPv6 address in brackets
329+
}
330+
return {true, QString::fromStdString(hostname), QString::number(port)};
327331
} else { // Invalid: return default
328332
return default_val;
329333
}

0 commit comments

Comments
 (0)