Merge pull request #513 from pierre-l/#495

Listening address is hardcoded to 127 0 0 1 #495
This commit is contained in:
Svyatoslav Nikolsky 2018-07-16 08:05:21 +03:00 committed by GitHub
commit 424642fbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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,

View File

@ -19,6 +19,7 @@ pub struct Config {
pub services: Services,
pub port: u16,
pub connect: Option<net::SocketAddr>,
pub host: net::IpAddr,
pub seednodes: Vec<String>,
pub quiet: bool,
pub inbound_connections: u32,
@ -111,6 +112,14 @@ pub fn parse(matches: &clap::ArgMatches) -> Result<Config, String> {
None => InternetProtocol::default(),
};
let host = match matches.value_of("host") {
Some(s) => s.parse::<net::IpAddr>().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<Config, String> {
services: services,
port: port,
connect: connect,
host: host,
seednodes: seednodes,
inbound_connections: in_connections,
outbound_connections: out_connections,