diff --git a/pbtc/cli.yml b/pbtc/cli.yml index c3bd031c..82e6f35e 100644 --- a/pbtc/cli.yml +++ b/pbtc/cli.yml @@ -21,6 +21,12 @@ args: value_name: IP help: Connect only to the specified node. takes_value: true + - host: + short: h + long: host + value_name: HOST + help: Listen for connections on HOST. + takes_value: true - seednode: short: s long: seednode diff --git a/pbtc/commands/start.rs b/pbtc/commands/start.rs index 25bfd1f7..d0a06534 100644 --- a/pbtc/commands/start.rs +++ b/pbtc/commands/start.rs @@ -96,7 +96,7 @@ pub fn start(cfg: config::Config) -> Result<(), String> { protocol_version: PROTOCOL_VERSION, protocol_minimum: PROTOCOL_MINIMUM, magic: cfg.consensus.magic(), - local_address: SocketAddr::new("127.0.0.1".parse().unwrap(), cfg.port), + local_address: SocketAddr::new(cfg.host, cfg.port), services: cfg.services, user_agent: cfg.user_agent, start_height: 0, diff --git a/pbtc/config.rs b/pbtc/config.rs index 5c17ff60..99462dcb 100644 --- a/pbtc/config.rs +++ b/pbtc/config.rs @@ -19,6 +19,7 @@ pub struct Config { pub services: Services, pub port: u16, pub connect: Option, + pub host: net::IpAddr, pub seednodes: Vec, pub quiet: bool, pub inbound_connections: u32, @@ -111,6 +112,14 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { None => InternetProtocol::default(), }; + let host = match matches.value_of("host") { + Some(s) => s.parse::().map_err(|_| "Invalid host".to_owned())?, + None => match only_net { + InternetProtocol::IpV6 => "::".parse().unwrap(), + _ => "0.0.0.0".parse().unwrap(), + } + }; + let rpc_config = parse_rpc_config(network, matches)?; let block_notify_command = match matches.value_of("blocknotify") { @@ -147,6 +156,7 @@ pub fn parse(matches: &clap::ArgMatches) -> Result { services: services, port: port, connect: connect, + host: host, seednodes: seednodes, inbound_connections: in_connections, outbound_connections: out_connections,