272 Commits

Author SHA1 Message Date
Yonle
2a9abe64ea bouncer: send CLOSED to client as per recent NIP-01
From https://github.com/nostr-protocol/nips/blob/master/01.md#from-relay-to-client-sending-events-and-notices
> ["CLOSED", <subscription_id>, <message>], used to indicate that a subscription was ended on the server side.
> CLOSED messages MUST be sent in response to a REQ when the relay refuses to fulfill it. It can also be sent when a relay decides to kill a subscription on its side before a client has disconnected or sent a CLOSE.

Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-04 12:26:48 +07:00
Yonle
91637c13f9 g r a m m a r
Signed-off-by: Yonle <yonle@lecturify.net>
2.0.2
2024-01-03 23:54:44 +07:00
Yonle
29cb8ab5ed properly clear orphaned session.
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 22:51:16 +07:00
Yonle
53cf7a1562 fixbug
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 22:30:05 +07:00
Yonle
ca5f9f7a8e bouncer: count on orphans
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 21:51:15 +07:00
Yonle
403c51c9ee Release: 2.0.2
Fast connect and disconnecting is brutal sometime.

What's new?
===========
- An whitelist to only allow some event authors to be published with
  this bouncer.
- Orphan sockets feature to make stuff fast & not so easy to abuse,
  therefore reducing the amount of reconnects.

New Contributors
================
- Takuro Fukuda https://github.com/ftkro

Full Changelog: https://github.com/Yonle/bostr/compare/2.0.1...2.0.2

Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 17:32:10 +07:00
Yonle
80d87626fd defaultconf: enable orphan session by default
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 17:24:53 +07:00
Yonle
26462d16df orphan sess: admin sess must destroyed
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 17:15:41 +07:00
Yonle
7d0583791f fix another potential memory leak
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 17:13:07 +07:00
Yonle
d81cc497f8 fixbug 2024-01-03 16:52:32 +07:00
Yonle
a404e79104 probably an fix for orphan sockets & fix potential memory leak
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 16:51:23 +07:00
Yonle
75c39b6bf5 yeet
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 16:27:40 +07:00
Yonle
bcc5c46979 remove useless code.
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 16:24:02 +07:00
Yonle
7d5ab86756 orphan: send CLOSE
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 14:41:22 +07:00
Yonle
7df3a272af orphan socket is unreliable.
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 14:23:59 +07:00
Yonle
da562a335d feat: Orphan Session
Add feature to keep and reuse an session to cut some loads off &
somewhat improve bouncing performance.

Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-03 14:10:01 +07:00
Yonle
08684cfdbd defaultconf: leave pause_on_limit off by default
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-01 18:42:55 +07:00
Yonle
6044eb2dba feat: add feature to only allow event from <approved_publishers>
Based on: https://github.com/Yonle/bostr/pull/8
Idea is originally by Takuro Furoda <https://github.com/ftkro>

This feature will only allow transmitting events from specified authors.

Suggested-by: Takuro Furoda
Signed-off-by: Yonle <yonle@lecturify.net>
2024-01-01 11:16:53 +07:00
Yonle
a163e6a879 defaultconf: change default max_eose_score
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-28 08:38:00 +07:00
Ryo Kanbayashi
99a076865b
several bug fixes (by ryogrid #7)
* condition of if statement at line 119 seems to wrong
* Original code can't check size of client.pendingEOSE.get(data[1]) collectly
* Replaced clearInterval to clearTimeout. canceling function for timer which is created by setTimeout is clearTimeout
2.0.1
2023-12-25 21:12:26 +07:00
Yonle
c400c3959d relayHandler: terminate immediately if user already disconnected.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-24 21:22:56 +07:00
Yonle
c7d37b8531 PRfix: timeoutBeforeReconnHandler, and improvements in code
As based in the following Pull Request:
- https://github.com/Yonle/bostr/pull/6

Suggested-By: ryogrid <ryo.contact@gmail.com>
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-24 21:16:44 +07:00
Yonle
0c8d21edf1 typofix
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-20 18:37:24 +07:00
Yonle
1efe153039 ramp the cache up, again.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-20 00:16:54 +07:00
Yonle
6b1c5e03eb ramp the cache up no matter what
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-20 00:11:13 +07:00
Yonle
635b317d73 caching: also save into cache relays
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-19 23:48:24 +07:00
Yonle
30b627f00c caching tweaks
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-19 23:41:33 +07:00
Yonle
592af79f9c feat: added [cache_relays] feature
Signed-off-by: Yonle <yonle@lecturify.net>
2023-12-19 23:26:02 +07:00
Yonle
5ae56bd8b4
Merge pull request #4 from akiomik/fix-typos
Fix typos
2023-12-19 22:12:38 +07:00
Akiomi Kamakura
2873527df7
Fix typos 2023-12-19 12:05:11 +09:00
Yonle
a3b37912bc fix resend event code
Signed-off-by: Yonle <yonle@lecturify.net>
2.0.0-r1
2023-11-29 13:58:44 +07:00
Yonle
540963177a fix verbose logging bug.
Signed-off-by: Yonle <yonle@lecturify.net>
2.0.0
2023-11-22 16:57:14 +07:00
Yonle
6758fc2070 defaultconf comment: give a tips.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-22 16:51:46 +07:00
Yonle
ac14c698dc introduce max EOSE score in config
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-22 16:43:19 +07:00
Yonle
e9fa7e19ee introduce EOSE Timeout
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-22 00:46:08 +07:00
Yonle
a1b68cc77e bouncer: allow the same subID to be REQ again
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 22:50:13 +07:00
Yonle
917de23b21 defaultconf: uh, small comment fix
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 20:49:14 +07:00
Yonle
64d06f2b2a defaultconf: add pubkey field for nip11
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 19:19:22 +07:00
Yonle
e3c2bf34d2 code cleaning, add more config options
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 19:14:40 +07:00
Yonle
2d73575375 http.js: probably need to tell the current path.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 15:15:11 +07:00
Yonle
e2d6960f9e package.json: change desc
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 13:58:31 +07:00
Yonle
b518022b21 major fix: fix EOSE handling
Array.from(relays) is actually just derivering { relays } from
config.js. Fix by changing "relays" with "socks" as that's what i am
expecting that limit from.

Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-21 13:08:52 +07:00
Yonle
b8c720aa8a enable nip42 function for public bouncer.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-20 22:45:35 +07:00
Yonle
8a189bcd2e defaultconf: Make it more understandable.
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-20 21:10:57 +07:00
Yonle
a9ddba1da3
Merge pull request #2 from HolgerHatGarKeineNode/patch-2
Missing commas added to config.js.example
2023-11-19 11:22:46 +07:00
Yonle
b9b8f5575f defaultconf: small typo
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-19 10:51:13 +07:00
Yonle
8b158507fb handle since & until and fixbug
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-19 08:46:35 +07:00
Yonle
f6d623004d do not send events after reach to limit till all relays EOSE-ed
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-19 08:37:43 +07:00
Yonle
4c20e05b5f defaultconf: Change some comments
Signed-off-by: Yonle <yonle@lecturify.net>
2023-11-19 08:02:40 +07:00
HolgerHatGarKeineNode
01a6f5157e
Missing commas added to config.js.example
syntax errors fixed
2023-11-18 22:23:18 +00:00