Fail if user passes in local port for non-tor usage

Local port is only used when running behind tor. Fail if user passes a local
port number when running in non-tor mode.
This commit is contained in:
Tobin C. Harding 2020-10-28 09:45:39 +11:00
parent 42d194f758
commit 464b699426

View File

@ -125,7 +125,10 @@ fn new_swarm(listen: Multiaddr, port: Option<u16>) -> Result<Swarm> {
} }
#[cfg(not(feature = "tor"))] #[cfg(not(feature = "tor"))]
{ {
transport = transport::build(local_key_pair)?; transport = match port {
None => transport::build(local_key_pair)?,
Some(port) => anyhow::bail!("local port should not be provided for non-tor usage"),
};
} }
let mut swarm = libp2p::swarm::SwarmBuilder::new(transport, behaviour, local_peer_id.clone()) let mut swarm = libp2p::swarm::SwarmBuilder::new(transport, behaviour, local_peer_id.clone())