246 Commits

Author SHA1 Message Date
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
fiatjaf
42fee9cb1d update go-nostr. 2022-05-02 16:55:23 -03:00
fiatjaf
d25ace94ac support prefix search and change indexes. 2022-02-14 14:04:25 -03:00
fiatjaf
e50a298496 update go-nostr for a fix. 2022-02-13 20:37:51 -03:00
fiatjaf
fa0079c020 fix sql scanning without sqlx magic. 2022-02-13 10:15:39 -03:00
fiatjaf
638b9262ec wait, we don't need to check if date is recent or anything, just if it is not nil. 2022-02-13 08:42:09 -03:00
fiatjaf
f9d058a95a adapt to updated go-nostr. 2022-02-13 08:40:06 -03:00
fiatjaf
a7710ef4f3 fix basic logs. 2022-02-11 20:10:25 -03:00
fiatjaf
ea7d2eeb3e guard all websocket writes with mutexes. 2022-01-11 16:00:19 -03:00
fiatjaf
ed829ac5f8 fix query fields returned. 2022-01-02 18:32:55 -03:00
Saul
b0467795cd Add Docker instructions 2022-01-02 17:31:09 -03:00
fiatjaf
85e5644e2f add some readmes. 2022-01-02 17:30:35 -03:00
fiatjaf
8091dfedbe use generated columns and gin array indexes to query tags better. 2022-01-02 17:19:24 -03:00
fiatjaf
ae3f5df0b9 log query on sql error. 2022-01-02 11:01:05 -03:00
fiatjaf
3e20e6c7cc renaming Equal -> FilterEqual 2022-01-02 09:08:05 -03:00
fiatjaf
629c9174eb update go-nostr. 2022-01-02 09:00:14 -03:00
fiatjaf
f86eb9246b limit against abusive queries. 2022-01-01 21:38:54 -03:00
fiatjaf
9a455b8db6 update go-nostr with new nip-01 slices of everything. 2022-01-01 21:36:56 -03:00
fiatjaf
61f21dd3a6 basic: fix kind filtering (0 != nil). 2022-01-01 10:24:55 -03:00