Add UPnP support for Lighthouse (#1587)

This commit was modified by Paul H whilst rebasing master onto
v0.3.0-staging

Adding UPnP support will help grow the DHT by allowing NAT traversal for peers with UPnP supported routers.

Using IGD library: https://docs.rs/igd/0.10.0/igd/

Adding the  the libp2p tcp port and discovery udp port. If this fails it simply logs the attempt and moves on

Co-authored-by: Age Manning <Age@AgeManning.com>
This commit is contained in:
Sean
2020-10-02 08:47:00 +00:00
committed by Paul Hauner
parent 8fde9a4016
commit 6af3bc9ce2
29 changed files with 368 additions and 32 deletions

View File

@@ -75,6 +75,12 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
.help("One or more comma-delimited base64-encoded ENR's to bootstrap the p2p network. Multiaddr is also supported.")
.takes_value(true),
)
.arg(
Arg::with_name("disable-upnp")
.long("disable-upnp")
.help("Disables UPnP support. Setting this will prevent Lighthouse from attempting to automatically establish external port mappings.")
.takes_value(false),
)
.arg(
Arg::with_name("enr-udp-port")
.long("enr-udp-port")

View File

@@ -507,7 +507,7 @@ pub fn set_network_config(
config.enr_address = Some(resolved_addr);
}
if cli_args.is_present("disable_enr_auto_update") {
if cli_args.is_present("disable-enr-auto-update") {
config.discv5_config.enr_update = false;
}
@@ -516,6 +516,10 @@ pub fn set_network_config(
warn!(log, "Discovery is disabled. New peers will not be found");
}
if cli_args.is_present("disable-upnp") {
config.upnp_enabled = false;
}
Ok(())
}