Compare commits

...

2 Commits

Author SHA1 Message Date
Dennis Schwerdel ac1aec9d25 Fix lost peng 2020-11-01 23:33:00 +01:00
Dennis Schwerdel 45ab0a4608 Do not reconnect to timed out pending conections 2020-11-01 23:02:27 +01:00
2 changed files with 24 additions and 9 deletions

View File

@ -339,10 +339,11 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
}
}
for addr in del {
self.peers.remove(&addr);
self.pending_inits.remove(&addr);
if self.peers.remove(&addr).is_some() {
self.connect_sock(addr)?;
}
}
Ok(())
}
@ -716,6 +717,15 @@ 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) {
init.handle_message(data)
} else if is_init_message(data.message()) {
let mut result = None;
if let Some(peer) = self.peers.get_mut(&src) {
if peer.crypto.has_init() {
result = Some(peer.crypto.handle_message(data))
}
}
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 {
@ -725,6 +735,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
}
Err(err) => return Err(err)
}
}
} else if let Some(peer) = self.peers.get_mut(&src) {
peer.crypto.handle_message(data)
} else {

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 {
self.core.is_some()
}