diff options
author | Jake McGinty <me@jake.su> | 2018-02-15 04:39:01 +0000 |
---|---|---|
committer | Jake McGinty <me@jake.su> | 2018-02-15 04:39:01 +0000 |
commit | adda3a848b149211b1ed8417ec21472b0ad60f68 (patch) | |
tree | 520eecd324cb508c17e2f06a17383497fb6d93fe /src/consts.rs | |
parent | use x25519-dalek for a significant performance boost (diff) | |
download | wireguard-rs-adda3a848b149211b1ed8417ec21472b0ad60f68.tar.xz wireguard-rs-adda3a848b149211b1ed8417ec21472b0ad60f68.zip |
proper passive keepalives
Diffstat (limited to 'src/consts.rs')
-rw-r--r-- | src/consts.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/consts.rs b/src/consts.rs index 1989832..27f53dd 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -1,23 +1,22 @@ #![allow(dead_code)] use std::u64; +use std::time::Duration; -// transport ratcheting time limits, in seconds -pub const REKEY_ATTEMPT_TIME: u64 = 90; -pub const REKEY_AFTER_TIME: u64 = 120; -pub const REJECT_AFTER_TIME: u64 = 180; +lazy_static! { + pub static ref REKEY_ATTEMPT_TIME: Duration = Duration::new(90, 0); + pub static ref REKEY_AFTER_TIME: Duration = Duration::new(121, 0); + pub static ref REJECT_AFTER_TIME: Duration = Duration::new(180, 0); + pub static ref REKEY_TIMEOUT: Duration = Duration::new(5, 0); + pub static ref KEEPALIVE_TIMEOUT: Duration = Duration::new(10, 0); + pub static ref RECEIVE_REKEY_TIMEOUT: Duration = *REKEY_AFTER_TIME - *KEEPALIVE_TIMEOUT - *REKEY_TIMEOUT; + pub static ref TIMER_TICK_DURATION: Duration = Duration::from_millis(100); +} // transport ratcheting message limits, in seconds pub const REKEY_AFTER_MESSAGES: u64 = u64::MAX - (1 << 16) - 1; pub const REJECT_AFTER_MESSAGES: u64 = u64::MAX - (1 << 4) - 1; -// how often to attempt rekeying -pub const REKEY_TIMEOUT: u64 = 5; - -// keepalive packet timer, in seconds -pub const KEEPALIVE_TIMEOUT: u64 = 10; - -pub const RECEIVE_REKEY_TIMEOUT: u64 = REKEY_AFTER_TIME - KEEPALIVE_TIMEOUT - REKEY_TIMEOUT; pub const TRANSPORT_HEADER_SIZE: usize = 16; pub const AEAD_TAG_SIZE: usize = 16; |