Setting torcontrol overrides proxy address #25265

issue kroese openend this issue on June 1, 2022
  1. kroese commented at 11:28 pm on June 1, 2022: none

    When using Bitcoin in combination with Tor, to generate a hidden service to allow for inbound connections, it is needed to add torcontrol like this:

    0proxy=1.2.3.4:9050
    1torcontrol=1.2.3.4:29501
    

    The problem is that adding torcontrol results in overriding the proxy address with 127.0.0.1 and the end-result is that Bitcoin cannot connect to Tor any longer:

    connect() to 127.0.0.1:9050 failed after wait: Connection refused (111)

    It should have connected to 1.2.3.4 instead.

    So why does adding torcontrol overrides the configured address for proxy?

  2. kroese added the label Bug on Jun 1, 2022
  3. kroese renamed this:
    Setting torcontrol overrides proxy
    Setting torcontrol overrides proxy address
    on Jun 1, 2022
  4. fjahr commented at 3:08 pm on June 19, 2022: contributor
    @kroese can you share any relevant logs outputs and also what other settings you are using that are networking related?
  5. laanwj added the label P2P on Jun 20, 2022
  6. laanwj commented at 4:50 pm on June 20, 2022: member

    So why does adding torcontrol overrides the configured address for proxy?

    To be precise, it overrides the specific proxy for NET_ONION, e.g. -onion. See https://github.com/bitcoin/bitcoin/blob/master/src/torcontrol.cpp#L385

    I guess it shouldn’t be doing so if an explicit one was provided on the command line.

  7. fjahr commented at 10:06 pm on June 20, 2022: contributor

    So why does adding torcontrol overrides the configured address for proxy?

    To be precise, it overrides the specific proxy for NET_ONION, e.g. -onion. See https://github.com/bitcoin/bitcoin/blob/master/src/torcontrol.cpp#L385

    I guess it shouldn’t be doing so if an explicit one was provided on the command line.

    That’s a good hint! I will look into it unless you have already started working on it.

  8. laanwj commented at 4:50 am on June 21, 2022: member
    No I haven’t, feel free to pick it up!
  9. luke-jr commented at 3:04 am on July 26, 2022: member
    If you want to override -torcontrol, you should be using -onion. Overriding -proxy is expected behaviour (otherwise why use -torcontrol at all?).
  10. fjahr commented at 7:27 pm on July 26, 2022: contributor

    If you want to override -torcontrol, you should be using -onion. Overriding -proxy is expected behaviour (otherwise why use -torcontrol at all?).

    To me, this doesn’t make sense. -onion is the more specific version of -proxy, so it makes sense that -onion overrides -proxy. But the interactions with any other parameter should be consistent between the two. Everything else is very confusing.

  11. vasild commented at 8:11 am on August 18, 2022: contributor

    This was briefly discussed in #15423 (review). Related PR: #22830.

    IMO it is ok that the auto-discovered Tor proxy overrides the generic one from -proxy because -proxy could be just an ordinary SOCKS5 proxy unrelated to the Tor network. If that is not ok, then the user has the option to override the auto-discovered one by using -onion. That is, -proxy < -torcontrol (auto-discover) < -onion looks reasonable to me.

    If it is changed to -torcontrol (auto-discover) < -proxy < -onion then there is no way for the user to setup a configuration that uses auto-discovery + a manually specified non-Tor-related SOCKS5 proxy (with -proxy). The auto-discovery is nice because it returns a correct location, even after configuration changes in the network or the Tor daemon, without user interaction.

  12. Fidel76y commented at 7:49 pm on October 14, 2024: none
    According to my understanding bitcoin core designed automatically to configure tor when using torcontrol, when torcontrol is active the device automatically manages the tor instance making it override the manual proxy configuration
  13. vasild commented at 9:53 am on November 5, 2024: contributor

    According to my understanding bitcoin core designed automatically to configure tor when using torcontrol,

    It automatically configures the location of the Tor proxy, used for outgoing connections to Tor. Don’t confuse this with the creation of the Tor hidden service for accepting incoming connections from Tor, that is controlled by -listenonion=0|1. @kroese, it is a bit unclear from the OP, did it connect to torcontrol and retrieve an invalid proxy from there? That is, 127.0.0.1:9050 instead of 1.2.3.4:9050? That would be odd. I think the torcontrol reports the value of SOCKSPort from torrc and if you are using some tunneling that could probably confuse it. If you know better, you can set the correct value of the Tor proxy with -onion:

    0proxy=1.2.3.4:9050
    1torcontrol=1.2.3.4:29501
    2onion=1.2.3.4:9050
    

    I think that the current priority of -proxy < -torcontrol (auto-discover) < -onion is correct, as elaborated above, so I guess this issue can be closed as “not a bug, will not fix”.

  14. kroese commented at 10:11 am on November 5, 2024: none
    @vasild I cannot remember anymore, it was two years ago that I ran into this behaviour. So feel free to close it.
  15. maflcko closed this on Nov 7, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me