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

@@ -14,7 +14,7 @@ milagro = ["bls/milagro"]
[dependencies]
beacon_node = { "path" = "../beacon_node" }
tokio = "0.2.21"
tokio = "0.2.22"
slog = { version = "2.5.2", features = ["max_level_trace"] }
sloggers = "1.0.0"
types = { "path" = "../consensus/types" }

View File

@@ -5,7 +5,7 @@ authors = ["Paul Hauner <paul@paulhauner.com>"]
edition = "2018"
[dependencies]
tokio = { version = "0.2.21", features = ["full"] }
tokio = { version = "0.2.22", features = ["macros"] }
slog = { version = "2.5.2", features = ["max_level_trace"] }
sloggers = "1.0.0"
types = { "path" = "../../consensus/types" }

View File

@@ -30,6 +30,8 @@ mod metrics;
pub const ETH2_CONFIG_FILENAME: &str = "eth2-spec.toml";
const LOG_CHANNEL_SIZE: usize = 2048;
/// The maximum time in seconds the client will wait for all internal tasks to shutdown.
const MAXIMUM_SHUTDOWN_TIME: u64 = 3;
/// Builds an `Environment`.
pub struct EnvironmentBuilder<E: EthSpec> {
@@ -424,7 +426,7 @@ impl<E: EthSpec> Environment<E> {
/// Shutdown the `tokio` runtime when all tasks are idle.
pub fn shutdown_on_idle(self) {
self.runtime
.shutdown_timeout(std::time::Duration::from_secs(2))
.shutdown_timeout(std::time::Duration::from_secs(MAXIMUM_SHUTDOWN_TIME))
}
/// Fire exit signal which shuts down all spawned services