diff --git a/src/snmp/client.rs b/src/snmp/client.rs index 4b94ab0..23524a0 100644 --- a/src/snmp/client.rs +++ b/src/snmp/client.rs @@ -3,9 +3,10 @@ use crate::secret::SecretString; use snmp2::SyncSession; use std::time::Duration; -// SNMP timeout in seconds - increased from 5s to 30s to match Phoenix app -// and reduce timeouts for slow devices or congested networks -const SNMP_TIMEOUT_SECS: u64 = 30; +// SNMP timeout in seconds - increased to 60s for SNMPv3 operations +// SNMPv3 has significant encryption/auth overhead, especially for large walks +// MikroTik enterprise tree (1.3.6.1.4.1.14988) can take 16+ seconds with v3 +const SNMP_TIMEOUT_SECS: u64 = 60; /// SNMPv3 configuration bundle #[derive(Clone)] diff --git a/src/snmp/device_poller.rs b/src/snmp/device_poller.rs index ce82d2c..beea54e 100644 --- a/src/snmp/device_poller.rs +++ b/src/snmp/device_poller.rs @@ -6,7 +6,9 @@ use std::str::FromStr; use std::time::Duration; use tokio::sync::{mpsc, oneshot}; -const SNMP_TIMEOUT_SECS: u64 = 30; +// SNMP timeout in seconds - increased to 60s for SNMPv3 operations +// SNMPv3 has significant encryption/auth overhead +const SNMP_TIMEOUT_SECS: u64 = 60; /// Request to perform an SNMP operation #[derive(Debug)] @@ -487,10 +489,7 @@ mod tests { fn test_parse_auth_protocol_standard() { use snmp2::v3::AuthProtocol; assert!(matches!(parse_auth_protocol("MD5"), Ok(AuthProtocol::Md5))); - assert!(matches!( - parse_auth_protocol("SHA"), - Ok(AuthProtocol::Sha1) - )); + assert!(matches!(parse_auth_protocol("SHA"), Ok(AuthProtocol::Sha1))); assert!(matches!( parse_auth_protocol("SHA1"), Ok(AuthProtocol::Sha1) @@ -541,10 +540,7 @@ mod tests { parse_auth_protocol("sha-256"), Ok(AuthProtocol::Sha256) )); - assert!(matches!( - parse_auth_protocol("md5"), - Ok(AuthProtocol::Md5) - )); + assert!(matches!(parse_auth_protocol("md5"), Ok(AuthProtocol::Md5))); } #[test] @@ -557,35 +553,17 @@ mod tests { use snmp2::v3::Cipher; assert!(matches!(parse_priv_protocol("DES"), Ok(Cipher::Des))); assert!(matches!(parse_priv_protocol("AES"), Ok(Cipher::Aes128))); - assert!(matches!( - parse_priv_protocol("AES128"), - Ok(Cipher::Aes128) - )); - assert!(matches!( - parse_priv_protocol("AES192"), - Ok(Cipher::Aes192) - )); - assert!(matches!( - parse_priv_protocol("AES256"), - Ok(Cipher::Aes256) - )); + assert!(matches!(parse_priv_protocol("AES128"), Ok(Cipher::Aes128))); + assert!(matches!(parse_priv_protocol("AES192"), Ok(Cipher::Aes192))); + assert!(matches!(parse_priv_protocol("AES256"), Ok(Cipher::Aes256))); } #[test] fn test_parse_priv_protocol_hyphenated() { use snmp2::v3::Cipher; - assert!(matches!( - parse_priv_protocol("AES-128"), - Ok(Cipher::Aes128) - )); - assert!(matches!( - parse_priv_protocol("AES-192"), - Ok(Cipher::Aes192) - )); - assert!(matches!( - parse_priv_protocol("AES-256"), - Ok(Cipher::Aes256) - )); + assert!(matches!(parse_priv_protocol("AES-128"), Ok(Cipher::Aes128))); + assert!(matches!(parse_priv_protocol("AES-192"), Ok(Cipher::Aes192))); + assert!(matches!(parse_priv_protocol("AES-256"), Ok(Cipher::Aes256))); assert!(matches!( parse_priv_protocol("AES-256-C"), Ok(Cipher::Aes256)