mirror of https://github.com/dswd/vpncloud.git
Make clippy happy
This commit is contained in:
parent
798964030f
commit
79916104ba
|
@ -379,7 +379,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
|||
for entry in &mut self.reconnect_peers {
|
||||
// Schedule for next second if node is connected
|
||||
for addr in &entry.resolved {
|
||||
if self.peers.contains_key(&addr) {
|
||||
if self.peers.contains_key(addr) {
|
||||
entry.tries = 0;
|
||||
entry.timeout = 1;
|
||||
entry.next = now + 1;
|
||||
|
@ -424,7 +424,7 @@ impl<D: Device, P: Protocol, S: Socket, TS: TimeSource> GenericCloud<D, P, S, TS
|
|||
let now = TS::now();
|
||||
let mut buffer = MsgBuffer::new(SPACE_BEFORE);
|
||||
let mut del: SmallVec<[SocketAddr; 3]> = SmallVec::new();
|
||||
for (&addr, ref data) in &self.peers {
|
||||
for (&addr, data) in &self.peers {
|
||||
if data.timeout < now {
|
||||
del.push(addr);
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ impl Config {
|
|||
if let Some(ref s) = self.hook {
|
||||
script = Some(s);
|
||||
}
|
||||
if let Some(ref s) = self.hooks.get(event) {
|
||||
if let Some(s) = self.hooks.get(event) {
|
||||
script = Some(s);
|
||||
}
|
||||
if script.is_none() {
|
||||
|
|
|
@ -110,7 +110,7 @@ struct CryptoKey {
|
|||
|
||||
impl CryptoKey {
|
||||
fn new(rand: &SystemRandom, key: LessSafeKey, nonce_half: bool) -> Self {
|
||||
let mut send_nonce = Nonce::random(&rand);
|
||||
let mut send_nonce = Nonce::random(rand);
|
||||
send_nonce.set_msb(if nonce_half { 0x80 } else { 0x00 });
|
||||
CryptoKey {
|
||||
key,
|
||||
|
|
|
@ -235,7 +235,7 @@ impl InitMsg {
|
|||
|
||||
let signed_data = &r.into_inner()[0..pos];
|
||||
let public_key = signature::UnparsedPublicKey::new(&ED25519, &public_key_data);
|
||||
if public_key.verify(&signed_data, &signature).is_err() {
|
||||
if public_key.verify(signed_data, &signature).is_err() {
|
||||
return Err(Error::Crypto("invalid signature"));
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ impl InitMsg {
|
|||
w.write_u8(Self::PART_ECDH_PUBLIC_KEY)?;
|
||||
let key_bytes = ecdh_public_key.bytes();
|
||||
w.write_u16::<NetworkEndian>(key_bytes.len() as u16)?;
|
||||
w.write_all(&key_bytes)?;
|
||||
w.write_all(key_bytes)?;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
@ -522,8 +522,8 @@ impl<P: Payload> InitState<P> {
|
|||
},
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let mut bytes = out.buffer();
|
||||
let len = msg.write_to(&mut bytes, &self.key_pair).expect("Buffer too small");
|
||||
let bytes = out.buffer();
|
||||
let len = msg.write_to(bytes, &self.key_pair).expect("Buffer too small");
|
||||
self.last_message = Some(bytes[0..len].to_vec());
|
||||
out.set_length(len);
|
||||
}
|
||||
|
@ -662,7 +662,7 @@ mod tests {
|
|||
|
||||
impl Payload for Vec<u8> {
|
||||
fn write_to(&self, buffer: &mut MsgBuffer) {
|
||||
buffer.buffer().write_all(&self).expect("Buffer too small");
|
||||
buffer.buffer().write_all(self).expect("Buffer too small");
|
||||
buffer.set_length(self.len())
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ impl RotationState {
|
|||
if let Some(ref private_key) = self.proposed {
|
||||
// Still a proposed key that has not been confirmed, proposal must have been lost
|
||||
if self.timeout {
|
||||
let proposed_key = Self::compute_public_key(&private_key);
|
||||
let proposed_key = Self::compute_public_key(private_key);
|
||||
if let Some((ref confirmed_key, message_id)) = self.confirmed {
|
||||
// Reconfirm last confirmed key
|
||||
Self::send(
|
||||
|
@ -271,7 +271,7 @@ mod tests {
|
|||
assert!(key2.is_some());
|
||||
let key2 = key2.unwrap();
|
||||
assert_eq!(key2.id, 2);
|
||||
assert_eq!(key2.use_for_sending, false);
|
||||
assert!(!key2.use_for_sending);
|
||||
assert!(!out2.is_empty());
|
||||
let msg2 = out2.msg().unwrap();
|
||||
assert_eq!(msg2.message_id, 2);
|
||||
|
@ -281,14 +281,14 @@ mod tests {
|
|||
assert!(key.is_some());
|
||||
let key = key.unwrap();
|
||||
assert_eq!(key.id, 2);
|
||||
assert_eq!(key.use_for_sending, true);
|
||||
assert!(key.use_for_sending);
|
||||
// Cycle 2
|
||||
let key1 = node1.cycle(&mut out1);
|
||||
let key2 = node2.cycle(&mut out2);
|
||||
assert!(key1.is_some());
|
||||
let key1 = key1.unwrap();
|
||||
assert_eq!(key1.id, 3);
|
||||
assert_eq!(key1.use_for_sending, false);
|
||||
assert!(!key1.use_for_sending);
|
||||
assert!(!out1.is_empty());
|
||||
let msg1 = out1.msg().unwrap();
|
||||
assert_eq!(msg1.message_id, 3);
|
||||
|
@ -300,7 +300,7 @@ mod tests {
|
|||
assert!(key.is_some());
|
||||
let key = key.unwrap();
|
||||
assert_eq!(key.id, 3);
|
||||
assert_eq!(key.use_for_sending, true);
|
||||
assert!(key.use_for_sending);
|
||||
// Cycle 3
|
||||
let key1 = node1.cycle(&mut out1);
|
||||
let key2 = node2.cycle(&mut out2);
|
||||
|
@ -309,7 +309,7 @@ mod tests {
|
|||
assert!(key2.is_some());
|
||||
let key2 = key2.unwrap();
|
||||
assert_eq!(key2.id, 4);
|
||||
assert_eq!(key2.use_for_sending, false);
|
||||
assert!(!key2.use_for_sending);
|
||||
assert!(!out2.is_empty());
|
||||
let msg2 = out2.msg().unwrap();
|
||||
assert_eq!(msg2.message_id, 4);
|
||||
|
@ -319,7 +319,7 @@ mod tests {
|
|||
assert!(key.is_some());
|
||||
let key = key.unwrap();
|
||||
assert_eq!(key.id, 4);
|
||||
assert_eq!(key.use_for_sending, true);
|
||||
assert!(key.use_for_sending);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in New Issue