Additional address filter
This commit is contained in:
parent
0bef355494
commit
64913d5009
@ -356,7 +356,11 @@ impl Discovery {
|
||||
}
|
||||
let mut entry = NodeEntry { id: node.clone(), endpoint: source.clone() };
|
||||
if !entry.endpoint.is_valid() {
|
||||
debug!(target: "discovery", "Bad address: {:?}", entry);
|
||||
debug!(target: "discovery", "Got bad address: {:?}, using {:?} instead", entry, from);
|
||||
entry.endpoint.address = from.clone();
|
||||
}
|
||||
if !entry.endpoint.is_global() {
|
||||
debug!(target: "discovery", "Got local address: {:?}, using {:?} instead", entry, from);
|
||||
entry.endpoint.address = from.clone();
|
||||
}
|
||||
self.update_node(entry.clone());
|
||||
|
@ -105,12 +105,12 @@ impl NetworkConfiguration {
|
||||
if self.nat_enabled {
|
||||
info!("Enabling NAT...");
|
||||
match search_gateway() {
|
||||
Err(ref err) => info!("Error: {}", err),
|
||||
Err(ref err) => warn!("Port mapping error: {}", err),
|
||||
Ok(gateway) => {
|
||||
let int_addr = SocketAddrV4::from_str("127.0.0.1:30304").unwrap();
|
||||
match gateway.get_any_address(PortMappingProtocol::TCP, int_addr, 0, "Parity Node/TCP") {
|
||||
Err(ref err) => {
|
||||
info!("There was an error! {}", err);
|
||||
warn!("Port mapping error: {}", err);
|
||||
},
|
||||
Ok(ext_addr) => {
|
||||
info!("Local gateway: {}, External ip address: {}", gateway, ext_addr);
|
||||
@ -356,7 +356,7 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
|
||||
},
|
||||
|s| KeyPair::from_secret(s).expect("Error creating node secret key"))
|
||||
};
|
||||
let endpoint = NodeEndpoint { address: addr.clone(), udp_port: addr.port() };
|
||||
let endpoint = NodeEndpoint { address: config.public_address.clone(), udp_port: addr.port() };
|
||||
let discovery = Discovery::new(&keys, endpoint, DISCOVERY);
|
||||
let path = config.config_path.clone();
|
||||
let mut host = Host::<Message> {
|
||||
|
@ -96,6 +96,13 @@ impl NodeEndpoint {
|
||||
SocketAddr::V6(a) => !a.ip().is_unspecified()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_global(&self) -> bool {
|
||||
match self.address {
|
||||
SocketAddr::V4(a) => a.ip().is_global(),
|
||||
SocketAddr::V6(a) => a.ip().is_global()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for NodeEndpoint {
|
||||
|
Loading…
Reference in New Issue
Block a user