[tests] bind functional test nodes to 127.0.0.1 #12482

pull Sjors wants to merge 1 commits into bitcoin:master from Sjors:2018/02/test-framework-bind changing 6 files +21 −6
  1. Sjors commented at 3:00 PM on February 19, 2018: member

    Replaces #12200 which broke rpc_bind.py.

    Prevents OSX firewall allow-this-application-to-accept-inbound-connections permission popups and is generally safer.

    To prevent binding to 127.0.0.1, set self.bind_to_localhost_only = False.

    cc @jnewbery

  2. fanquake added the label Tests on Feb 19, 2018
  3. practicalswift commented at 3:04 PM on February 19, 2018: contributor

    Ouch, I naïvely assumed that we only bound to loopback for the tests (for obvious security reasons). Very nice find!

    Very strong concept ACK

  4. esotericnonsense commented at 6:53 PM on February 19, 2018: contributor

    Are there any cases in which we don't want to bind to lo? Later arguments take precedence if I'm not mistaken, couldn't this just be hardcoded into args and set extra_args to have -bind=0.0.0.0 if other behaviour is required?

  5. randolf commented at 8:14 PM on February 19, 2018: contributor

    @esotericnonsense Binding to 0.0.0.0 means "bind to all local addresses" (which includes loopback, as I suspect you probably already know), and is often a default for many server daemons, so I don't see why it should be necessary to bind to loopback specifically (unless, of course, -bind=127.0.0.1 was specified).

    On a side-note: When binding to 0.0.0.0, on some systems that support IPv6 this has the effect of also binding to ::1 in addition to 127.0.0.1 (I encountered this behaviour on Windows 7 a few years ago), but this really shouldn't be of any concern as it's a stack-implementation matter that I generally regard as being beyond the scope of most server daemons and other socket-listening applications.

  6. Sjors commented at 12:27 PM on February 20, 2018: member

    @esotericnonsense note that Cannot set -bind or -whitebind together with -listen=0.

  7. laanwj commented at 2:18 PM on February 22, 2018: member

    A little more correct would be to call it "bind only to localhost" instead of "bind to localhost", because the default will bind (P2P) on all interfaces including localhost, but concept ACK.

  8. Sjors force-pushed on Feb 22, 2018
  9. Sjors commented at 7:15 PM on February 22, 2018: member

    @laanwj I renamed the variable and added a more useful commit message.

  10. Sjors force-pushed on Feb 26, 2018
  11. Sjors force-pushed on Feb 26, 2018
  12. Sjors commented at 2:19 PM on February 26, 2018: member

    Rebased

  13. in test/functional/test_framework/test_framework.py:217 in 97d19ed4ea outdated
     213 | @@ -213,7 +214,7 @@ def run_test(self):
     214 |  
     215 |      # Public helper methods. These can be accessed by the subclass test scripts.
     216 |  
     217 | -    def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, binary=None):
     218 | +    def add_nodes(self, num_nodes, extra_args=None, rpchost=None, timewait=None, binary=None, bind=True):
    


    conscott commented at 1:32 PM on February 27, 2018:

    Nit, but should this argument also be bind_to_localhost_only?

    bind is a bit ambiguous.


    MarcoFalke commented at 6:11 PM on March 5, 2018:

    How is this argument passed along in this function?


    jnewbery commented at 9:07 PM on March 5, 2018:

    it isn't used

  14. laanwj commented at 6:04 PM on March 5, 2018: member

    @Sjors this is almost ready for merge, but needs responding to @conscott's nit.

  15. Sjors force-pushed on Mar 5, 2018
  16. jnewbery commented at 9:13 PM on March 5, 2018: member

    It doesn't make much sense to me to add the extra bind_to_localhost_only argument to the initialize_datadir() function. That function doesn't take any other arguments related to bitcoind config.

    It seems more architecturally sound to me to have the add_nodes() function update the config file directly, perhaps through an update_config_file() method on the TestNode class.

  17. Sjors force-pushed on Mar 5, 2018
  18. Sjors commented at 9:18 PM on March 5, 2018: member

    Nit addressed; I renamed bind to bind_to_localhost_only. I also removed it from add_nodes, not sure why I put it there in the first place.

  19. Sjors closed this on Mar 5, 2018

  20. Sjors reopened this on Mar 5, 2018

  21. Sjors commented at 9:19 PM on March 5, 2018: member

    @jnewbery just saw your suggestion, will look into that tomorrow...

  22. Sjors force-pushed on Mar 6, 2018
  23. [tests] bind functional test nodes to 127.0.0.1
    Prevents OSX firewall allow-this-application-to-accept-inbound-connections
    permission popups and is generally safer.
    
    To prevent binding to 127.0.0.1, set self.bind_to_localhost_only = False.
    b156ff7c30
  24. Sjors force-pushed on Mar 6, 2018
  25. Sjors commented at 9:48 PM on March 6, 2018: member

    @jnewbery improved...

  26. jnewbery commented at 11:41 PM on March 6, 2018: member

    utACK b156ff7c30175f5d23bde97a56a2c34af2196466. Will test tomorrow.

  27. laanwj merged this on Mar 7, 2018
  28. laanwj closed this on Mar 7, 2018

  29. laanwj referenced this in commit 0f7167989d on Mar 7, 2018
  30. Sjors deleted the branch on Mar 7, 2018
  31. PastaPastaPasta referenced this in commit 3075ac2776 on Jul 9, 2020
  32. PastaPastaPasta referenced this in commit 773a16daa3 on Jul 9, 2020
  33. xdustinface referenced this in commit 488c8e5753 on Jul 9, 2020
  34. MarcoFalke 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-14 09:15 UTC

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