mirror of
https://github.com/Yonle/bostr.git
synced 2025-09-27 21:36:21 +02:00
bouncer: warn when config is still using approved_publishers
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
17
bouncer.js
17
bouncer.js
@@ -6,16 +6,25 @@ const { validateEvent, nip19, matchFilters, mergeFilters, getFilterLimit } = req
|
|||||||
const auth = require("./auth.js");
|
const auth = require("./auth.js");
|
||||||
const nip42 = require("./nip42.js");
|
const nip42 = require("./nip42.js");
|
||||||
|
|
||||||
let { relays, approved_publishers, blocked_publishers, log_about_relays, authorized_keys, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, broadcast_ratelimit, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, noscraper } = require(process.env.BOSTR_CONFIG_PATH || "./config");
|
let { relays, allowed_publishers, approved_publishers, blocked_publishers, log_about_relays, authorized_keys, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, broadcast_ratelimit, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, noscraper } = require(process.env.BOSTR_CONFIG_PATH || "./config");
|
||||||
|
|
||||||
log_about_relays = process.env.LOG_ABOUT_RELAYS || log_about_relays;
|
log_about_relays = process.env.LOG_ABOUT_RELAYS || log_about_relays;
|
||||||
authorized_keys = authorized_keys?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
authorized_keys = authorized_keys?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
||||||
approved_publishers = approved_publishers?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
allowed_publishers = allowed_publishers?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
||||||
blocked_publishers = blocked_publishers?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
blocked_publishers = blocked_publishers?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
||||||
|
|
||||||
// CL MaxEoseScore: Set <max_eose_score> as 0 if configured relays is under of the expected number from <max_eose_score>
|
// CL MaxEoseScore: Set <max_eose_score> as 0 if configured relays is under of the expected number from <max_eose_score>
|
||||||
if (relays.length < max_eose_score) max_eose_score = 0;
|
if (relays.length < max_eose_score) max_eose_score = 0;
|
||||||
|
|
||||||
|
// The following warning will be removed in the next 2 stable release
|
||||||
|
if (approved_publishers?.length) {
|
||||||
|
allowed_publishers = approved_publishers?.map(i => i.startsWith("npub") ? nip19.decode(i).data : i);
|
||||||
|
console.warn(process.pid, "[config]");
|
||||||
|
console.warn(process.pid, "[config]", "!!! Attention !!!");
|
||||||
|
console.warn(process.pid, "[config]", "approved_publishers is deprecated. rename as allowed_publishers");
|
||||||
|
console.warn(process.pid, "[config]");
|
||||||
|
}
|
||||||
|
|
||||||
const csess = new Map(); // this is used for relays.
|
const csess = new Map(); // this is used for relays.
|
||||||
const userRelays = new Map(); // per ID contains Set() of <WebSocket>
|
const userRelays = new Map(); // per ID contains Set() of <WebSocket>
|
||||||
const idleSess = new Set();
|
const idleSess = new Set();
|
||||||
@@ -88,8 +97,8 @@ function handleConnection(ws, req, onClose) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
approved_publishers?.length &&
|
allowed_publishers?.length &&
|
||||||
!approved_publishers?.includes(data[1].pubkey)
|
!allowed_publishers?.includes(data[1].pubkey)
|
||||||
) return ws.send(JSON.stringify(["OK", data[1]?.id, false, "rejected: unauthorized"]));
|
) return ws.send(JSON.stringify(["OK", data[1]?.id, false, "rejected: unauthorized"]));
|
||||||
|
|
||||||
if (broadcast_ratelimit && (broadcast_ratelimit > (Date.now() - lastEvent))) {
|
if (broadcast_ratelimit && (broadcast_ratelimit > (Date.now() - lastEvent))) {
|
||||||
|
@@ -89,15 +89,15 @@ module.exports = {
|
|||||||
// ....
|
// ....
|
||||||
],
|
],
|
||||||
|
|
||||||
// A whitelist of approved event publishers.
|
// A whitelist of allowed event owner.
|
||||||
// Leaving this empty will allow everyone to publish events with this bouncer.
|
// Leaving this empty will allow everyone to publish events from anyone to this bouncer.
|
||||||
approved_publishers: [
|
allowed_publishers: [
|
||||||
// "pubkey-in-hex",
|
// "pubkey-in-hex",
|
||||||
// "npub ....",
|
// "npub ....",
|
||||||
// ....
|
// ....
|
||||||
],
|
],
|
||||||
|
|
||||||
// A blacklist of blocked event publishers.
|
// A blacklist of blocked event owner.
|
||||||
blocked_publishers: [
|
blocked_publishers: [
|
||||||
// "pubkey-in-hex",
|
// "pubkey-in-hex",
|
||||||
// "npub ....",
|
// "npub ....",
|
||||||
|
Reference in New Issue
Block a user