Skip to content

Commit

Permalink
gui: Fix proxy details display in Options Dialog
Browse files Browse the repository at this point in the history
- Ensured that the proxy IP is displayed correctly in the UI when using an IPv6 address.

No functionality impact; changes only affect UI display.
  • Loading branch information
pablomartin4btc committed Sep 18, 2024
1 parent 0c4ff18 commit eeac4e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void OptionsDialog::updateDefaultProxyNets()

has_proxy = model->node().getProxy(NET_IPV4, proxy);
ui->proxyReachIPv4->setChecked(has_proxy && proxy.ToString() == proxyIpText);

has_proxy = model->node().getProxy(NET_IPV6, proxy);
ui->proxyReachIPv6->setChecked(has_proxy && proxy.ToString() == proxyIpText);

Expand Down
12 changes: 8 additions & 4 deletions src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,14 @@ static ProxySetting ParseProxyString(const QString& proxy)
if (proxy.isEmpty()) {
return default_val;
}
// contains IP at index 0 and port at index 1
QStringList ip_port = GUIUtil::SplitSkipEmptyParts(proxy, ":");
if (ip_port.size() == 2) {
return {true, ip_port.at(0), ip_port.at(1)};
uint16_t port{0};
std::string hostname;
if (!SplitHostPort(proxy.toStdString(), port, hostname) || port != 0) {
// Check if the hostname contains a colon, indicating an IPv6 address
if (hostname.find(':') != std::string::npos) {
hostname = "[" + hostname + "]"; // Wrap IPv6 address in brackets
}
return {true, QString::fromStdString(hostname), QString::number(port)};
} else { // Invalid: return default
return default_val;
}
Expand Down

0 comments on commit eeac4e9

Please sign in to comment.