26 Commits

Author SHA1 Message Date
Yonle
499e765a28 add a way to set user agent
Signed-off-by: Yonle <yonle@lecturify.net>
2025-01-06 22:27:40 +07:00
Yonle
d3c73eb05a moving...
Signed-off-by: Yonle <yonle@lecturify.net>
2024-08-29 16:45:55 +07:00
Yonle
c6935870cb worker_bouncer: fix error handling code
Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-09 09:35:41 +07:00
Yonle
d8d364e274 code: cleanup & fix NIP-42 for upstream
- Fix NIP-42 authentication in bouncer side
- Split event handler codes for receiver

Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-08 17:07:04 +07:00
Yonle
4af2f4095b worker_bouncer: small fix but does not really hurt that much
Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-08 10:09:58 +07:00
Yonle
ec9baec453 worker_bouncer: try replace newConn function code as class inherited from WebSocket
Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-07 23:34:41 +07:00
Yonle
5d0eb6fa0c worker_bouncer: for some reason, terminate() is good for memory.
Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-07 12:13:38 +07:00
Yonle
30fd601263 code: use .close() instead of .terminate() & change the name for node module load
Signed-off-by: Yonle <yonle@lecturify.net>
2024-06-05 19:57:17 +07:00
Yonle
a187fed74f worker: newsess: rehandle loadbalancer config handling
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-28 23:12:50 +07:00
Yonle
533f3e6d00 worker_bouncer: use <array>.splice(<index>, 1) for removing instead of just delete
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-28 22:49:28 +07:00
Yonle
014d4692cd bouncer connection to relays: tell ConnID in header
This commit will expose ConnID in User-Agent HTTP Header on connection to upstream
relays. The ConnID is only an random string that only the bostr admin
knows what IP it does belong. This random string is always changing and
will never give the same ID on every single connections, So please do
not take this to be a similiar thing like X-Real-IP.

The ConnID won't reveal client IP to upstream relay due to how the
bouncer technically works, But it will help on both parties to finding the
culprit.

Only the respective bostr owner / admin know what IP does this ConnIDs
belong.

- To report an suspected service abuse, Contact to the bostr admin.
  Make sure that you send atleast more than a single log of ConnID.
  Please remember that these ConnIDs is not always the same.
  So sending more log about ConnIDs will help bostr admin to figure out
  the culprit.

- For bostr admins, Finding out the culprit is easy.
  In your bostr log:

  1 --- xxx.xxx.xxx.xxx is now using session 171629xxxxxxx_1_0.503985444xxxxxxx
               ^                                             ^
               |                                             |
            Culprit                                        ConnID

Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-21 18:32:12 +07:00
Yonle
b99795f9d8 worker: do not reconnect to cache relays/loadbalancer bouncers if status code ix 4xx
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-21 16:32:07 +07:00
Yonle
845aa5b3cc worker: fix bug where subscription limit is not being handled properly
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-20 13:16:53 +07:00
Yonle
14efdaf830 http & worker: handle max_client_subs properly
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-19 23:33:36 +07:00
Yonle
f7cc855fe3 comm: User-Agent: Tell the contact address in User-Agent
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-19 22:01:13 +07:00
Yonle
1a3bac81b5 code: internal auth handling: improve the way of how it works
- Try not to renew ${authKey} variable after auth
- Call _auth() only after ${authenticated} and ${!sessStarted} is passed
  (_auth() is for telling the worker thread the authenticated user
  pubkey)
- In worker_bouncer.js, If csess[m.id].pubkey === m.pubkey, We do not
  need to do another reAUTH to these relays.

Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-16 18:45:55 +07:00
Yonle
dc96f87515 code comments: remove some old comments and try improve some existing one
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-12 16:07:38 +07:00
Yonle
7e54d9a209 bouncer: fix duplicates being forwarded to client.
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 19:04:15 +07:00
Yonle
65cddf8030 bouncer: trigger EOSE according to max_known_events value if available
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 14:07:35 +07:00
Yonle
63a653ae51 conf & bouncer: introducing max_known_events configuration
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 13:44:25 +07:00
Yonle
bc4784bfe0 bouncer: improve session & idents handling
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 10:59:10 +07:00
Yonle
6bf93d5be6 connections: try not use noDelay & allowSynchronousEvents
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 10:30:08 +07:00
Yonle
4923d263f2 code cleaning and features removal
The following configurations is removed due to flawed memory issues:
- broadcast_ratelimit
- incomming_ratelimit

Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-11 10:19:27 +07:00
Yonle
81fd6ebfac bouncer: remove event retransmitting
bostr already connected to relays before client is connecting to an
bouncer. So this feature is no longer needed.

Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-10 18:46:43 +07:00
Yonle
b6af5af30b code: replace Map() with Object just to try busting the myth
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-10 18:35:05 +07:00
Yonle
f6baf0c53b bouncer: split code into two separate processes with upstream comms to be a worker
Signed-off-by: Yonle <yonle@lecturify.net>
2024-05-10 13:18:05 +07:00