mirror of https://github.com/dswd/vpncloud.git
Improve logging
This commit is contained in:
parent
dd9444c5ef
commit
aab4f000b5
20
src/cloud.rs
20
src/cloud.rs
|
@ -353,7 +353,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for addr in del {
|
for addr in del {
|
||||||
info!("Forgot peer: {}", addr_nice(addr));
|
info!("Forgot peer {} due to timeout", addr_nice(addr));
|
||||||
self.peers.remove(&addr);
|
self.peers.remove(&addr);
|
||||||
self.table.remove_claims(addr);
|
self.table.remove_claims(addr);
|
||||||
self.connect_sock(addr)?; // Try to reconnect
|
self.connect_sock(addr)?; // Try to reconnect
|
||||||
|
@ -707,14 +707,20 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
||||||
} 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 init = self.crypto.peer_instance(self.create_node_info());
|
||||||
let msg_result = init.handle_message(data);
|
let msg_result = init.handle_message(data);
|
||||||
if msg_result.is_ok() {
|
match msg_result {
|
||||||
|
Ok(res) => {
|
||||||
self.pending_inits.insert(src, init);
|
self.pending_inits.insert(src, init);
|
||||||
|
Ok(res)
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Error in init message from peer {}: {}", addr_nice(src), err);
|
||||||
|
return Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg_result
|
|
||||||
} 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)
|
||||||
} else {
|
} else {
|
||||||
error!("Received non-init message from unknown peer {}", addr_nice(src));
|
info!("Ignoring non-init message from unknown peer {}", addr_nice(src));
|
||||||
return Ok(())
|
return Ok(())
|
||||||
};
|
};
|
||||||
match msg_result {
|
match msg_result {
|
||||||
|
@ -737,10 +743,12 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
||||||
let src = try_fail!(self.socket.receive(buffer), "Failed to read from network socket: {}");
|
let src = try_fail!(self.socket.receive(buffer), "Failed to read from network socket: {}");
|
||||||
self.traffic.count_in_traffic(src, buffer.len());
|
self.traffic.count_in_traffic(src, buffer.len());
|
||||||
if let Err(e) = self.handle_net_message(src, buffer) {
|
if let Err(e) = self.handle_net_message(src, buffer) {
|
||||||
error!("Error: {}", e);
|
|
||||||
if let Error::CryptoInit(_) = e {
|
if let Error::CryptoInit(_) = e {
|
||||||
info!("Closing pending connection to {} due to error", addr_nice(src));
|
debug!("Crypto init error: {}", e);
|
||||||
|
info!("Closing pending connection to {} due to error in crypto init", addr_nice(src));
|
||||||
self.pending_inits.remove(&src);
|
self.pending_inits.remove(&src);
|
||||||
|
} else {
|
||||||
|
error!("Error: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl CryptoCore {
|
||||||
tag_space.clone_from_slice(tag.as_ref());
|
tag_space.clone_from_slice(tag.as_ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decrypt_with_key<'a>(key: &mut CryptoKey, nonce: Nonce, data_and_tag: &'a mut [u8]) -> Result<(), Error> {
|
fn decrypt_with_key(key: &mut CryptoKey, nonce: Nonce, data_and_tag: &mut [u8]) -> Result<(), Error> {
|
||||||
if nonce < key.min_nonce {
|
if nonce < key.min_nonce {
|
||||||
return Err(Error::Crypto("Old nonce rejected"))
|
return Err(Error::Crypto("Old nonce rejected"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue