Commit Graph

297 Commits

Author SHA1 Message Date
Daniele Tonon
b7ec430166 Fix GetImmediateReply
When scanning an event with positional "e" tags the reply is the last one
v0.18.8
2023-05-31 12:35:48 -03:00
fiatjaf
9cafea7e2a ensure relay context and subscriptions are closed when we lose connectivity. v0.18.7 2023-05-30 17:44:25 -03:00
fiatjaf
19d96e3566 close SubMany channel when all underlying subscriptions die. 2023-05-30 16:11:33 -03:00
fiatjaf
a2941876e3 expose subscriptions from relay and keep that updated. v0.18.6 2023-05-30 14:55:44 -03:00
fiatjaf
0f7a3f01f2 use an atomic counter. 2023-05-30 14:01:07 -03:00
fiatjaf
39f09e6bb9 replace generic-sync-map with xsync. 2023-05-30 13:52:14 -03:00
fiatjaf
ad0f73fa9c ensure subscription dies if the relay connection dies. 2023-05-30 13:47:47 -03:00
fiatjaf
5cead32fbe remove extra subscription after publishing an event to check if it is there.
just assume all relays will return OK.
2023-05-30 13:45:45 -03:00
fiatjaf
1cd2c0293d add a bunch more of event kinds. 2023-05-28 15:46:41 -03:00
fiatjaf
b269dd9ce9 sdk: return start and end on references for replacement. v0.18.5 2023-05-26 19:22:59 -03:00
Daniele Tonon
5c0f8bff83 Add fields to ProfileMetadata v0.18.4 2023-05-25 08:23:12 -03:00
starcorn2020
123d3a6a9a Add error capture to authentication status in relay.Auth 2023-05-14 10:23:35 -03:00
fiatjaf
fa00133825 websocket to send text, not binary. v0.18.3 2023-05-11 10:09:43 -03:00
fiatjaf
0c06788672 oops: stop replacing connectionContext with Connect(ctx). v0.18.2 2023-05-10 09:09:49 -03:00
fiatjaf
9dc674bc02 use different contexts for the relay connection lifetime and the Connect() call.
fixes https://github.com/nbd-wtf/go-nostr/pull/86
v0.18.1
2023-05-09 17:08:08 -03:00
fiatjaf
ccbb44989f get rid of WriteJSON() and replace calls with manually marshaled envelopes. 2023-05-09 17:02:22 -03:00
fiatjaf
d36fbb95b9 ParseMessage() returns an Envelope, use that on the main relay handler loop. 2023-05-09 16:55:21 -03:00
fiatjaf
f7ce78d7f8 add custom envelope types with json codecs. 2023-05-09 16:31:10 -03:00
fiatjaf
52a493fd96 EnsureRelay() returns an error. 2023-05-09 00:09:05 -03:00
shota3506
6c186812c9 fix readme code example 2023-05-07 06:21:25 -03:00
shota3506
96f3d4c9a0 fix event comparison in EventSerialization test 2023-05-07 06:21:12 -03:00
fiatjaf
c0a42ff2ff SimplePool improvements. 2023-05-06 14:32:39 -03:00
fiatjaf_
2b2c000d6a Merge pull request #81 from wozuo/master v0.18.0 2023-05-05 21:06:07 -03:00
Marc Tarnutzer
69b9d82bb1 check if messages are compressed on receive 2023-05-06 01:48:01 +02:00
fiatjaf
98a2a39521 add SimplePool. 2023-05-05 19:05:11 -03:00
Marc Tarnutzer
c86e907142 enable compression by default 2023-05-05 22:00:25 +02:00
Marc Tarnutzer
ee9502bc3e fix: outgoing pings 2023-05-05 12:14:29 +02:00
Marc Tarnutzer
f152a5e0c7 simplify connection close 2023-05-04 23:54:39 +02:00
Marc Tarnutzer
9c01ead91f switch to gobwas/ws, add compression 2023-05-04 23:51:15 +02:00
fiatjaf
1c118cd83e take context.Context for nip-05 resolving. 2023-05-04 13:20:15 -03:00
fiatjaf
53e0935308 parse kind in nevent. v0.17.3 v0.17.2 2023-05-04 08:24:39 -03:00
fiatjaf
6fc1627fcc json tags on pointers. 2023-05-04 08:24:26 -03:00
fiatjaf
32ca737acf remove unused ping handler (it is done automatically).
fixes https://github.com/nbd-wtf/go-nostr/pull/74, thanks @patdz
v0.17.1
2023-04-26 08:12:50 -03:00
Patrick Bennett
ebae5d41e6 Add most NIP-11 extension structures to the RelayInformationDocument struct. (#80)
* Fix race condition on status in Relay.Publish method and failure to send

A race-condition exists between setting of the (unprotected) status and the callback which sets the status upon receiving an OK.
The message is sent which can receive an OK in separate goroutine (setting status) prior to the status being set to 'sent.'
The OK can be received prior to the status being set.

This fix also sets the status to PublishStatusFailed if the WriteJSON call fails.

* Add some NIP-11 extension structures to the RelayInformationDocument struct.

Added additional NIP-11 fields for relays that want to provide additional details based on NIP-11 extensions.
The retention structure has been left out as it doesn't have a clean schema for kinds (array of kinds, or pairs of kinds?)
Specified the fields w/ omitempty so marshaled will be same as original NIP-11 if nothing else is specified.
Nested structs defined as pointers so they are omitted if not specified.

* Fix TestPublishWriteFailed so that the socket is given a brief amount of time to close prior to publish being called.
The test relies on Publish always failing.
2023-04-26 08:06:05 -03:00
fiatjaf
3838ed7e91 guard ping writes with the mutex.
fixes https://github.com/nbd-wtf/go-nostr/issues/76#issuecomment-1521170395
2023-04-26 08:04:51 -03:00
Patrick Bennett
b077a41f83 Fix race condition on status in Relay.Publish method and failure to send
A race-condition exists between setting of the (unprotected) status and the callback which sets the status upon receiving an OK.
The message is sent which can receive an OK in separate goroutine (setting status) prior to the status being set to 'sent.'
The OK can be received prior to the status being set.

This fix also sets the status to PublishStatusFailed if the WriteJSON call fails.
2023-04-21 07:48:08 -03:00
fiatjaf
9b89a49e5e cancel relay context when calling .Close().
fixing https://github.com/nbd-wtf/go-nostr/issues/76#issuecomment-1517251898
2023-04-21 07:45:28 -03:00
fiatjaf
3785daf8aa normalize relay url from Tag.Relay(). v0.17.0 2023-04-19 14:40:44 -03:00
fiatjaf
fc7b20114b update readme and example. 2023-04-16 16:25:25 -03:00
fiatjaf
2695854e56 fixing json filter json + marshaling filter tags. 2023-04-16 16:22:32 -03:00
fiatjaf
c42059f4b4 tests run (but not pass) and fine-tuning (specially tag filters) on filter_easyjson.go 2023-04-16 16:16:16 -03:00
fiatjaf
0a3e898c2f using easyjson. 2023-04-16 15:56:50 -03:00
fiatjaf
af52f8d490 debug log events received. v0.16.12 2023-04-14 10:07:10 -03:00
fiatjaf
326d2790de rename interface{} to any. v0.16.11 2023-04-12 12:14:24 -03:00
fiatjaf
ec3f1287c4 debug log CLOSE messages. 2023-04-12 12:14:16 -03:00
fiatjaf
2314db57a1 tweak timeouts on Publish() v0.16.10 2023-04-11 15:33:29 -03:00
fiatjaf
dd692560ff fill in event pubkey when signing. 2023-04-11 15:33:13 -03:00
fiatjaf
32768b1a5b improve debug logging, fix stringer interface, debuglog events sent, fix debuglogging affecting the actual values. v0.16.9 2023-04-11 11:02:35 -03:00
fiatjaf
7f64f2f65e improve logic for subscribing to just-published events. v0.16.8 2023-04-11 10:38:30 -03:00
fiatjaf
df7abe72fa fix: return PublishStatusFailed if connection can't be established etc. 2023-04-11 09:52:01 -03:00