Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

network: Only insert global addresses into the DHT. #5735

Merged
merged 6 commits into from
Apr 23, 2020

Conversation

twittner
Copy link
Contributor

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.

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.
@twittner twittner requested a review from cecton as a code owner April 22, 2020 09:58
@twittner twittner requested a review from tomaka April 22, 2020 09:58
@twittner twittner added A0-please_review Pull request needs code review. B1-clientnoteworthy labels Apr 22, 2020
Copy link
Contributor

@cecton cecton left a 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

@tomaka tomaka requested review from mxinden and romanb April 22, 2020 10:16
Copy link
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
@mxinden and/or @romanb let me know your opinion this.

@tomaka
Copy link
Contributor

tomaka commented Apr 22, 2020

You probably have to enable the flag for tests to pass. The tests use /memory/... addresses.

Copy link
Contributor

@mxinden mxinden left a 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.

client/network/src/discovery.rs Show resolved Hide resolved
client/network/src/discovery.rs Show resolved Hide resolved
@mxinden
Copy link
Contributor

mxinden commented Apr 22, 2020

👍 for B1-clientnoteworthy. Maybe someone is using Substrate in a private IPv4 network.

@arkpar
Copy link
Member

arkpar commented Apr 22, 2020

CLI option name could be a bit more user friendly. Something like --discover-local - Enable peer discovery on local networks. "DHT" is an implementation detail.

@twittner
Copy link
Contributor Author

CLI option name could be a bit more user friendly. Something like --discover-local - Enable peer discovery on local networks. "DHT" is an implementation detail.

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.

@tomaka
Copy link
Contributor

tomaka commented Apr 22, 2020

Please merge master for the CI to pass.

@tomaka tomaka added A8-mergeoncegreen and removed A0-please_review Pull request needs code review. labels Apr 23, 2020
@tomaka tomaka merged commit 435a710 into paritytech:master Apr 23, 2020
@twittner twittner deleted the address-checks branch April 23, 2020 08:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants