Config settings for serve_ephemeral and serve_relay_lists

This commit is contained in:
Mike Dilger 2024-02-21 08:40:44 +13:00
parent 86c74f9e40
commit a09aa5a002
5 changed files with 32 additions and 4 deletions

View File

@ -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,
)

View File

@ -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.

View File

@ -19,4 +19,6 @@ FriendlyConfig(
// your entire relay
allow_scraping: true,
max_subscriptions: 32,
serve_ephemeral: true,
serve_relay_lists: true,
)

View File

@ -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<Pubkey> = 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,
}

View File

@ -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;
}