Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node/wire: manage logs for error establishing connection
Fintan Halpenny committed 3 months ago
commit a65fb8b60be13e2d60fd3ad275d96a80305b79e6
parent 7c6d4acad1ebc7e8d512f08834fc7156d97cc99a
1 file changed +16 -1
modified crates/radicle-node/src/wire.rs
@@ -990,7 +990,7 @@ where
                                .push_back(reactor::Action::RegisterTransport(token, transport));
                        }
                        Err(err) => {
-
                            log::error!(target: "wire", "Error establishing connection to {addr}: {err}");
+
                            logger::establish_connection(&addr, &err);

                            self.service.disconnected(
                                node_id,
@@ -1221,6 +1221,21 @@ fn session<G: Ecdh<Pk = NodeId>>(
    WireSession::new(proxy, noise)
}

+
mod logger {
+
    use radicle::node::Address;
+

+
    pub fn establish_connection(addr: &Address, err: &std::io::Error) {
+
        use std::io::ErrorKind::*;
+
        match err.kind() {
+
            ConnectionRefused | ConnectionReset | HostUnreachable | ConnectionAborted
+
            | NotConnected => {
+
                log::info!(target: "wire", "Could not establish connection to {addr}: {err}")
+
            }
+
            _ => log::error!(target: "wire", "Error establishing connection to {addr}: {err}"),
+
        }
+
    }
+
}
+

#[cfg(test)]
mod test {
    use super::*;