Add UPnP support for Lighthouse (#1587)

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

## Issue Addressed

#927 

## Proposed Changes

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

## Additional Info



Co-authored-by: Age Manning <Age@AgeManning.com>
This commit is contained in:
Sean
2020-10-02 08:47:00 +00:00
parent 2cc20101d4
commit 94b17ce02b
29 changed files with 342 additions and 33 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

@@ -474,7 +474,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;
}
@@ -483,6 +483,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(())
}