diff --git a/README.md b/README.md index f125158..0338ab9 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ NIPs with a relay-specific implementation are listed here. - [x] NIP-12: Generic tag search (_experimental_) - [x] NIP-15: End of stored events notice - [x] NIP-16: Replaceable and ephemeral events +- [x] NIP-22: Event `created_at` limits (_future-dated events only_) ## Quick Start diff --git a/config.toml b/config.toml index 1f36df7..94f8928 100644 --- a/config.toml +++ b/config.toml @@ -44,8 +44,8 @@ port = 8080 [options] # Reject events that have timestamps greater than this many seconds in -# the future. Defaults to rejecting anything greater than 30 minutes -# from the current time. +# the future. Recommended to reject anything greater than 30 minutes +# from the current time, but the default is to allow any date. reject_future_seconds = 1800 [limits] diff --git a/src/config.rs b/src/config.rs index 578cfd0..45c56af 100644 --- a/src/config.rs +++ b/src/config.rs @@ -219,7 +219,7 @@ impl Default for Settings { whitelist_addresses: None, // whitelisted addresses (never delete) }, options: Options { - reject_future_seconds: Some(30 * 60), // Reject events 30min in the future or greater + reject_future_seconds: None, // Reject events in the future if defined }, } } diff --git a/src/info.rs b/src/info.rs index 1af7f9e..d615cd4 100644 --- a/src/info.rs +++ b/src/info.rs @@ -35,7 +35,7 @@ impl From for RelayInfo { description: i.description, pubkey: i.pubkey, contact: i.contact, - supported_nips: Some(vec![1, 2, 11, 15, 16]), + supported_nips: Some(vec![1, 2, 11, 15, 16, 22]), software: Some("https://git.sr.ht/~gheartsfield/nostr-rs-relay".to_owned()), version: CARGO_PKG_VERSION.map(|x| x.to_owned()), } diff --git a/src/server.rs b/src/server.rs index 04fcbdf..c86b4c8 100644 --- a/src/server.rs +++ b/src/server.rs @@ -529,8 +529,9 @@ async fn nostr_server( client_published_event_count += 1; } else { info!("client {:?} sent a far future-dated event", cid); - ws_stream.send(make_notice_message("event was too far in the future")).await.ok(); - + if let Some(fut_sec) = settings.options.reject_future_seconds { + ws_stream.send(make_notice_message(&format!("The event created_at field is out of the acceptable range (+{}sec) for this relay and was not stored.",fut_sec))).await.ok(); + } } }, Err(_) => {