1
0
mirror of https://github.com/Yonle/bostr.git synced 2025-03-17 21:32:43 +01:00

comm: User-Agent: Tell the contact address in User-Agent

Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
Yonle 2024-05-19 22:01:13 +07:00
parent 55cd043b6e
commit f7cc855fe3
3 changed files with 10 additions and 3 deletions

@ -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.

@ -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}`
}
});

@ -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}`,
}
});