diff --git a/config.js.example b/config.js.example index f07857d..0c383e8 100644 --- a/config.js.example +++ b/config.js.example @@ -142,6 +142,7 @@ module.exports = { "description": "Nostr relay bouncer", "name": "Bostr", "software": "git+https://github.com/Yonle/bostr", + "canonical_url": "wss://bostr.example.com", // Some nostr client may read the following for compatibility check. // You may change the supported_nips to match with what your relays supported. diff --git a/http.js b/http.js index f5e916d..287722c 100644 --- a/http.js +++ b/http.js @@ -22,12 +22,18 @@ let wslinkregex = /(?:^- )(wss?:\/\/.*)(?: \(.*\))/gm; let loadbalancerUpstreamLinks = []; config.server_meta.version = version; +config.server_meta.limitation = { + auth_required: false +}; + +if (config.server_meta.loadbalancer?.length || config.authorized_keys?.length) + config.server_meta.limitation.auth_required = true; if (!config.relays?.length) (async () => { console.log("Load balancer mode. Fetching relays list from", config.loadbalancer[0].replace(/^ws/, "http")); const request = await undici.request(config.loadbalancer[0].replace(/^ws/, "http"), { headers: { - "User-Agent": `Bostr ${version}; The nostr relay bouncer; https://github.com/Yonle/bostr` + "User-Agent": `Bostr ${version}; The nostr relay bouncer; https://github.com/Yonle/bostr; ${config.server_meta.canonical_url || "No canonical bouncer URL specified"}; Contact: ${config.server_meta.contact}` } }); diff --git a/worker_bouncer.js b/worker_bouncer.js index 45ac29d..bb365a1 100644 --- a/worker_bouncer.js +++ b/worker_bouncer.js @@ -7,7 +7,7 @@ const WebSocket = require("ws"); const { validateEvent, nip19, matchFilters, mergeFilters, getFilterLimit } = require("nostr-tools"); const nip42 = require("./nip42.js"); -let { relays, log_about_relays, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, loadbalancer, max_known_events } = require(process.env.BOSTR_CONFIG_PATH || "./config"); +let { relays, log_about_relays, server_meta, private_keys, reconnect_time, wait_eose, pause_on_limit, max_eose_score, upstream_ratelimit_expiration, max_client_subs, idle_sessions, cache_relays, loadbalancer, max_known_events } = require(process.env.BOSTR_CONFIG_PATH || "./config"); log_about_relays = process.env.LOG_ABOUT_RELAYS || log_about_relays; @@ -280,7 +280,7 @@ function newConn(addr, id, reconn_t = 0) { if (!stats[addr]) stats[addr] = { raw_rx: 0, rx: 0, tx: 0, f: 0 }; const relay = new WebSocket(addr, { headers: { - "User-Agent": `Bostr ${version}; The nostr relay bouncer; https://github.com/Yonle/bostr`, + "User-Agent": `Bostr ${version}; The nostr relay bouncer; https://github.com/Yonle/bostr; ${server_meta.canonical_url || "No canonical bouncer URL specified"}; Contact: ${server_meta.contact}`, } });