upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2026-01-14 13:40:33 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2026-01-14 13:43:40 +0000
commit5897e4bccd41f1a9ebb01a11280cea929c93d2c0 (patch)
treecbe4d2447312b7bc7653bef874b6fb23d60a0ede /src/config.rs
parent4c8f1813fada9ce2bfd371095b0721bff68173e3 (diff)
parent2821578202d1313c23c30a5dbae39548822e3c55 (diff)
Add defensive relay features with rate limiting and connection limits
Implement defensive measures to protect against DoS attacks: - Add explicit rate limits (500 subscriptions, 60 events/min per connection) - Add total connection limit (default: 500, configurable via NGIT_MAX_CONNECTIONS) - Update configuration across all 4 locations (src, nix, docs, .env.example) Per-IP rate limiting deferred until abuse is detected in production or implemented in rust-nostr relay-builder to benefit the entire Nostr ecosystem. Documentation added explaining the defensive features and rationale. Detailed analysis of other relay implementations preserved in commit history.
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs
index 0f0d853..0014003 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -469,6 +469,11 @@ pub struct Config {
469 /// All events from these authors are blocked from both relay storage and purgatory 469 /// All events from these authors are blocked from both relay storage and purgatory
470 #[arg(long, env = "NGIT_EVENT_BLACKLIST", default_value = "")] 470 #[arg(long, env = "NGIT_EVENT_BLACKLIST", default_value = "")]
471 pub event_blacklist: String, 471 pub event_blacklist: String,
472
473 /// Maximum total connections to the relay (default: 500)
474 /// Prevents connection exhaustion DoS attacks
475 #[arg(long, env = "NGIT_MAX_CONNECTIONS", default_value_t = 500)]
476 pub max_connections: usize,
472} 477}
473 478
474impl Config { 479impl Config {
@@ -703,6 +708,7 @@ impl Config {
703 repository_whitelist: String::new(), 708 repository_whitelist: String::new(),
704 repository_blacklist: String::new(), 709 repository_blacklist: String::new(),
705 event_blacklist: String::new(), 710 event_blacklist: String::new(),
711 max_connections: 500,
706 } 712 }
707 } 713 }
708} 714}