UPNP is not disabled when tor-only settings are in effect. #2927

issue ghost opened this issue on August 23, 2013
  1. ghost commented at 5:12 PM on August 23, 2013: none

    With the following enabled, UPNP should not attempt to open a port at the router for 8333, however in the latest stable the port is uselessly opened. At best it's doing nothing productive, at worst it's just advertising the existence of a bitcoin client.

    onlynet=tor
    tor=127.0.0.1:9050
    discover=0
    listen=0
    

    Compiling with USE_UPNP=- works as a temporary solution, but is by no means ideal.

  2. Diapolo commented at 11:21 AM on August 25, 2013: none

    If using Bitcoin-Qt make sure to unset the UPnP option. For using bitcoind, I'm looking into a little patch currently.

  3. gmaxwell commented at 11:52 AM on August 25, 2013: contributor

    @63 Thanks for the report! A lot of the developers build with UPNP much of the time (or, well, at least I do), unfortunate that this slipped through. @Diapolo we should not UPNP if listen=0, and separately, we should not UPNP if onlynet=tor.

  4. sipa commented at 2:04 PM on August 25, 2013: member

    As far as I can see, -listen=0 should already disable UPnP by default. Only if you enable it explicitly through -upnp (or upnp=1), or the GUI should it be enabled. If that's not the case, it's a bug.

  5. ghost commented at 6:09 AM on August 28, 2013: none

    @sipa Reproduced in the latest master.

    bitcoin.conf:

    active UPNP mappings on the router:

  6. laanwj commented at 11:52 AM on November 7, 2013: member

    My reasoning would be that the bind=XXX re-enables listen, and hence upnp is not disabled.

    Edit: does it work if you explicitly add upnp=0 to the config?

  7. sipa commented at 12:30 PM on November 7, 2013: member

    If you explicitly set listen to false, bind shouldn't re-enable it.

  8. ghost commented at 12:55 AM on November 29, 2013: none

    Yes, @laanwj, running with the line

    upnp=0 
    

    or compiling without UPNP does work, but logically if we're not listening it shouldn't be enabled to begin with, right?

  9. laanwj commented at 12:25 PM on January 17, 2014: member

    Guess this needs to be fixed before 0.9 as well.

  10. Diapolo commented at 3:25 PM on January 17, 2014: none

    Would this suffice (change in net.cpp)?

    <pre> // only map ports when not using Tor if (!IsLimited(NET_TOR)) // Map ports with UPnP MapPort(GetBoolArg("-upnp", fDefaultUpnp)); </pre>

    We already have in init.cpp the check for listen:

    <pre> if (!GetBoolArg("-listen", true)) { // do not map ports or try to retrieve public IP when not listening (pointless) SoftSetBoolArg("-upnp", false); SoftSetBoolArg("-discover", false); } </pre>

  11. laanwj commented at 3:28 PM on January 17, 2014: member

    Your change would make it impossible to map ports when using Tor.

    The goal is to make the default (if not overridden using -upnp) to not map ports when using Tor, not to make it completely impossible.

  12. Diapolo commented at 3:35 PM on January 17, 2014: none

    I'm out... too many cases to consider for my ill brain ^^.

  13. laanwj removed this from the milestone 0.9.0 on Feb 24, 2014
  14. gmaxwell added this to the milestone 0.9.2 on May 11, 2014
  15. gmaxwell commented at 8:49 PM on May 11, 2014: contributor

    This appears to have been already solved:

    if (!GetBoolArg("-listen", true)) {
        // do not map ports or try to retrieve public IP when not listening (pointless)
        if (SoftSetBoolArg("-upnp", false))
    ...
    
  16. laanwj commented at 5:57 AM on May 12, 2014: member

    @gmaxwell well, the problem seems to be that he has a bind:XXX statement (for a hidden service), which re-enables listen so it never goes into that.

  17. laanwj removed this from the milestone 0.9.2 on Nov 27, 2014
  18. ghost removed this from the milestone 0.9.2 on Nov 27, 2014
  19. laanwj referenced this in commit 8c35b6f3be on May 18, 2015
  20. laanwj commented at 9:24 AM on May 18, 2015: member

    Foremost, if your goal is to hide completely behind a proxy you should use -proxy, not -tor. -tor is only meant for hyrid Tor/clearnet nodes.

    Given that, see #6153 for fix.

  21. laanwj closed this on May 27, 2015

  22. laanwj referenced this in commit ebd7d8d78c on Jun 2, 2015
  23. IntegralTeam referenced this in commit 8c743968bd on Jun 4, 2019
  24. reddink referenced this in commit 084db0cb83 on May 27, 2020
  25. DrahtBot locked this on Sep 8, 2021

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: 2026-04-13 18:16 UTC

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