-
Notifications
You must be signed in to change notification settings - Fork 2.6k
network: Only insert global addresses into the DHT. #5735
Conversation
Currently every address reported via libp2p-identify is inserted into the DHT which thus contains a multitude of unreachable addresses such as from 127.0.0.0/8 or 10.0.0.0/8. Issue #5099 suggested a dedicated service over UDP to gauge the reachability of an address, which would however incur extra I/O costs and be of limited use. As an alternative and simpler tactic, this PR only allows global IP addresses to be inserted into the DHT unless an explicit command-line flag `--allow-non-global-addresses-in-dht` is given or a node is started with `--dev`. This opt-in behaviour is meant to allow site-local networks to still make use of a DHT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CLI part LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably have to enable the flag for tests to pass. The tests use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely in favor of this.
In a personal project I had to drop all non global addresses returned by the Kusama Dht, because my server hoster thought I am doing a netscan over their backbone.
👍 for |
CLI option name could be a bit more user friendly. Something like |
I would be fine changing it to this. The meaning of "discover-local" overlaps perhaps slightly with mDNS but since we have a separate option to disable mDNS I guess it is fine. |
Please merge master for the CI to pass. |
Currently every address reported via libp2p-identify is inserted into the DHT which thus contains a multitude of unreachable addresses such as from 127.0.0.0/8 or 10.0.0.0/8.
Issue paritytech/polkadot-sdk#563 suggested a dedicated service over UDP to gauge the reachability of an address, which would however incur extra I/O costs and be of limited use.
As an alternative and simpler tactic, this PR only allows global IP addresses to be inserted into the DHT unless an explicit command-line flag
--allow-non-global-addresses-in-dht
is given or a node is started with--dev
. This opt-in behaviour is meant to allow site-local networks to still make use of a DHT.