214 Commits

Author SHA1 Message Date
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
Liran Cohen
0442b02394 fix postgres delete event query 2023-01-18 18:33:06 -03:00
fiatjaf
e270b56314
Merge pull request #26 from barkyq/master
Small fixes to NIP-42 parts of handlers.go
2023-01-17 08:08:46 -03:00
Dylan Cant
23965269a1 Merge remote-tracking branch 'origin/master' 2023-01-16 21:32:28 -05: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
38d0f481c1 Added an "OK" signal when authenticated (or not)
To interact with okCallback in go-nostr relay.go.
2023-01-16 08:26:41 -03:00
Dylan Cant
c05896a2e3 fixed typos added docstring 2023-01-16 08:26:41 -03: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
fiatjaf
e70a5601c7
update go-nostr and fix rss-bridge. 2023-01-02 14:31:28 -03:00
0x0ff
9ba958e9a0 set SetMaxOpenConns, close rows when QueryEvents finishes 2022-12-30 15:28:43 -03:00
0x0ff
8b3ff7ac26 fix: remove listeners when client disconnects 2022-12-29 13:59:19 -03:00
0x0ff
9ba4326085 fix: pass unix timestamp to DB.Exec instead of Time 2022-12-29 13:57:49 -03:00
0x0ff
af890590f3 fix: QueryEvents should skip ids that are not a valid 32 byte hex 2022-12-28 09:17:33 -03:00
0x0ff
f2ab8020a8 handle event responses as per NIP-20 2022-12-27 16:44:57 -03:00
Saul Freeberty
05e8f03d43 move timestamp variable under condition 2022-12-26 19:53:00 -03:00
Saul Freeberty
8fd148bbb5 remove expired invoice, and fix display unexpired invoice 2022-12-26 19:53:00 -03:00
Saul Freeberty
bacf19b88d remove empty space 2022-12-25 20:54:49 -03:00
Saul Freeberty
3c953e4ae8 fix expensive relay invoice handler 2022-12-25 20:54:49 -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
alex
932a9b62a7
start: make http server's listening host/port compatible with IPv6 (#14)
previously, a command like this to listen on IPv6 loopback:

    HOST=::1 PORT=7447 go run ./basic/

would exit immediately because ::1:7447 is an invalid address.

IPv6 addresses contain columns, so a simple host + port concatenation
doesn't work. net.JoinHostPort is a function to do exactly that.
2022-12-24 18:53:05 -03:00
alex
642710fda8 start: propagate init errors
package users can now act accordingly on startup errors, for example
by exiting with a non-zero code. this is useful when running a service,
notifying a supervising process about such failures.

although this is technically a breaking change, most pkg users should be
unaffected since Start and StartConf returned nothing before this commit.
2022-12-24 18:52:06 -03:00
alex
570912e752 start: introduce function-args as alternative to env variable params
the Start function always assumes there are environment variables such
as HOST and PORT on start up. this is not always desirable and
especially makes it hard to run independent tests concurrently.

this commit introduces StartConf, an alternative to Start where the
same settings like host and port are passed in a function argument
instead of the global process environment.
2022-12-22 09:23:05 -03:00
Wes van der Vleuten
e03d2a56f5 Fixed whitelisted example 2022-12-21 22:46:59 -03:00
fiatjaf
3b7800692f
better and less logs for websocket abnormal closures. 2022-12-19 14:47:57 -03:00
fiatjaf
9684033223
update go-nostr dependency and tag release. 2022-12-19 09:31:49 -03:00
fiatjaf
4b2fc819a1
fix expensive html bolt11 printing. 2022-12-15 21:35:40 -03:00
fiatjaf
5f8908e028
update go-nostr dependency. 2022-11-26 09:27:08 -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
d7aba0b21f
fix some dependencies and storage instantiation on example relays. 2022-11-11 09:46:18 -03:00
fiatjaf
b903f72945
never store ephemeral events. 2022-11-03 14:33:18 -03:00
0x0ff
13a0c45fff fix: postgresql tags_to_tagvalues func definition 2022-10-15 17:54:55 -03:00
0x0ff
ec4cd51ebd fix: build failing 2022-10-09 11:43:07 -03:00
fiatjaf
eee9952fac base58 bad-coding session. 2022-08-12 17:02:40 -03:00
fiatjaf
396ca4d3a0 use updated lnsocket library. 2022-07-25 15:03:37 -03:00
fiatjaf
dd1093676f github action to build all the things. 2022-07-24 20:17:31 -03:00
fiatjaf
13d57303b5 support "limit" field on filters. 2022-07-24 19:58:34 -03:00
fiatjaf
fbb81c868c bring in and refactor rss bridge. 2022-07-24 19:52:25 -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
84f7d34840 rename closed to whitelisted and build it and basic with musl. 2022-07-24 11:53:30 -03:00
fiatjaf
d2ce4dbf54 implement nip-16 on closed and basic relays. 2022-07-24 11:48:34 -03:00
fiatjaf
ca1d1ce58f update basic and closed. 2022-07-24 11:35:49 -03:00
fiatjaf
440a64ef28 update go-nostr. 2022-07-24 11:35:49 -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
f383a0c71f remove deploy script. 2022-07-24 11:35:49 -03:00
fiatjaf
c075684e65 add closedrelay: like basic, but only allows authorized pubkeys to post. 2022-07-24 11:35:49 -03:00