mirror of https://github.com/dswd/vpncloud.git
Fix keepalive for small timeouts
This commit is contained in:
parent
2238a04cd3
commit
57c993e8d5
|
@ -7,6 +7,7 @@ This project follows [semantic versioning](http://semver.org).
|
||||||
|
|
||||||
- [added] Added crypto option AES128
|
- [added] Added crypto option AES128
|
||||||
- [changed] Updated dependencies
|
- [changed] Updated dependencies
|
||||||
|
- [fixed] Fixed keepalive for small timeouts
|
||||||
|
|
||||||
|
|
||||||
### v1.4.0 (2020-06-03)
|
### v1.4.0 (2020-06-03)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// This software is licensed under GPL-3 or newer (see LICENSE.md)
|
// This software is licensed under GPL-3 or newer (see LICENSE.md)
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
cmp::min,
|
cmp::{min, max},
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt,
|
fmt,
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
|
@ -473,7 +473,7 @@ impl<D: Device, P: Protocol, T: Table, S: Socket, TS: TimeSource> GenericCloud<D
|
||||||
let mut msg = Message::Peers(peers);
|
let mut msg = Message::Peers(peers);
|
||||||
self.broadcast_msg(&mut msg)?;
|
self.broadcast_msg(&mut msg)?;
|
||||||
// Reschedule for next update
|
// Reschedule for next update
|
||||||
let interval = min(self.update_freq as u16, self.peers.min_peer_timeout());
|
let interval = min(self.update_freq as u16, max(self.peers.min_peer_timeout()/2-60, 1));
|
||||||
self.next_peerlist = now + Time::from(interval);
|
self.next_peerlist = now + Time::from(interval);
|
||||||
}
|
}
|
||||||
// Connect to those reconnect_peers that are due
|
// Connect to those reconnect_peers that are due
|
||||||
|
|
|
@ -14,7 +14,8 @@ use super::{
|
||||||
use siphasher::sip::SipHasher24;
|
use siphasher::sip::SipHasher24;
|
||||||
use std::{
|
use std::{
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
net::{IpAddr, Ipv6Addr, SocketAddr}
|
net::{IpAddr, Ipv6Addr, SocketAddr},
|
||||||
|
cmp::max
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +285,7 @@ impl Config {
|
||||||
pub fn get_keepalive(&self) -> Duration {
|
pub fn get_keepalive(&self) -> Duration {
|
||||||
match self.keepalive {
|
match self.keepalive {
|
||||||
Some(dur) => dur,
|
Some(dur) => dur,
|
||||||
None => self.peer_timeout / 2 - 60
|
None => max(self.peer_timeout / 2 - 60, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue