disable libp2p upnp (#5449)
* disable libp2p upnp when passing --disable-upnp cli flag
This commit is contained in:
parent
65a6118c53
commit
6edf031490
@ -5,6 +5,7 @@ use crate::types::SnappyTransform;
|
|||||||
|
|
||||||
use crate::gossipsub;
|
use crate::gossipsub;
|
||||||
use libp2p::identify;
|
use libp2p::identify;
|
||||||
|
use libp2p::swarm::behaviour::toggle::Toggle;
|
||||||
use libp2p::swarm::NetworkBehaviour;
|
use libp2p::swarm::NetworkBehaviour;
|
||||||
use libp2p::upnp::tokio::Behaviour as Upnp;
|
use libp2p::upnp::tokio::Behaviour as Upnp;
|
||||||
use types::EthSpec;
|
use types::EthSpec;
|
||||||
@ -34,7 +35,7 @@ where
|
|||||||
/// Provides IP addresses and peer information.
|
/// Provides IP addresses and peer information.
|
||||||
pub identify: identify::Behaviour,
|
pub identify: identify::Behaviour,
|
||||||
/// Libp2p UPnP port mapping.
|
/// Libp2p UPnP port mapping.
|
||||||
pub upnp: Upnp,
|
pub upnp: Toggle<Upnp>,
|
||||||
/// The routing pub-sub mechanism for eth2.
|
/// The routing pub-sub mechanism for eth2.
|
||||||
pub gossipsub: Gossipsub,
|
pub gossipsub: Gossipsub,
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ use api_types::{PeerRequestId, Request, RequestId, Response};
|
|||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use gossipsub_scoring_parameters::{lighthouse_gossip_thresholds, PeerScoreSettings};
|
use gossipsub_scoring_parameters::{lighthouse_gossip_thresholds, PeerScoreSettings};
|
||||||
use libp2p::multiaddr::{self, Multiaddr, Protocol as MProtocol};
|
use libp2p::multiaddr::{self, Multiaddr, Protocol as MProtocol};
|
||||||
|
use libp2p::swarm::behaviour::toggle::Toggle;
|
||||||
use libp2p::swarm::{Swarm, SwarmEvent};
|
use libp2p::swarm::{Swarm, SwarmEvent};
|
||||||
use libp2p::{identify, PeerId, SwarmBuilder};
|
use libp2p::{identify, PeerId, SwarmBuilder};
|
||||||
use slog::{crit, debug, info, o, trace, warn};
|
use slog::{crit, debug, info, o, trace, warn};
|
||||||
@ -379,6 +380,11 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
|||||||
libp2p::connection_limits::Behaviour::new(limits)
|
libp2p::connection_limits::Behaviour::new(limits)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let upnp = Toggle::from(
|
||||||
|
config
|
||||||
|
.upnp_enabled
|
||||||
|
.then_some(libp2p::upnp::tokio::Behaviour::default()),
|
||||||
|
);
|
||||||
let behaviour = {
|
let behaviour = {
|
||||||
Behaviour {
|
Behaviour {
|
||||||
gossipsub,
|
gossipsub,
|
||||||
@ -387,7 +393,7 @@ impl<AppReqId: ReqId, TSpec: EthSpec> Network<AppReqId, TSpec> {
|
|||||||
identify,
|
identify,
|
||||||
peer_manager,
|
peer_manager,
|
||||||
connection_limits,
|
connection_limits,
|
||||||
upnp: Default::default(),
|
upnp,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user