mirror of https://github.com/dswd/vpncloud.git
Fix lost peng
This commit is contained in:
parent
45ab0a4608
commit
ac1aec9d25
24
src/cloud.rs
24
src/cloud.rs
|
@ -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) {
|
||||
init.handle_message(data)
|
||||
} else if is_init_message(data.message()) {
|
||||
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)
|
||||
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 {
|
||||
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) {
|
||||
peer.crypto.handle_message(data)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue