diff --git a/contrib/chorus.ron b/contrib/chorus.ron index 1a5ed30..8a7ccbd 100644 --- a/contrib/chorus.ron +++ b/contrib/chorus.ron @@ -2,6 +2,7 @@ FriendlyConfig( data_directory: "/opt/chorus/var/chorus", ip_address: "127.0.0.1", port: 443, + hostname: "localhost", use_tls: true, certchain_pem_path: "/opt/chorus/etc/tls/fullchain.pem", key_pem_path: "/opt/chorus/etc/tls/privkey.pem", @@ -13,4 +14,7 @@ FriendlyConfig( ], verify_events: true, allow_scraping: false, + max_subscriptions: 32, + serve_ephemeral: true, + serve_relay_lists: true, ) \ No newline at end of file diff --git a/docs/CONFIG.md b/docs/CONFIG.md index f2f23d1..4257a4c 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -130,3 +130,15 @@ If you set this too low, clients will be incentivised to resubmit updated subscr It is strongly recommended to not go below 16. Default is 32. + +### serve_ephemeral + +Accept and serve all ephemeral events to everybody. + +Default is true. + +### serve_relay_lists + +Accept and serve kind 10002 events to everybody. + +Default is true. diff --git a/sample/sample.config.ron b/sample/sample.config.ron index 576fa4d..229e5e3 100644 --- a/sample/sample.config.ron +++ b/sample/sample.config.ron @@ -19,4 +19,6 @@ FriendlyConfig( // your entire relay allow_scraping: true, max_subscriptions: 32, + serve_ephemeral: true, + serve_relay_lists: true, ) \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 6db98c5..119674d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,6 +20,8 @@ pub struct FriendlyConfig { pub verify_events: bool, pub allow_scraping: bool, pub max_subscriptions: usize, + pub serve_ephemeral: bool, + pub serve_relay_lists: bool, } impl Default for FriendlyConfig { @@ -40,6 +42,8 @@ impl Default for FriendlyConfig { verify_events: true, allow_scraping: false, max_subscriptions: 32, + serve_ephemeral: true, + serve_relay_lists: true, } } } @@ -62,6 +66,8 @@ impl FriendlyConfig { verify_events, allow_scraping, max_subscriptions, + serve_ephemeral, + serve_relay_lists, } = self; let mut public_key: Option = None; @@ -93,6 +99,8 @@ impl FriendlyConfig { verify_events, allow_scraping, max_subscriptions, + serve_ephemeral, + serve_relay_lists, }) } } @@ -115,4 +123,6 @@ pub struct Config { pub verify_events: bool, pub allow_scraping: bool, pub max_subscriptions: usize, + pub serve_ephemeral: bool, + pub serve_relay_lists: bool, } diff --git a/src/nostr.rs b/src/nostr.rs index 72fa5ce..00c57f3 100644 --- a/src/nostr.rs +++ b/src/nostr.rs @@ -366,12 +366,12 @@ async fn screen_incoming_event( } // Accept relay lists from anybody - if event.kind() == Kind(10002) { + if event.kind() == Kind(10002) && GLOBALS.config.get().unwrap().serve_relay_lists { return Ok(true); } // Allow if event kind ephemeral - if event.kind().is_ephemeral() { + if event.kind().is_ephemeral() && GLOBALS.config.get().unwrap().serve_ephemeral { return Ok(true); } @@ -408,12 +408,12 @@ pub fn screen_outgoing_event( authorized_user: bool, ) -> bool { // Allow Relay Lists - if event.kind() == Kind(10002) { + if event.kind() == Kind(10002) && GLOBALS.config.get().unwrap().serve_relay_lists { return true; } // Allow if event kind ephemeral - if event.kind().is_ephemeral() { + if event.kind().is_ephemeral() && GLOBALS.config.get().unwrap().serve_ephemeral { return true; }