diff --git a/bouncer.js b/bouncer.js index 478ee4f..d2e6b22 100644 --- a/bouncer.js +++ b/bouncer.js @@ -38,6 +38,7 @@ module.exports = (ws, req, onClose) => { ws.acceptKinds = query.accept?.split(",").map(_ => parseInt(_)); ws.forcedLimit = parseInt(query.limit); ws.accurateMode = parseInt(query.accurate); + ws.saveMode = parseInt(query.save); if (authorized_keys?.length) { authKey = Date.now() + Math.random().toString(36); @@ -268,7 +269,7 @@ function newConn(addr, client, reconn_t = 0) { if (client.events.get(data[1]).size >= limit) { // Once reached to , send EOSE to client. client.send(JSON.stringify(["EOSE", data[1]])); - if (!client.accurateMode && pause_on_limit) { + if (!client.accurateMode && (client.saveMode || pause_on_limit)) { client.pause_subs.add(data[1]); } else { client.pendingEOSE.delete(data[1]); diff --git a/config.js.example b/config.js.example index 55fc7ea..9b0d7db 100644 --- a/config.js.example +++ b/config.js.example @@ -49,7 +49,7 @@ module.exports = { // Could save client's bandwidth. Disable this if you need to get more events. // // You may also need to adjust . - pause_on_limit: false, + pause_on_limit: true, // Maximum of received EOSE from relays to send EOSE to client. // Normally, waiting EOSE from 3 relays should be enough. Leaving it with 0 equals wait for every established relays. diff --git a/http.js b/http.js index eeca55b..12b1fca 100644 --- a/http.js +++ b/http.js @@ -79,9 +79,12 @@ server.on('request', (req, res) => { res.write(`\n\n- To make connection that override client's REQ limit, Connect:`); 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\n- To connect with accurate bouncing mode${config.pause_on_limit ? "" : " (Default)"}, Connect:`); res.write(`\n ${serverAddr}?accurate=1`); res.write(`\n (Will consume lot of bandwidths)`); + res.write(`\n\n- To connect with save mode${config.pause_on_limit ? " (Default)" : ""}, Connect:`); + res.write(`\n ${serverAddr}?save=1`); + res.write(`\n (Saves bandwidth usage)`); 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() });