Commit Graph

19 Commits

Author SHA1 Message Date
Greg Heartsfield
234a8ba0ac feat: limit event publishing to NIP-05 verified users
This adds a new configurable feature to restrict event publishing to
only users with NIP-05 verified metadata.  Domains can be whitelisted
or blacklisted.  Verification expiration and schedules are
configurable.

This upgrades the database to add a table for tracking verification
records.
2022-02-12 09:29:25 -06:00
Greg Heartsfield
6502f7dcd7 fix: do not panic when validating events with malformed pubkeys 2022-01-29 13:19:34 -06:00
Greg Heartsfield
af453548ee feat: allow author and event id prefix search
This is an experimental non-NIP feature that allows a subscription
filter to include a prefix for authors and events.
2022-01-25 18:23:08 -06:00
Greg Heartsfield
2d28a95ff7 feat: allow arbitrary tag queries
This is an experimental feature, outside of any NIP, that demonstrates
generic tag queries.

Instead of limiting subscription filters to just querying only "e" or
"p" tags (via `#e` or `#p` attributes), any tag can be queried.

As an example, consider an event which uses a tag "url".  With this
modification, a subscription filter could add a top-level field
"#url", with an array of strings as the key.  Exact matches would be
returned.

A NIP is forthcoming to formalize this.
2022-01-22 21:29:15 -06:00
Raj
5c8390bbe0
fix: fix some test failures 2022-01-14 14:27:12 -06:00
Greg Heartsfield
7037555516 improvement: add indexed tag queries 2022-01-05 17:33:53 -05:00
Greg Heartsfield
1aa5a5458d improvement: event signature validation is 100x faster
Switched to latest (git) release of secp256k1, which has more
efficient verification-only context for Schnorr.  Switched to single
pre-instantiated instance of the verifier.
2022-01-01 09:08:19 -06:00
Greg Heartsfield
6447ddd974 fix: compile error with missing import 2021-12-30 10:00:34 -06:00
Greg Heartsfield
079722ddd9 improvement: reduce logging level for rejected events 2021-12-30 06:35:36 -06:00
Greg Heartsfield
3302fb2e81 refactor: clippy suggestions 2021-12-29 22:49:46 -06:00
Greg Heartsfield
f415295184 feat: reject future-dated events
If configured, reject events than are more than N seconds in the
future.

Fixes https://todo.sr.ht/~gheartsfield/nostr-rs-relay/5
2021-12-29 22:47:31 -06:00
Greg Heartsfield
49598b2c9e fix: subscription event filtering bugs
Subscriptions properly filter using the authors tag.  Petname/keys are
correctly filtered (previously the event tags were incorrectly used).
2021-12-14 21:38:26 -06:00
Greg Heartsfield
e732f918f9 refactor: clippy suggestions 2021-12-11 21:56:52 -06:00
Greg Heartsfield
ca0f01c94b docs: add rustdoc comments 2021-12-11 21:43:41 -06:00
Greg Heartsfield
65969a4121 feat: store events in SQLite and allow querying
Events are persisted in a local database, and can be queried through
subscriptions.
2021-12-11 15:48:59 -06:00
Greg Heartsfield
23f47899cd feat: broadcast events that match active client subscriptions
A broadcast channel sends messages to all connections.  Any connection
with a subscription that matches then sends it via websocket.
2021-12-05 20:28:02 -06:00
Greg Heartsfield
8b4c43ae71 feat: add and remove subscriptions from client requests
A hashmap of active subscriptions is maintained for each client.  REQ
and CLOSE commands will modify the subscription list.
2021-12-05 18:14:14 -06:00
Greg Heartsfield
e7d0ab1aca feat: parse subscriptions from websockets
Parses subscription requests (REQ, but not CLOSE).  Performs no
subscription state management yet.
2021-12-05 17:15:50 -06:00
Greg Heartsfield
92e9a5e639 feat: parse and validate events from websockets
Establishes a websocket listener, parses events, and performs
validation to ensure valid signatures.
2021-12-05 16:53:26 -06:00