Commit Graph

213 Commits

Author SHA1 Message Date
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
fiatjaf
6f74d284c4 improved logging thing with the "debug" build tag. v0.16.6 2023-04-11 09:35:37 -03:00
fiatjaf
7b0af23f1a implement Stringer for Event. 2023-04-11 07:36:59 -03:00
fiatjaf
4507477486 slight improvements to debug logging. 2023-04-11 07:10:05 -03:00
fiatjaf
e103c99bb8 a pluggable logging interface and more debug logging. v0.16.2 2023-04-11 00:32:32 -03:00
fiatjaf
f918809e21 add subscription test using the damus relay. 2023-04-07 12:52:10 -03:00
fiatjaf
a666994ae7 fix test that was broken when the context passed to RelayConnect() became the relay context for its full timeline.
30e0e1040a
v0.16.0
2023-04-06 16:22:24 -03:00
fiatjaf
ef428ff39f Subscription.Fire() can error, so Relay.Subscribe() must also. 2023-04-06 16:21:25 -03:00
fiatjaf
4c9db5928a log relay url too when filter doesn't match. 2023-04-06 12:57:15 -03:00
fiatjaf
abfb7de394 add a mutex lock around Challenges and Notices channel. v0.15.4 2023-03-31 22:09:01 -03:00
fiatjaf
411718f3c1 reformat nip04 errors. 2023-03-31 09:30:33 -03:00
fiatjaf
30e0e1040a use context passed to .Connect() for the live of the relay. 2023-03-30 18:26:43 -03:00
fiatjaf
e84a7936d5 fix some concurrency things. v0.15.3 2023-03-29 14:55:52 -03:00
fiatjaf
b0031bfd86 sdk.ParseReferences() v0.15.2 2023-03-27 08:47:59 -03:00
fiatjaf
d3a1624880 ping every 29 seconds.
fixes https://github.com/nbd-wtf/go-nostr/issues/72
2023-03-25 14:59:38 -03:00
fiatjaf
35875e6071 replace vendored bech32 code with btcd library. 2023-03-23 16:59:46 -03:00
fiatjaf
3f3bbb7529 ensure nip05 results are valid keys or nil. v0.15.1 2023-03-23 08:09:49 -03:00
fiatjaf
4b1f69ec27 subscriptions receive their context on Prepare(). v0.15.0 2023-03-21 14:50:34 -03:00
fiatjaf
46e724b8d5 dry sub.unsub() on context cancelation. v0.14.1 2023-03-18 16:07:19 -03:00
fiatjaf
e9ad77c822 asynchronous event parsing on received. 2023-03-18 15:09:58 -03:00
fiatjaf
85fc74fd22 fixing subscription labels and ids. 2023-03-18 15:09:49 -03:00
fiatjaf
3f66c60b5f subscription labels: GetID() and SetLabel(). v0.14.0 2023-03-18 08:40:12 -03:00
fiatjaf
661e299981 one live random filter test. 2023-03-18 08:18:08 -03:00
fiatjaf
fdc99d61b6 subscription ids as sequential numbers and sub.GetID() 2023-03-17 16:43:48 -03:00
fiatjaf
cef5892bce return status from publish when relay loses connectivity. 2023-03-17 16:21:04 -03:00
fiatjaf
332ae1ff7f support author on nevent. 2023-03-17 09:09:36 -03:00
fiatjaf
c982ad0ab1 guard against closed channels in subscriptions. 2023-03-16 15:53:24 -03:00
fiatjaf
ec34d4eb10 return error message from Publish() 2023-03-16 14:27:33 -03:00
fiatjaf
0765f7b91b context cancelation for relay connections and subscriptions. 2023-03-16 14:16:46 -03:00
fiatjaf
5e24b24442 improve relay URL normalization. 2023-03-14 21:56:40 -03:00
fiatjaf
7803cc74b3 a function to check if a public key hex is a public key hex. 2023-03-14 21:56:40 -03:00
fiatjaf
02759120ea Relay.AssumeValid 2023-03-14 17:07:32 -03:00
cj-ibex
483f40a596 add nip57 constants 2023-03-11 14:20:31 -03:00
fiatjaf
7be5330d42 improve nip10.GetImmediateReply() 2023-03-04 21:04:59 -03:00
fiatjaf
392013fa25 sdk package with higher-level functions. 2023-02-27 16:45:45 -03:00