Commit Graph

32 Commits

Author SHA1 Message Date
fiatjaf 4b2cec9c6d proper relay pinging disconnection.
from https://github.com/nbd-wtf/go-nostr/pull/200
2025-11-13 16:37:09 -03:00
fiatjaf c20ca669cd nip77: more interface fixes to prevent channel deadlock. 2025-11-13 16:12:10 -03:00
fiatjaf c2ab9d082c *connection to be an integral part of *Relay. 2025-11-12 09:47:26 -03:00
fiatjaf 69c0981b51 address closeMutex deadlock by canceling the relay connection context on doClose(). 2025-08-23 10:08:45 -03:00
fiatjaf 31a590ee4f fix sending on close channel with yet another mutex. 2025-08-23 09:16:12 -03:00
fiatjaf 6592319774 stop exposing connection, more debugLog calls and properly fail subscriptions when a relay dies. 2025-07-13 14:21:15 -03:00
fiatjaf 9f8b810882 fix main relay context being canceled instead of just the dial context. 2025-07-11 13:01:04 -03:00
fiatjaf 7289da9c72 improve/refactor websocket connections hoping this will fix the undetected disconnections we're seeing.
this commit also remove all the sonic envelope parsing and reintroduces filters in REQ as a slice instead of as a singleton.

why? well, the sonic stuff wasn't really that fast, it was a little bit but only got fast enough once I introduced unsafe conversions between []byte and string and did weird unsafe reuse of []byte in order to save the values of tags, which would definitely cause issues in the future if the caller wasn't aware of it (and even if they were, like myself).

and the filters stuff is because we abandoned the idea of changing NIP-01 to only accept one filter per REQ.
2025-07-10 22:58:37 -03:00
fiatjaf 15c6093c9b define a nostr.Kind type for event kinds, make adjustments everywhere and fix some horrible bugs with mmm, lmdb and badger querying and deleting. 2025-04-20 11:15:41 -03:00
fiatjaf 5bfaed2740 docstrings for many functions. 2025-03-04 11:42:44 -03:00
fiatjaf 1f36d7a9f1 increase websocket message limit to an absurd of 33MB. 2025-02-12 15:42:00 -03:00
fiatjaf 3e1c0ddc7e fix pinging relays: use the main relay context, not the relay connection temporary context. 2025-01-17 14:08:54 -03:00
fiatjaf 06a15fdaab follow list fetching test and related changes and fixes.
- make BatchedSubManyEose() use a single duplicate id index and use it for replaceable loaders;
- fixes parsing follow entry from kind:3 events (and others);
- adds a "cause" to most cancelation errors in relay/pool;
- remove the inherent cache from dataloader (we have our own hopefully);
- increase max frame size we can read from any websocket to 2**18 (262k), which gives over 2000 item lists.
2025-01-17 13:44:51 -03:00
fiatjaf defc349e57 use coder/websocket for everything, get rid of gobwas.
supposedly it is faster, and anyway it's better to use it since we're already using it for wasm/js.

(previously named nhooyr/websocket).
2025-01-03 01:15:17 -03:00
reis 63919cf685 support wasm (#163) 2025-01-02 09:42:04 -03:00
fiatjaf a35cdff6c8 problem: connection can be nil when writing and we're panic'ing. 2024-06-21 09:32:53 -03:00
ice-cronus c0f1c4f510 add option to connect with custom TLS 2024-03-28 15:54:12 -03:00
Yasuhiro Matsumoto d6baa2f74c separate msgState for reader/writer 2023-11-06 13:29:19 -03:00
fiatjaf 35faff858a reuse buffer when reading messages from websocket. 2023-07-30 17:12:30 -03:00
fiatjaf 030c1d1898 get rid of mutexes and use a single loop to prevent races.
in the meantime change the API to makes a little less error-prone.
2023-06-21 19:55:43 -03:00
Isaque Veras 58d56abe05 fix: removing redundancy 2023-06-12 08:18:29 -03:00
fiatjaf fa00133825 websocket to send text, not binary. 2023-05-11 10:09:43 -03:00
fiatjaf ccbb44989f get rid of WriteJSON() and replace calls with manually marshaled envelopes. 2023-05-09 17:02:22 -03:00
Marc Tarnutzer 69b9d82bb1 check if messages are compressed on receive 2023-05-06 01:48:01 +02: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 326d2790de rename interface{} to any. 2023-04-12 12:14:24 -03:00
fiatjaf 329b8d44d2 move stuff back from nostr package to top level.
because otherwise the path must be specified as github.com/fiatjaf/go-nostr/nostr, which is annoying.
2022-11-04 08:22:13 -03:00
BitcoinCoderBob 9549c3624a nostr package, readme updates accordingly, matching example program (#14) 2022-10-12 17:24:30 -03:00
Honza Pokorny a3df2cb893 Add mutexes around websockets
We replace the bare websocket.Conn type with a new Connection type which
implements `WriteJSON`, `WriteMessage`, and `Close`.  The Connection
type adds mutexes around writes since gorilla doesn't support concurrent
writes to websockets.

Signed-off-by: Honza Pokorny <honza@pokorny.ca>
2022-01-12 12:19:33 -03:00