Repository navigation
Conversation
With --proxy (e.g. Tor), the CLI wallet still resolved the node host name with a local DNS lookup before connecting, and sent the proxy only the IP (socks5 ATYP=1). That leaks the lookup outside Tor, and names that only the proxy can resolve (e.g. .onion) didn't work at all. With the proxy on, a node given by name is now passed through as "host:port" (FlyClient Config::m_vNodeHosts) down to ProxyConnector, which sends a socks5 CONNECT with ATYP=3 (domain name), so the proxy resolves it. IP literals still go as ATYP=1, byte for byte as before; without the proxy nothing changes. The proxy/no-proxy connect branches in FlyClient are folded into Connection::ConnectNode(). proxy_test: request encoding (domain, IP, 255/256-byte and empty hosts), host:port parsing, reactor rejections, and an end-to-end check with a local socks5 server that the CONNECT carries the host name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: with
--proxy(Tor or another socks5 proxy), the wallet no longer looks up the node's host name with a local DNS query. It sends the name to the proxy (socks5ATYP=3), so the proxy resolves it (#1198).Why:
CreateNetworkcallednodeAddress.resolve(nodeURI)(a localgetaddrinfo) before checking--proxy, andProxyConnectorcould only encode an IPv4 address (ATYP=1).DOMAINNAME = 0x03was defined but never used. So a Tor user's DNS query for the node went out over the normal network, and names only the proxy can resolve (e.g..onion) didn't work at all.How to see the bug (master, no internet needed): run a tiny socks5 stub on
127.0.0.1:39151that prints the CONNECT request, thenImprovement
-nwith--proxynode.invalid:8100ATYP=03 node.invalid:8100localhost:8100ATYP=01 127.0.0.1(resolved locally)ATYP=03 localhost:8100127.0.0.2:8100(IP)ATYP=01ATYP=01, same bytes--proxyHow:
FlyClient::Config::m_vNodeHosts) to a newNodeConnection::Connect(host, port, proxy), thenReactor::tcp_connect_with_proxy(host, …), thenSocks5_Protocol::makeRequest(host, port).EC_EINVAL.FlyClientare merged intoConnection::ConnectNode().--proxy_addritself is still a local endpoint.Testing:
proxy_testhas a newproxy_domain_name_request_test: exact request bytes for a domain and an IP, the 255/256-byte and empty hosts,host:portparsing, reactor rejections, and an end-to-end check against a local socks5 server that the CONNECT carriesnode.invalid. It passes. If the domain path is made to send the old IP request instead, it fails (CHECK failed … line 406).address_test,tcpclient_testandnode_testpass. The CLI rows above compare master and this branch against a stub proxy.Fixes #1198