major bugfix: fix sock readyState handler

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-01-27 07:33:15 +07:00
parent d0b040fbb9
commit 7a71bcd779

View File

@ -208,7 +208,7 @@ function direct_bc(msg, id) {
for (const sock of socks) {
if (cache_relays?.includes(sock.url)) continue;
if (sock.id !== id) continue;
if (sock.readyState !== 2) continue;
if (sock.readyState !== 1) continue;
// skip the ratelimit after <config.upstream_ratelimit_expiration>
if ((upstream_ratelimit_expiration) > (Date.now() - sock.ratelimit)) continue;
@ -220,7 +220,7 @@ function cache_bc(msg, id) {
for (const sock of socks) {
if (!cache_relays?.includes(sock.url)) continue;
if (sock.id !== id) continue;
if (sock.readyState !== 2) continue;
if (sock.readyState !== 1) continue;
sock.send(JSON.stringify(msg));
}
}