upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorBitflash-sh <btf01@proton.me>2026-07-24 14:46:49 -0300
committerBitflash-sh <btf01@proton.me>2026-07-24 14:46:49 -0300
commite2bc68de1af27d3459878f43c40061d0c30d09d7 (patch)
tree40bffb13573ff9fe4a3c114883d10f533aa7e803 /src/net.cpp
parent2b10d4a64fd17ad6320055935d76ab6beca3b9b3 (diff)
Automatic relay discovery over Nostr + call-to-action
Relay operators announce their relay with -announcerelay=host:port; every node discovers announced relays (kind 38502) and adds them to its failover list, so volunteer relays join with no maintainer edit or approval. Anti-spam cap + validation; relays are trustless (echan makes a bad relay unable to read/MITM). README: automatic relay-volunteer guide, 'don't let the network die' section.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 659de05..31afaf5 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -442,18 +442,27 @@ void ThreadBtfAccept(void* parg)
442 Sleep(5000); 442 Sleep(5000);
443 } 443 }
444 size_t iRelay = 0; 444 size_t iRelay = 0;
445 bool fPicked = false;
445 loop 446 loop
446 { 447 {
447 if (fShutdown) 448 if (fShutdown)
448 return; 449 return;
449 if (vBtfMeetingRelays.empty()) 450 // Curated seeds + relays discovered from Nostr announcements.
451 vector<string> relays = BtfAllRelays();
452 if (relays.empty())
450 { 453 {
451 Sleep(10000); // no meeting relay configured 454 Sleep(10000); // no meeting relay configured
452 continue; 455 continue;
453 } 456 }
457 // Random start spreads nodes across all relays (incl. volunteer ones).
458 if (!fPicked)
459 {
460 iRelay = (size_t)GetRand(relays.size());
461 fPicked = true;
462 }
454 // Stick to the current relay while it works; on failure, fail over to 463 // Stick to the current relay while it works; on failure, fail over to
455 // the next seed so a DDoS'd/blocked relay IP can't keep us offline. 464 // the next one so a DDoS'd/blocked relay IP can't keep us offline.
456 string strMeeting = vBtfMeetingRelays[iRelay % vBtfMeetingRelays.size()]; 465 string strMeeting = relays[iRelay % relays.size()];
457 size_t colon = strMeeting.rfind(':'); 466 size_t colon = strMeeting.rfind(':');
458 if (colon == string::npos) 467 if (colon == string::npos)
459 { 468 {