aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-10-06 19:26:40 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-10-06 19:26:45 +0100
commit5fe6878b5f7c1c97b5c8ae04be9592be73e840c1 (patch)
tree276ef49596e2552751f7e8770916ee294bf2948c /src
parent5ea335a97f8f9e197d6680cdbd01b272074c3a95 (diff)
parentfee4cba48472239f7a426db62f45c4b6af8e5ef2 (diff)
Merge bitcoin-core/gui#836: Fix display issues for IPv6 proxy setup in Options Dialog (UI only, no functionality impact)
fee4cba48472239f7a426db62f45c4b6af8e5ef2 gui: Fix proxy details display in Options Dialog (pablomartin4btc) Pull request description: Currently, setting up a proxy (whether SOCKS5 or Tor) with an IPv6 address works correctly via the command line or configuration file in both `bitcoind` and `bitcoin-qt` (also from the UI the ipv6 address gets saved properly in `settings.json`). However, the UI does not reflect this properly, which can create confusion. Since some ISPs and VPNs still experience issues with IPv6, users may mistakenly think there is a problem with Bitcoin Core, when in fact the proxy setup is functioning as expected. So this PR ensures that the proxy IP is displayed correctly in the UI when using an IPv6 address. No functionality impact; changes only affect UI display. <details> <summary>Click her to see <b>before</b> and <b>after</b> screenshots.</summary> - Before: ![image](https://github.com/user-attachments/assets/073d9022-3174-4eef-8e0c-8c1b73b17226) - After: ![image](https://github.com/user-attachments/assets/293e4e07-83e5-44ec-8ab3-df9d1f601a6f) </details> --- <details> <summary>Test instructions</summary> (Ubuntu 22.04) 1. Start ssh service on localhost. `ssh -D [::1]:1080 -f -C -q -N localhost` 2. Check that the service is up and running. ``` ps aux | grep ssh pepe 2860289 0.0 0.0 20456 5576 ? Ss 06:59 0:00 ssh -D [::1]:1080 -f -C -q -N localhost ``` 3. Check with `bitcoind` if it works correctly. `bitcoind -onlynet=ipv6 -proxy=[::1]:1080` 4. Check for established connections. ``` netstat -natl |grep 1080 tcp6 0 0 ::1:1080 :::* LISTEN tcp6 0 0 ::1:47610 ::1:1080 ESTABLISHED tcp6 0 0 ::1:1080 ::1:47610 ESTABLISHED tcp6 0 0 ::1:1080 ::1:47606 TIME_WAIT ``` ```./build/src/bitcoin-cli getpeerinfo [ { "id": 0, "addr": "[2a01:4f9:4a:2a07::2]:8333", "addrbind": "[::1]:47638", "network": "ipv6", ... ``` 5. Stop `bitcoind` and run `bitcoin-qt` adding the corresponding configuration in `settings.json`. ``` { "onlynet": "ipv6", "proxy": "[::1]:1080", } ``` 6. Open the Peers window to check available connections or run `getpeerinfo` on the rpc-console window. 7. Same can be done for Tor setting up `tor` service (I'll add instructions later) and configuring on its default port 9050 and forcing `"onlynet": "onion"` to verify easily the net traffic. </details> --- Thanks jarolrod and vasild for your help on validating ipv6 was not broken. ACKs for top commit: vasild: ACK fee4cba48472239f7a426db62f45c4b6af8e5ef2 promag: Code review ACK fee4cba48472239f7a426db62f45c4b6af8e5ef2. hebasto: ACK fee4cba48472239f7a426db62f45c4b6af8e5ef2, I have reviewed the code and it looks OK. Tree-SHA512: 4be9052569ccb1e17ce94fb15691debf0651fa172ed1a83d60696d10f20d469b19d70a979b65322951f5783cd7582d55b39b669edb588e20404d8d10e767c49a
Diffstat (limited to 'src')
-rw-r--r--src/qt/optionsmodel.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp
index 6a997ce556..e87ea0bd24 100644
--- a/src/qt/optionsmodel.cpp
+++ b/src/qt/optionsmodel.cpp
@@ -320,10 +320,15 @@ 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) {
+ // Valid and port within the valid range
+ // 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;
}