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
✗ CI failure Fintan Halpenny committed 4 months ago
commit 75b665ff3af4c29c53ad6979bbb93b8635301122
parent 47dc2c562ca5f6566dd357094f275d7bbf014064
2 failed (2 total) View logs
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::*;