HomePhabricator

net: don't bind on 0.0.0.0 if binds are restricted to Tor

Description

net: don't bind on 0.0.0.0 if binds are restricted to Tor

Summary:

The semantic of `-bind` is to restrict the binding only to some address.
If not specified, then the user does not care and we bind to `0.0.0.0`.
If specified then we should honor the restriction and bind only to the specified address.

Before this change, if no `-bind` is given then we would bind to `0.0.0.0:8333` and to `127.0.0.1:8334` (incoming Tor) which is ok - the user does not care to restrict the binding.

However, if only `-bind=addr:port=onion` is given (without ordinary `-bind=`) then we would bind to `addr:port` _and_ to `0.0.0.0:8333` in addition.

Change the above to not do the additional bind: if only
`-bind=addr:port=onion` is given (without ordinary `-bind=`) then bind to `addr:port` (only) and consider incoming connections to that as Tor and do not advertise it. I.e. a Tor-only node.

Backport of core#20234.

Test Plan:

ninja all check-all

Reviewers: #bitcoin_abc, sdulfari

Reviewed By: #bitcoin_abc, sdulfari

Differential Revision: https://reviews.bitcoinabc.org/D12343

Details

Provenance
Vasil Dimov <vd@FreeBSD.org>Authored on Oct 22 2020, 18:34
FabienCommitted on Oct 21 2022, 08:32
FabienPushed on Oct 21 2022, 08:32
Reviewer
Restricted Project
Differential Revision
D12343: net: don't bind on 0.0.0.0 if binds are restricted to Tor
Parents
rABCfcccee0cf4f4: [avalanche] Cleanup old usage of legacyavaproof in functional test framework
Branches
Unknown
Tags
Unknown