From 0f94767f8073d5199ccc9753c0e8a5e55a5f5f8f Mon Sep 17 00:00:00 2001 From: Mike Dilger Date: Tue, 21 Jan 2025 11:45:53 +1300 Subject: [PATCH] config param: allow_scrape_if_negentropy --- contrib/chorus.toml | 7 +++++++ docs/CONFIG.md | 6 ++++++ src/config.rs | 5 +++++ src/nostr.rs | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/contrib/chorus.toml b/contrib/chorus.toml index 21a321f..e475bde 100644 --- a/contrib/chorus.toml +++ b/contrib/chorus.toml @@ -197,6 +197,13 @@ allow_scrape_if_limited_to = 100 allow_scrape_if_max_seconds = 7200 +# Within negentropy synchronization, allow scraping +# +# The default is true +# +allow_scrape_if_negentropy = true + + # This is an integer indicating the maximum number of subscriptions a connection can have open # at a given time. # diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 33438c7..e85965b 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -168,6 +168,12 @@ See `allow_scraping` to learn the definition of a scrape. The default is 7200. +### allow_scrape_if_negentropy + +Within negentropy synchronization, allow scraping. + +The default is true + ### max_subscriptions This is an integer indicating the maximum number of subscriptions a connection can have open at a given time. diff --git a/src/config.rs b/src/config.rs index b77bede..3e7c096 100644 --- a/src/config.rs +++ b/src/config.rs @@ -29,6 +29,7 @@ pub struct FriendlyConfig { pub allow_scraping: bool, pub allow_scrape_if_limited_to: u32, pub allow_scrape_if_max_seconds: u64, + pub allow_scrape_if_negentropy: bool, pub max_subscriptions: usize, pub serve_ephemeral: bool, pub serve_relay_lists: bool, @@ -69,6 +70,7 @@ impl Default for FriendlyConfig { allow_scraping: false, allow_scrape_if_limited_to: 100, allow_scrape_if_max_seconds: 7200, + allow_scrape_if_negentropy: true, max_subscriptions: 128, serve_ephemeral: true, serve_relay_lists: true, @@ -111,6 +113,7 @@ impl FriendlyConfig { allow_scraping, allow_scrape_if_limited_to, allow_scrape_if_max_seconds, + allow_scrape_if_negentropy, max_subscriptions, serve_ephemeral, serve_relay_lists, @@ -175,6 +178,7 @@ impl FriendlyConfig { allow_scraping, allow_scrape_if_limited_to, allow_scrape_if_max_seconds, + allow_scrape_if_negentropy, max_subscriptions, serve_ephemeral, serve_relay_lists, @@ -218,6 +222,7 @@ pub struct Config { pub allow_scraping: bool, pub allow_scrape_if_limited_to: u32, pub allow_scrape_if_max_seconds: u64, + pub allow_scrape_if_negentropy: 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 23c1483..10c52b5 100644 --- a/src/nostr.rs +++ b/src/nostr.rs @@ -539,7 +539,7 @@ impl WebSocketService { let config = &*GLOBALS.config.read(); GLOBALS.store.get().unwrap().find_events( &filter, - config.allow_scraping, + config.allow_scraping || config.allow_scrape_if_negentropy, config.allow_scrape_if_limited_to, config.allow_scrape_if_max_seconds, screen,