mirror of
https://github.com/Yonle/bostr.git
synced 2025-09-25 20:36:24 +02:00
feat(bouncer): Tell upstream relays the client IP address if needed.
Signed-off-by: Yonle <yonle@lecturify.net>
This commit is contained in:
@@ -6,7 +6,7 @@ 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 } = require(process.env.BOSTR_CONFIG_PATH || "./config");
|
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, forward_ip_address_to_upstream } = 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);
|
||||||
@@ -211,9 +211,14 @@ function bc(msg, ws) {
|
|||||||
// WS - Sessions
|
// WS - Sessions
|
||||||
function newConn(addr, client, reconn_t = 0) {
|
function newConn(addr, client, reconn_t = 0) {
|
||||||
if (client.readyState !== 1) return;
|
if (client.readyState !== 1) return;
|
||||||
|
let additionalReqHeaders = {};
|
||||||
|
if (forward_ip_address_to_upstream)
|
||||||
|
additionalReqHeaders["x-forwarded-for"] = client.ip;
|
||||||
|
|
||||||
const relay = new WebSocket(addr, {
|
const relay = new WebSocket(addr, {
|
||||||
headers: {
|
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`,
|
||||||
|
...additionalReqHeaders
|
||||||
},
|
},
|
||||||
noDelay: true,
|
noDelay: true,
|
||||||
allowSynchronousEvents: true
|
allowSynchronousEvents: true
|
||||||
|
@@ -139,6 +139,9 @@ module.exports = {
|
|||||||
// Path to favicon file.
|
// Path to favicon file.
|
||||||
favicon: "",
|
favicon: "",
|
||||||
|
|
||||||
|
// Forward client IP address to upstream relays with x-forwarded-for
|
||||||
|
forward_ip_address_to_upstream: true,
|
||||||
|
|
||||||
// Nostr relays to bounce [Required]
|
// Nostr relays to bounce [Required]
|
||||||
relays: [
|
relays: [
|
||||||
"wss://example1.com",
|
"wss://example1.com",
|
||||||
|
Reference in New Issue
Block a user