From 8c9809bc0c52546359a6058cad861e610fc8406b Mon Sep 17 00:00:00 2001 From: Revertron Date: Fri, 19 Feb 2021 18:14:48 +0100 Subject: [PATCH] Fixed some network errors. --- src/dns/server.rs | 4 ++-- src/p2p/network.rs | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dns/server.rs b/src/dns/server.rs index 903fff1..12cf28c 100644 --- a/src/dns/server.rs +++ b/src/dns/server.rs @@ -175,7 +175,7 @@ impl DnsServer for DnsUdpServer { /// This method takes ownership of the server, preventing the method from being called multiple times. fn run_server(self) -> Result<()> { // Bind the socket - let socket = UdpSocket::bind(("[::]", self.context.dns_port))?; + let socket = UdpSocket::bind(("::", self.context.dns_port))?; // Spawn threads for handling requests for thread_id in 0..self.thread_count { @@ -290,7 +290,7 @@ impl DnsTcpServer { impl DnsServer for DnsTcpServer { fn run_server(mut self) -> Result<()> { - let socket = TcpListener::bind(("[::]", self.context.dns_port))?; + let socket = TcpListener::bind(("::", self.context.dns_port))?; // Spawn threads for handling requests, and create the channels for thread_id in 0..self.thread_count { diff --git a/src/p2p/network.rs b/src/p2p/network.rs index b30663f..1b1a00d 100644 --- a/src/p2p/network.rs +++ b/src/p2p/network.rs @@ -168,8 +168,11 @@ fn handle_connection_event(context: Arc>, peers: &mut Peers, regi Err(_) => { return Ok(false); } } } else { - // Consider connection as unreliable - return Ok(false); + // Try to reregister connection + let peer = peers.get_mut_peer(&event.token()).expect("Error getting peer for connection"); + let mut stream = peer.get_stream(); + registry.reregister(stream, event.token(), Interest::READABLE); + return Ok(true); } }