Fix lost peng

This commit is contained in:
Dennis Schwerdel 2020-11-01 23:33:00 +01:00
parent 45ab0a4608
commit ac1aec9d25
2 changed files with 21 additions and 7 deletions

View File

@ -717,14 +717,24 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
let msg_result = if let Some(init) = self.pending_inits.get_mut(&src) { let msg_result = if let Some(init) = self.pending_inits.get_mut(&src) {
init.handle_message(data) init.handle_message(data)
} else if is_init_message(data.message()) { } else if is_init_message(data.message()) {
let mut init = self.crypto.peer_instance(self.create_node_info()); let mut result = None;
let msg_result = init.handle_message(data); if let Some(peer) = self.peers.get_mut(&src) {
match msg_result { if peer.crypto.has_init() {
Ok(res) => { result = Some(peer.crypto.handle_message(data))
self.pending_inits.insert(src, init); }
Ok(res) }
if let Some(result) = result {
result
} else {
let mut init = self.crypto.peer_instance(self.create_node_info());
let msg_result = init.handle_message(data);
match msg_result {
Ok(res) => {
self.pending_inits.insert(src, init);
Ok(res)
}
Err(err) => return Err(err)
} }
Err(err) => return Err(err)
} }
} else if let Some(peer) = self.peers.get_mut(&src) { } else if let Some(peer) = self.peers.get_mut(&src) {
peer.crypto.handle_message(data) peer.crypto.handle_message(data)

View File

@ -269,6 +269,10 @@ impl<P: Payload> PeerCrypto<P> {
} }
} }
pub fn has_init(&self) -> bool {
self.init.is_some()
}
pub fn is_ready(&self) -> bool { pub fn is_ready(&self) -> bool {
self.core.is_some() self.core.is_some()
} }