Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Add 'interface' option to cli
Browse files Browse the repository at this point in the history
Additionally as to the port, the new  command line option
now allows the user to specify the network interface the P2P-Parity
listens, too. With support for 'all' and 'local' like in all other
versions of this flag. Default is 'all' (aka ).
  • Loading branch information
gnunicorn committed May 30, 2018
1 parent 93054ef commit 92818fb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions parity/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ usage! {
"--port=[PORT]",
"Override the port on which the node should listen.",

ARG arg_interface: (String) = "all", or |c: &Config| c.network.as_ref()?.interface.clone(),
"--interface=[IP]",
"Network interfaces. Valid values are 'all', 'local' or the ip of the interface you want parity to listen to.",

ARG arg_min_peers: (Option<u16>) = None, or |c: &Config| c.network.as_ref()?.min_peers.clone(),
"--min-peers=[NUM]",
"Try to maintain at least NUM peers.",
Expand Down Expand Up @@ -1119,6 +1123,7 @@ struct Network {
warp: Option<bool>,
warp_barrier: Option<u64>,
port: Option<u16>,
interface: Option<String>,
min_peers: Option<u16>,
max_peers: Option<u16>,
snapshot_peers: Option<u16>,
Expand Down Expand Up @@ -1567,6 +1572,7 @@ mod tests {
// -- Networking Options
flag_no_warp: false,
arg_port: 30303u16,
arg_interface: "all".into(),
arg_min_peers: Some(25u16),
arg_max_peers: Some(50u16),
arg_max_pending_peers: 64u16,
Expand Down Expand Up @@ -1823,6 +1829,7 @@ mod tests {
warp: Some(false),
warp_barrier: None,
port: None,
interface: None,
min_peers: Some(10),
max_peers: Some(20),
max_pending_peers: Some(30),
Expand Down
2 changes: 1 addition & 1 deletion parity/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ impl Configuration {

fn net_addresses(&self) -> Result<(SocketAddr, Option<SocketAddr>), String> {
let port = self.args.arg_ports_shift + self.args.arg_port;
let listen_address = SocketAddr::new("0.0.0.0".parse().unwrap(), port);
let listen_address = SocketAddr::new(self.interface(&self.args.arg_interface).parse().unwrap(), port);
let public_address = if self.args.arg_nat.starts_with("extip:") {
let host = &self.args.arg_nat[6..];
let host = host.parse().map_err(|_| format!("Invalid host given with `--nat extip:{}`", host))?;
Expand Down

0 comments on commit 92818fb

Please sign in to comment.