http&bouncer: enable synchronousEvents & deflate compression by default.

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle
2024-01-27 19:42:18 +07:00
parent 8f3689a1c7
commit 67e44ffb84
3 changed files with 10 additions and 2 deletions

View File

@@ -284,7 +284,8 @@ function newConn(addr, id, reconn_t = 0) {
headers: { headers: {
"User-Agent": `Bostr (v${version}); The nostr relay bouncer; https://github.com/Yonle/bostr` "User-Agent": `Bostr (v${version}); The nostr relay bouncer; https://github.com/Yonle/bostr`
}, },
noDelay: true noDelay: true,
allowSynchronousEvents: true
}); });
relay.id = id; relay.id = id;

View File

@@ -23,6 +23,9 @@ module.exports = {
// Log about bouncer connection with relays? // Log about bouncer connection with relays?
log_about_relays: false, log_about_relays: false,
// Use deflate compression for websocket.
perMessageDeflate: true,
// Time before reconnect to relays in milliseconds. // Time before reconnect to relays in milliseconds.
reconnect_time: 5000, reconnect_time: 5000,

View File

@@ -37,7 +37,11 @@ if (
server.isStandaloneHTTPS = false; server.isStandaloneHTTPS = false;
} }
const wss = new WebSocket.WebSocketServer({ noServer: true }); const wss = new WebSocket.WebSocketServer({
noServer: true,
allowSynchronousEvents: true,
perMessageDeflate: config.perMessageDeflate || true
});
const lastConn = new Map(); const lastConn = new Map();
const favicon = fs.existsSync(config.favicon) ? fs.readFileSync(config.favicon) : null; const favicon = fs.existsSync(config.favicon) ? fs.readFileSync(config.favicon) : null;