52 Commits

Author SHA1 Message Date
fiatjaf
c0848182c4
OverwriteResponseEvent for optionally modifying events before sending them to client. 2023-11-04 17:39:28 -03:00
fiatjaf
d19b8f8895
support icon url. 2023-11-02 21:24:19 -03:00
fiatjaf
bbe186494e
replace mutex-guarded maps with xsync/v2 maps. 2023-10-03 08:32:07 -03:00
fiatjaf
8968982b9a
relayer, second attempt, now much better. 2023-08-10 14:32:11 -03:00
fiatjaf
0a5624737d
pass AUTH information to functions via context. 2023-06-26 20:05:06 -03:00
fiatjaf
dc594ee32b
migrate to fasthttp/websocket. 2023-06-23 07:10:59 -03:00
fiatjaf
ebfff13b18 use envelopes everywhere. 2023-06-16 17:48:34 -03:00
Isaque Veras
ee84bf513f
feat(AddEvent): add pointer when adding event (#68) 2023-06-12 08:19:07 -03:00
Yasuhiro Matsumoto
f328910ab6 COUNT should not be subscribable 2023-05-18 09:37:14 -03:00
mattn
639c210661
support NIP-45 (#58) 2023-05-17 07:54:56 -03:00
bndw
54001282d9 fix: async save event
Uses a non-request-scoped context for async event handling operations.

Fixes #50
2023-05-03 17:13:42 -03:00
fiatjaf
4e15120111
migrate all built-in storage backends. 2023-05-01 19:41:17 -03:00
fiatjaf
e3d4655dba
v2 with breaking changes and a simpler API. 2023-05-01 19:21:09 -03:00
Steve Perkins
a82e5edb0d Adds NIP-33 support for replaceable events. 2023-03-31 11:36:54 -03:00
Gustavo Chain
9aeb352320 advertise nip11 on nip11 handler 2023-02-10 15:28:11 -03:00
Dylan Cant
d7750ad15f added comment 2023-01-19 17:56:28 -03:00
Dylan Cant
82e4174073 added filter handling to query.go and sort "created_by" descending 2023-01-19 17:56:28 -03:00
Dylan Cant
cab0654516 small fixes to NIP-42 parts of handlers.go
also removed "break" commands at ends of cases in switch
statement (these are unnecessary in `go`, cf https://go.dev/tour/flowcontrol/9)
2023-01-16 21:29:35 -05:00
Dylan Cant
cf3f94f4de Added an "OK" signal when authenticated (or not)
To interact with okCallback in go-nostr relay.go.
2023-01-16 01:24:35 -05:00
Dylan Cant
c573c465f0 fixed typos added docstring 2023-01-15 23:33:53 -05:00
fiatjaf
fe91197d45
implement nip-42 AUTH and restrict DMs to authed users. 2023-01-15 22:38:24 -03:00
0x0ff
8b3ff7ac26 fix: remove listeners when client disconnects 2022-12-29 13:59:19 -03:00
alex
627724f702 start: introduce Server type and Shutdown (breaking change)
the main motivation for this change is to be able to run tests.
before this commit, Start, Router and Log operated on global variables,
making automated testing unreasonably hard.

this commit puts all that a server needs in a new Server type,
which also made it possible for a Server.Shutdown - see ShutdownAware
doc comments.

BREAKING CHANGES:
- Relay.OnInitialized takes one argument now, *relayer.Server.
- relayer.Router is now replaced by relayer.Server.Router().
  package users can still hook into the router from OnInitialized
  for custom HTTP routing.
- relayer.Log is gone. apart from another global var, imho this was
  a too opinionated choice for a framework to build a custom relay upon.
  this commit introduces a Logger interface which package users can implement
  for zerolog to make it log like before. see Server.Log for details.

other notable changes: finally added a couple basic tests, for start up
and shutdown. doc comments now explain most of the essentials,
hopefully making it more approachable for newcomers and easier to understand
the relayer package.

the changes in handlers.go are minimal, although git diff goes crazy.
this is because most of the lines are simply shifted indentation back by one
due to go fmt.

before this commit:

    func handleWebsocket(relay Relay) func(http.ResponseWriter, *http.Request)
    func handleNIP11(relay Relay) func(http.ResponseWriter, *http.Request)

after:

    func (s *Server) handleWebsocket(w http.ResponseWriter, r *http.Request)
    func (s *Server) handleNIP11(w http.ResponseWriter, r *http.Request)
2022-12-24 20:41:02 -03:00
fiatjaf
3b7800692f
better and less logs for websocket abnormal closures. 2022-12-19 14:47:57 -03:00
fiatjaf
d69479974c
expose AddEvent() method, allow implementations to deal with unknown websocket messages, remove opinionated validations from core lib, implement NIP-20 ("OK" message). 2022-11-11 09:48:11 -03:00
fiatjaf
b903f72945
never store ephemeral events. 2022-11-03 14:33:18 -03:00
fiatjaf
13d57303b5 support "limit" field on filters. 2022-07-24 19:58:34 -03:00
fiatjaf
aa96fa0a21 refactor framework interface, simplify basic and whitelisted, bring expensive on and rewrite it. 2022-07-24 17:41:00 -03:00
fiatjaf
4daac2fc28 implement nip-09, event deletion. 2022-07-24 11:35:49 -03:00
fiatjaf
8cc12a6bd9 implement nip-11, relay information document. 2022-07-24 11:35:49 -03:00
fiatjaf
809f8030db implement nip-15, EOSE. 2022-07-24 11:35:49 -03:00
fiatjaf
f9d058a95a adapt to updated go-nostr. 2022-02-13 08:40:06 -03:00
fiatjaf
ea7d2eeb3e guard all websocket writes with mutexes. 2022-01-11 16:00:19 -03:00
fiatjaf
629c9174eb update go-nostr. 2022-01-02 09:00:14 -03:00
fiatjaf
e7286f0658 fix "error writing ping" warnings. 2021-12-27 11:17:15 -03:00
fiatjaf
a63b805898 fix and improve error handling and notice sending flow. 2021-12-27 11:14:29 -03:00
fiatjaf
30eae726c1 turn relayer into a server framework and put actual relay code into ./basic 2021-12-25 21:22:40 -03:00
fiatjaf
ac93e5c028 make subscription ids unique per each websocket connection.
before they were globally unique, which was wrong.
2021-12-16 21:01:00 -03:00
fiatjaf
0265be6d31 upgrade to go-nostr v0.2.0. 2021-12-16 20:54:57 -03:00
fiatjaf
333d530901 don't send NOTICE on json parsing errors. 2021-11-28 17:01:17 -03:00
fiatjaf
6359ad8776 ensure deletion of old stuff such that we don't have a huge database. 2021-11-08 18:15:27 -03:00
fiatjaf
694eccd0c8 small fixes and guards. 2021-02-23 00:27:16 -03:00
Richard Bondi
36cd95a58e wrong index 2021-02-20 19:04:22 -03:00
fiatjaf
bc860ff28b one extra bit of logging. 2021-02-20 19:04:17 -03:00
fiatjaf
db384be3f9 fix some query bugs. 2021-02-17 16:59:56 -03:00
fiatjaf
9c992c90dc adapt to new nip-01. 2021-02-14 21:08:02 -03:00
fiatjaf
80d244b2c3 remove rate limiter, this is just a proof-of-concept anyway. 2021-02-07 14:28:06 -03:00
Richard Bondi
3dacb07b62 delete metadata, not notes 2021-01-22 00:46:21 -03:00
fiatjaf
029049e587 remove writedeadline for writing ping. 2021-01-19 17:37:36 -03:00
Richard Bondi
e58f5cbc84 fix body for calling request 2021-01-16 21:38:02 -03:00