upleb.uk

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

summaryrefslogtreecommitdiff
path: root/nix
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 /nix
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 'nix')
-rw-r--r--nix/module.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/nix/module.nix b/nix/module.nix
index 09c56c1..4117b6d 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -250,6 +250,12 @@ let
250 ''; 250 '';
251 }; 251 };
252 252
253 maxConnections = mkOption {
254 type = types.int;
255 default = 500;
256 description = "Maximum total connections to the relay";
257 };
258
253 user = mkOption { 259 user = mkOption {
254 type = types.str; 260 type = types.str;
255 default = "ngit-grasp-${name}"; 261 default = "ngit-grasp-${name}";
@@ -295,6 +301,7 @@ let
295 NGIT_REPOSITORY_WHITELIST = concatStringsSep "," cfg.repositoryWhitelist; 301 NGIT_REPOSITORY_WHITELIST = concatStringsSep "," cfg.repositoryWhitelist;
296 NGIT_REPOSITORY_BLACKLIST = concatStringsSep "," cfg.repositoryBlacklist; 302 NGIT_REPOSITORY_BLACKLIST = concatStringsSep "," cfg.repositoryBlacklist;
297 NGIT_EVENT_BLACKLIST = concatStringsSep "," cfg.eventBlacklist; 303 NGIT_EVENT_BLACKLIST = concatStringsSep "," cfg.eventBlacklist;
304 NGIT_MAX_CONNECTIONS = toString cfg.maxConnections;
298 RUST_LOG = cfg.logLevel; 305 RUST_LOG = cfg.logLevel;
299 } // optionalAttrs (cfg.relayName != null) { 306 } // optionalAttrs (cfg.relayName != null) {
300 NGIT_RELAY_NAME = cfg.relayName; 307 NGIT_RELAY_NAME = cfg.relayName;