diff --git a/bouncer.js b/bouncer.js index 8f2a200..478ee4f 100644 --- a/bouncer.js +++ b/bouncer.js @@ -37,6 +37,7 @@ module.exports = (ws, req, onClose) => { ws.rejectKinds = query.reject?.split(",").map(_ => parseInt(_)); ws.acceptKinds = query.accept?.split(",").map(_ => parseInt(_)); ws.forcedLimit = parseInt(query.limit); + ws.accurateMode = parseInt(query.accurate); if (authorized_keys?.length) { authKey = Date.now() + Math.random().toString(36); @@ -254,22 +255,20 @@ function newConn(addr, client, reconn_t = 0) { if (NotInSearchQuery) return; if (client.events.get(data[1]).has(data[2]?.id)) return; // No need to transmit once it has been transmitted before. - if (!client.pause_subs.has(data[1])) { - client.events.get(data[1]).add(data[2]?.id); - client.send(JSON.stringify(data)); - } + client.events.get(data[1]).add(data[2]?.id); + client.send(JSON.stringify(data)); // Now count for REQ limit requested by client. // If it's at the limit, Send EOSE to client and delete pendingEOSE of subID // Skip if EOSE has been omitted - if (!client.pendingEOSE.has(data[1]) || client.pause_subs.has(data[1])) return; + if (!client.pendingEOSE.has(data[1])) return; const limit = getFilterLimit(filter); if (limit === Infinity) return; if (client.events.get(data[1]).size >= limit) { // Once reached to , send EOSE to client. client.send(JSON.stringify(["EOSE", data[1]])); - if (pause_on_limit) { + if (!client.accurateMode && pause_on_limit) { client.pause_subs.add(data[1]); } else { client.pendingEOSE.delete(data[1]); diff --git a/http.js b/http.js index 48bc916..eeca55b 100644 --- a/http.js +++ b/http.js @@ -77,8 +77,11 @@ server.on('request', (req, res) => { res.write(`\n ${serverAddr}?reject=3,6,7`); res.write(`\n (Will not send events with kind 3, 6, and 7)`); res.write(`\n\n- To make connection that override client's REQ limit, Connect:`); - res.write(`\n ${serverAddr}?limit=50`); + res.write(`\n ${serverAddr}?limit=50 or ${serverAddr}?accurate=1&limit=50`); res.write(`\n (Will override REQ limit from client to 50 if exceeds)`); + res.write(`\n\n- To connect with accurate bouncing mode, Connect:`); + res.write(`\n ${serverAddr}?accurate=1`); + res.write(`\n (Will consume lot of bandwidths)`); res.end(`\n\n---\nPowered by Bostr (${version}) - Open source Nostr bouncer\nhttps://github.com/Yonle/bostr`); } else if (req.url.includes("favicon") && favicon) { res.writeHead(200, { "Content-Type": "image/" + config.favicon?.split(".").pop() });