upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/nostr.cpp
diff options
context:
space:
mode:
authorBitflash-sh <btf01@proton.me>2026-07-24 12:13:30 -0300
committerBitflash-sh <btf01@proton.me>2026-07-24 12:13:30 -0300
commit3efd9a089cc6b924d9bc917d3d8145f7c01265ad (patch)
tree5c4d1bc9a487e54fb0ec5b386dbd4360b6779f42 /src/nostr.cpp
parent51d617e70f90a972185917ea0096c1ecef2bfa8b (diff)
Multi-relay rendezvous with failover + relay rate-limiting
Seed list of 3 geographically-spread relays (Sao Paulo, New Jersey, Almaty); nodes register at the first reachable one and fail over if it is attacked or goes down, so no single relay IP is a point of failure. Relay installer now applies iptables connection rate-limits to soak up single-source floods.
Diffstat (limited to 'src/nostr.cpp')
-rw-r--r--src/nostr.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/nostr.cpp b/src/nostr.cpp
index 8e2a07d..59817f5 100644
--- a/src/nostr.cpp
+++ b/src/nostr.cpp
@@ -55,7 +55,32 @@ const int nNostrRelays = ARRAYLEN(pszNostrRelays);
55 55
56// Rendezvous meeting relay this node registers at (ThreadBtfAccept in net.cpp) 56// Rendezvous meeting relay this node registers at (ThreadBtfAccept in net.cpp)
57// and advertises in its .btf descriptor. Seed default; /rvrelay overrides. 57// and advertises in its .btf descriptor. Seed default; /rvrelay overrides.
58string strBtfMeetingRelay = "90.156.222.107:8434"; 58// Seed rendezvous relays. More entries = more resilience: the node fails over
59// between them (see ThreadBtfAccept), so DDoSing one relay IP can't take the
60// network down. /rvrelay overrides this list with a single entry.
61vector<string> vBtfMeetingRelays = {
62 "92.246.128.180:8434", // Sao Paulo, BR
63 "31.44.4.249:8434", // New Jersey, US
64 "90.156.222.107:8434", // Almaty, KZ
65};
66string strBtfActiveRelay;
67static CCriticalSection cs_activeRelay;
68
69string BtfActiveRelay()
70{
71 CRITICAL_BLOCK(cs_activeRelay)
72 if (!strBtfActiveRelay.empty())
73 return strBtfActiveRelay;
74 if (!vBtfMeetingRelays.empty())
75 return vBtfMeetingRelays[0];
76 return "";
77}
78
79void BtfSetActiveRelay(const string& relay)
80{
81 CRITICAL_BLOCK(cs_activeRelay)
82 strBtfActiveRelay = relay;
83}
59 84
60 85
61// 86//
@@ -519,8 +544,9 @@ static void PublishDescriptor(CWebSocket& ws, CNostrKey& key)
519{ 544{
520 // meeting_node is the rendezvous relay this node's hidden service 545 // meeting_node is the rendezvous relay this node's hidden service
521 // (ThreadBtfAccept in net.cpp) is registered at -- where clients dial us. 546 // (ThreadBtfAccept in net.cpp) is registered at -- where clients dial us.
522 string meeting_node = strBtfMeetingRelay.empty() ? "rendezvous-pending" 547 string meeting_node = BtfActiveRelay();
523 : strBtfMeetingRelay; 548 if (meeting_node.empty())
549 meeting_node = "rendezvous-pending";
524 string desc = btf::SignDescriptor(key.ctx, key.seckey, key.EncPubHex(), 550 string desc = btf::SignDescriptor(key.ctx, key.seckey, key.EncPubHex(),
525 meeting_node, (uint64_t)GetTime()); 551 meeting_node, (uint64_t)GetTime());
526 if (desc.empty()) 552 if (desc.empty())