Fixed node address detection on incoming connection (#6093)
This commit is contained in:
parent
253bc333c7
commit
4c32177ef3
@ -857,14 +857,19 @@ impl Host {
|
|||||||
// Add it to the node table
|
// Add it to the node table
|
||||||
if !s.info.originated {
|
if !s.info.originated {
|
||||||
if let Ok(address) = s.remote_addr() {
|
if let Ok(address) = s.remote_addr() {
|
||||||
let entry = NodeEntry { id: id, endpoint: NodeEndpoint { address: address, udp_port: address.port() } };
|
// We can't know remote listening ports, so just assume defaults and hope for the best.
|
||||||
self.nodes.write().add_node(Node::new(entry.id.clone(), entry.endpoint.clone()));
|
let endpoint = NodeEndpoint { address: SocketAddr::new(address.ip(), DEFAULT_PORT), udp_port: DEFAULT_PORT };
|
||||||
|
let entry = NodeEntry { id: id, endpoint: endpoint };
|
||||||
|
let mut nodes = self.nodes.write();
|
||||||
|
if !nodes.contains(&entry.id) {
|
||||||
|
nodes.add_node(Node::new(entry.id.clone(), entry.endpoint.clone()));
|
||||||
let mut discovery = self.discovery.lock();
|
let mut discovery = self.discovery.lock();
|
||||||
if let Some(ref mut discovery) = *discovery {
|
if let Some(ref mut discovery) = *discovery {
|
||||||
discovery.add_node(entry);
|
discovery.add_node(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (p, _) in self.handlers.read().iter() {
|
for (p, _) in self.handlers.read().iter() {
|
||||||
if s.have_capability(*p) {
|
if s.have_capability(*p) {
|
||||||
ready_data.push(*p);
|
ready_data.push(*p);
|
||||||
|
@ -236,6 +236,11 @@ impl NodeTable {
|
|||||||
self.nodes.get_mut(id)
|
self.nodes.get_mut(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a node exists in the table.
|
||||||
|
pub fn contains(&self, id: &NodeId) -> bool {
|
||||||
|
self.nodes.contains_key(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Apply table changes coming from discovery
|
/// Apply table changes coming from discovery
|
||||||
pub fn update(&mut self, mut update: TableUpdates, reserved: &HashSet<NodeId>) {
|
pub fn update(&mut self, mut update: TableUpdates, reserved: &HashSet<NodeId>) {
|
||||||
for (_, node) in update.added.drain() {
|
for (_, node) in update.added.drain() {
|
||||||
|
Loading…
Reference in New Issue
Block a user