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

* network: Only insert global addresses into the 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.

* Enable non-global in more test setups.

* Replace command-line option with different name.

* Another test fix.
This commit is contained in:
Toralf Wittner
2020-04-23 09:52:20 +02:00
committed by GitHub
parent 96b7cec1ce
commit 421ef498f4
8 changed files with 67 additions and 8 deletions
+7
View File
@@ -2283,6 +2283,12 @@ dependencies = [
"libc",
]
[[package]]
name = "ip_network"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee15951c035f79eddbef745611ec962f63f4558f1dadf98ab723cc603487c6f"
[[package]]
name = "ipnet"
version = "2.3.0"
@@ -6417,6 +6423,7 @@ dependencies = [
"futures-timer 3.0.2",
"futures_codec",
"hex",
"ip_network",
"libp2p",
"linked-hash-map",
"linked_hash_set",