Repository: citahub/cita (language: rust)

Issue:
[skip audit] fix for operation repeated peer key
fix for operation repeated peer key


Discussion / hints:

Fix patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index 9c6083d32..4d509c73c 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -145,7 +145,9 @@ jobs:
       - restore_cache: *restore-security-audit-cache
       - run:
           name: Check Security Audit
-          command: make security_audit
+          command: |
+            echo "Add it back when bump protobuf to `v2.6.0`."
+            # make security_audit
       - save_cache: *save-security-audit-cache
 
   "Check Contracts":
diff --git a/cita-bft b/cita-bft
index 588c7cac9..7041bda10 160000
--- a/cita-bft
+++ b/cita-bft
@@ -1,1 +1,1 @@
-Subproject commit 588c7cac9b839466a6f32d185bf7435765bae498
+Subproject commit 7041bda10499e88e7646f5df707b8058c09c9c67
diff --git a/cita-network/src/node_manager.rs b/cita-network/src/node_manager.rs
index 64c208b25..a464b7bb9 100644
--- a/cita-network/src/node_manager.rs
+++ b/cita-network/src/node_manager.rs
@@ -577,12 +577,9 @@ impl AddConnectedNodeReq {
                         node_status.session_id = Some(*repeated_id);
                         node_status.score += SUCCESS_DIALING_SCORE;
 
-                        let _ = service
-                            .connected_addrs
-                            .entry(self.session_id)
-                            .and_modify(|v| {
-                                v.trans_addr = Some(dialing_addr);
-                            });
+                        let _ = service.connected_addrs.entry(*repeated_id).and_modify(|v| {
+                            v.trans_addr = Some(dialing_addr);
+                        });
                     }
                 }
             }
@@ -620,11 +617,6 @@ impl AddConnectedNodeReq {
                     .connected_addrs
                     .insert(self.session_id, TransformAddr::new(session_info.addr, None));
 
-                // Add connected peer keys
-                let _ = service
-                    .connected_peer_keys
-                    .insert(self.init_msg.peer_key, self.session_id);
-
                 // If it is an active connection, need to set this node in known_addrs has been connected.
                 if self.ty == SessionType::Outbound {
                     if let Some(ref mut node_status) =
@@ -636,6 +628,12 @@ impl AddConnectedNodeReq {
                 }
             }
 
+            // Add connected peer keys
+            // Because AddRepeatedNodeReq maybe already did above action
+            let _ = service
+                .connected_peer_keys
+                .insert(self.init_msg.peer_key, self.session_id);
+
             info!(
                 "[NodeManager] connected_addrs info: {:?}",
                 service.connected_addrs
@@ -754,8 +752,23 @@ impl AddRepeatedNodeReq {
         if let Some(ref mut node_status) = service.known_addrs.get_mut(&self.addr) {
             node_status.session_id = Some(self.session_id);
             node_status.score += SUCCESS_DIALING_SCORE;
-        }
 
+            if let Some(session_info) = service.pending_connected_addrs.remove(&self.session_id) {
+                let _ = service.connected_addrs.insert(
+                    self.session_id,
+                    TransformAddr::new(session_info.addr, Some(self.addr)),
+                );
+            } else {
+                let _ = service
+                    .connected_addrs
+                    .entry(self.session_id)
+                    .and_modify(|v| {
+                        v.trans_addr = Some(self.addr);
+                    });
+            }
+        } else {
+            warn!("[NodeManager] Cant find repeated sock addr in known addrs");
+        }
         // This dialing is finished.
         service.dialing_node = None;
     }


Test patch: