74 Commits

Author SHA1 Message Date
fiatjaf
5823515d27
streamlined connection closes on failure.
account for the fact that the time.Ticker channel is
not closed when the ticker is stopped.
2023-12-09 00:00:22 -03:00
fiatjaf
9273a4b809
use a special context for each REQ stored-events handler that can be canceled. 2023-12-08 23:48:30 -03:00
fiatjaf
ddfc9ab64a
fun with connection contexts and context cancelations. 2023-12-08 22:51:00 -03:00
fiatjaf
375236cfe2
fix sign on error checking. 2023-12-06 21:32:48 -03:00
fiatjaf
35e801379a
make NIP-42 actually work, with inferred ServiceURL if that's not manually set. 2023-12-06 15:03:53 -03:00
fiatjaf
22da06b629
new flow for auth based on "auth-required: " rejection messages. 2023-12-06 12:14:58 -03:00
fiatjaf
ad92d0b051
return CLOSED if any of the filters get rejected. 2023-12-06 11:56:56 -03:00
fiatjaf
3c1b062eb8
include original http.Request in WebSocket struct. 2023-11-29 12:26:04 -03:00
fiatjaf
84d01dc1d3
rename auth-related fields on WebSocket struct. 2023-11-29 12:23:21 -03:00
fiatjaf
386a89676a
use go-nostr envelopes and support CLOSED when filters are rejected. 2023-11-28 22:43:06 -03:00
fiatjaf
90697ad3d3
OverwriteRelayInformation 2023-11-27 00:54:45 -03:00
fiatjaf
d608c67791
store websocket object under WS_KEY at the connection context. 2023-11-23 19:36:46 -03:00
fiatjaf
7a221cf9f0
add missing return when checking id. 2023-11-22 17:30:34 -03:00
fiatjaf
2edf754907
cors. 2023-11-20 09:07:52 -03:00
fiatjaf
18e4904a00
check id before signature and do not allow invalid ids. 2023-11-19 16:40:29 -03:00
fiatjaf
591b49fe73
do not log on normal websocket close. 2023-11-19 08:30:06 -03:00
fiatjaf
8fd6436ac8
rework nip11 support to be more transparent. 2023-11-18 10:35:08 -03:00
fiatjaf
d2544d0f4d
stop uselessly returning NIPs that are obviously supported on NIP-11 response. 2023-11-18 08:03:32 -03:00
fiatjaf
4905a46ccd
make filter rejection actually work and move logic to a separate file. 2023-11-11 21:08:39 -03:00
fiatjaf
78dd138ca8
fix content-type for nip-11. 2023-11-09 21:39:28 -03:00
fiatjaf
6c1a030ad2
get rid of useless error for closing connection on ping. 2023-11-07 22:55:24 -03:00
fiatjaf
b277dae743
fix RejectFilters application, support overwriting filters and add some filter plugin helpers. 2023-11-07 16:08:56 -03:00
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