diff --git a/config.toml b/config.toml index dbacd08..e179e89 100644 --- a/config.toml +++ b/config.toml @@ -51,6 +51,9 @@ port = 8080 #remote_ip_header = "x-forwarded-for" #remote_ip_header = "cf-connecting-ip" +# Websocket ping interval in seconds, defaults to 5 minutes +#ping_interval = 300 + [options] # Reject events that have timestamps greater than this many seconds in # the future. Recommended to reject anything greater than 30 minutes diff --git a/src/config.rs b/src/config.rs index 62eac74..4787320 100644 --- a/src/config.rs +++ b/src/config.rs @@ -29,6 +29,7 @@ pub struct Network { pub port: u16, pub address: String, pub remote_ip_header: Option, // retrieve client IP from this HTTP header if present + pub ping_interval: u32, } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -207,6 +208,7 @@ impl Default for Settings { }, network: Network { port: 8080, + ping_interval: 300, address: "0.0.0.0".to_owned(), remote_ip_header: None, }, diff --git a/src/server.rs b/src/server.rs index 1f4e799..c5e11a1 100644 --- a/src/server.rs +++ b/src/server.rs @@ -427,7 +427,7 @@ async fn nostr_server( let mut last_message_time = Instant::now(); // ping interval (every 5 minutes) - let default_ping_dur = Duration::from_secs(300); + let default_ping_dur = Duration::from_secs(settings.network.ping_interval.into()); // disconnect after 20 minutes without a ping response or event. let max_quiet_time = Duration::from_secs(60 * 20);