Since bitcoind default to localhost, onion=ip:port needs to be set when tor is running on a remote server, even if it is the same as proxy
doc: Extend `onion` option's description #16940
pull roshii wants to merge 1 commits into bitcoin:master from roshii:tor-usage changing 1 files +3 −2-
roshii commented at 12:43 PM on September 23, 2019: none
-
Extend `onion` option's description 9cb149cc59
- fanquake added the label Docs on Sep 23, 2019
- fanquake requested review from laanwj on Sep 23, 2019
-
sipa commented at 1:58 PM on September 23, 2019: member
I think this is wrong, localhost is not special here.
-
DrahtBot commented at 4:23 PM on September 23, 2019: member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #16901 (doc: Add markdownlint rules & apply formatting by ch4ot1c)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
roshii commented at 8:32 PM on September 23, 2019: none
Thanks for the prompt feedback. I realize my pull request may be lacking some background information, which I'll correct here after.
Details
The present documentation mentions that the
onionoption doesn't need to be setup (to set the proxy server to use for Tor hidden services) if itsip:portis equal to the one set inproxy. That considered, I did originally setup torrc and bitcoin.conf as follows. Note that both service are running in their own docker container, within the same user-defined docker network.torrc
RunAsDaemon 0 SocksPort 192.168.247.2:9050 ControlPort 192.168.247.2:9051 HashedControlPassword 16:HASHEDBLABLA... BridgeRelay 1 Log notice file /var/log/tor/log ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy ExtORPort auto ORPort 54321 ServerTransportListenAddr obfs4 0.0.0.0:45321bitcoin.conf
proxy=192.168.247.2:9050 txindex=1 disablewallet=1 printtoconsole=1 rpcuser=user rpcpassword=password rpcbind=192.168.247.3 server=1 listen=1 torcontrol=192.168.247.2:9051 torpassword=blablaWhat I get
bitcoind tries to connect to the tor hidden service proxy at 127.0.0.1:9050 (for the record, it is 127.0.0.1 that I did "translate" to localhost).
See relevant log here after.date stream content 2019-09-23 12:03:54 stdout 2019-09-23T12:03:54Z connect() to 127.0.0.1:9050 failed after select(): Connection refused (111) 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z AddLocal(xyz.onion:8333,4) 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Cached service private key to /bitcoin/.bitcoin/onion_private_key 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Got service ID xyz, advertising service xyz.onion:8333 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: ADD_ONION successful 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Authentication successful 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Using HASHEDPASSWORD authentication 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Supported authentication method: HASHEDPASSWORD 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Connected to Tor version 0.3.5.8 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z tor: Successfully connected! 2019-09-23 12:03:53 stdout 2019-09-23T12:03:53Z torcontrol thread start What I expect
Following
onionoption description, I expect bitcoind to connect to the very sameip:hostset inproxy, i.e.192.168.247.2:9050in the above example.Fix
Adding
onion=192.168.247.2:9050tobitcoin.confdoes resolve the issue and result in the very same log without the following error line.connect() to 127.0.0.1:9050 failed after select(): Connection refused (111)Conclusion
Obviously, it is not working as described. And so either the description isn't correct - which my little contribution should fix, either the implementation should be corrected to reflect wanted behaviour.
I hope this clarifies the reason of my pull request. Looking forward at your comments.
-
qubenix commented at 10:01 PM on September 23, 2019: contributor
-
laanwj commented at 8:19 AM on September 25, 2019: member
I think this is wrong, localhost is not special here.
Yes, this is wrong. Even if tor is running on a different host,
-proxy=<host>:<ip>will set both the onion and normal proxy to that.If this is somehow not working in your case, that's a bug and please create an issue about that.
- laanwj closed this on Sep 25, 2019
- DrahtBot locked this on Dec 16, 2021