Skip to content

Commit

Permalink
http & worker: handle max_client_subs properly
Browse files Browse the repository at this point in the history
Signed-off-by: Yonle <yonle@lecturify.net>
  • Loading branch information
Yonle committed May 19, 2024
1 parent 793bd71 commit 14efdaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions http.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ let loadbalancerUpstreamLinks = [];

config.server_meta.version = version;
config.server_meta.limitation = {
auth_required: false
auth_required: (config.server_meta.loadbalancer?.length || config.authorized_keys?.length) ? true : false,
max_subscription: config.max_client_subs || Infinity
};

if (config.server_meta.loadbalancer?.length || config.authorized_keys?.length)
config.server_meta.limitation.auth_required = true;

if (!config.relays?.length) (async () => {
console.log("Load balancer mode. Fetching relays list from", config.loadbalancer[0].replace(/^ws/, "http"));
const request = await undici.request(config.loadbalancer[0].replace(/^ws/, "http"), {
Expand Down
2 changes: 1 addition & 1 deletion worker_bouncer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ parentPort.on('message', m => {
if (!csess.hasOwnProperty(m.id)) return;
const ws = csess[m.id];

if ((max_client_subs !== -1) && (Object.keys(ws.subs).length > max_client_subs))
if ((max_client_subs !== -1) && (Object.keys(ws.subs).length >= max_client_subs))
return parentPort.postMessage({
type: "upstream_msg",
id: m.id,
Expand Down

0 comments on commit 14efdaf

Please sign in to comment.