Bump dep
[dnsseed-rust] / src / bgp_client.rs
index cb33305d4e17bde8b2d318fa438fb89775ddf2f4..a96de047731edc1bf0e958e61394e66d248f4a6a 100644 (file)
@@ -182,7 +182,7 @@ impl BGPClient {
                                .then(path_b.med.cmp(&path_a.med))
                });
                // TODO: Find last common ASN among all paths
-               *path_vecs[0].path.last().unwrap_or(&0)
+               *path_vecs.first().map(|route| route.path.last().unwrap_or(&0)).unwrap_or(&0)
        }
 
        pub fn disconnect(&self) {
@@ -257,7 +257,9 @@ impl BGPClient {
                                        }
                                        match bgp_msg {
                                                Message::Open(_) => {
-                                                       printer.add_line("Connected to BGP route provider".to_string(), true);
+                                                       client.routes.lock().unwrap().v4_table.clear();
+                                                       client.routes.lock().unwrap().v6_table.clear();
+                                                       printer.add_line("Connected to BGP route provider".to_string(), false);
                                                },
                                                Message::KeepAlive => {
                                                        let _ = sender.try_send(Message::KeepAlive);