nostr-rs-relay

My dev fork of nostr-rs-relay
git clone git://jb55.com/nostr-rs-relay
Log | Files | Refs | README | LICENSE

commit 50577b2dfa1d3f9f4b4ed9ada015a9351545e3d5
parent a6cb6f8486cc5a720b74f589a26810c1ab6b64ca
Author: William Casarin <jb55@jb55.com>
Date:   Fri,  4 Nov 2022 17:58:28 -0700

feat: add network.ping_interval setting

Add a ping interval setting that allows you to customize the websocket
ping interval. The default of 5 minutes may be too high for some proxy
servers that disconnect connections that are held open for too long.

Diffstat:
Mconfig.toml | 3+++
Msrc/config.rs | 2++
Msrc/server.rs | 2+-
3 files changed, 6 insertions(+), 1 deletion(-)

diff --git 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 @@ -29,6 +29,7 @@ pub struct Network { pub port: u16, pub address: String, pub remote_ip_header: Option<String>, // 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 @@ -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);