aboutsummaryrefslogtreecommitdiff
path: root/src/netapp.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-21 12:14:19 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-21 12:14:19 +0200
commit94c01a3565f0f5804ea096370aced22f8e4a723a (patch)
tree39f23ebe1360ef1891e8e01d9ae670b5ebd4d196 /src/netapp.rs
parente9add586a5fd6304473b9138b920e325629346f5 (diff)
downloadnetapp-94c01a3565f0f5804ea096370aced22f8e4a723a.tar.gz
netapp-94c01a3565f0f5804ea096370aced22f8e4a723a.zip
try fix
Diffstat (limited to 'src/netapp.rs')
-rw-r--r--src/netapp.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/netapp.rs b/src/netapp.rs
index 8c0b50c..acaed62 100644
--- a/src/netapp.rs
+++ b/src/netapp.rs
@@ -24,7 +24,7 @@ use crate::proto::*;
use crate::server::*;
use crate::util::*;
-#[derive(Serialize, Deserialize)]
+#[derive(Serialize, Deserialize, Debug)]
pub(crate) struct HelloMessage {
pub server_addr: Option<IpAddr>,
pub server_port: u16,
@@ -243,13 +243,16 @@ impl NetApp {
.log_err("Failed to await for connection collector");
}
- /// Drop all endpoint handlers
+ /// Drop all endpoint handlers, as well as handlers for connection/disconnection
+ /// events. (This disables the peering strategy)
///
/// Use this when terminating to break reference cycles
pub fn drop_all_handlers(&self) {
for (_, endpoint) in self.endpoints.read().unwrap().iter() {
endpoint.drop_handler();
}
+ self.on_connected_handler.store(None);
+ self.on_disconnected_handler.store(None);
}
/// Attempt to connect to a peer, given by its ip:port and its public key.
@@ -411,6 +414,7 @@ impl NetApp {
#[async_trait]
impl EndpointHandler<HelloMessage> for NetApp {
async fn handle(self: &Arc<Self>, msg: &HelloMessage, from: NodeID) {
+ debug!("Hello from {:?}: {:?}", hex::encode(from), msg);
if let Some(h) = self.on_connected_handler.load().as_ref() {
if let Some(c) = self.server_conns.read().unwrap().get(&from) {
let remote_ip = msg.server_addr.unwrap_or_else(|| c.remote_addr.ip());