mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 20:57:59 +00:00
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:
@@ -398,6 +398,8 @@ pub struct NetworkConfiguration {
|
||||
pub transport: TransportConfig,
|
||||
/// Maximum number of peers to ask the same blocks in parallel.
|
||||
pub max_parallel_downloads: u32,
|
||||
/// Should we insert non-global addresses into the DHT?
|
||||
pub allow_non_globals_in_dht: bool
|
||||
}
|
||||
|
||||
impl NetworkConfiguration {
|
||||
@@ -428,6 +430,7 @@ impl NetworkConfiguration {
|
||||
use_yamux_flow_control: false,
|
||||
},
|
||||
max_parallel_downloads: 5,
|
||||
allow_non_globals_in_dht: false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -448,6 +451,7 @@ impl NetworkConfiguration {
|
||||
.collect()
|
||||
];
|
||||
|
||||
config.allow_non_globals_in_dht = true;
|
||||
config
|
||||
}
|
||||
|
||||
@@ -466,6 +470,7 @@ impl NetworkConfiguration {
|
||||
.collect()
|
||||
];
|
||||
|
||||
config.allow_non_globals_in_dht = true;
|
||||
config
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user