upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/nostr.h
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-07-29 11:51:37 -0300
committerGitHub <noreply@github.com>2026-07-29 11:51:37 -0300
commit7f6fdbab6c90360ab3b2d391a7b5aedc6f9721ac (patch)
tree4a5504cb39d72d15b85e1a05f2493f6fa04b2eb3 /src/nostr.h
parentba2de82b76aeeabe1c45877e02b0e8fe5b59bed3 (diff)
nostr: never advertise a rendezvous we are not registered at (#26)
BtfActiveRelay() fell back to vBtfMeetingRelays[0] whenever registration had not completed yet. ThreadNostrSeed and ThreadBtfAccept start in parallel (net.cpp), so at boot that fallback was exactly what PublishDescriptor wrote into the descriptor -- including the one-time self-test, which publishes to every relay in the list. Peers reading it dialed a rendezvous this node was never registered at, and whenever the first seed happened to be down (92.246.128.180 was, for part of today) every one of those dials was wasted. BtfActiveRelay() now returns only the relay ThreadBtfAccept confirmed, and PublishDescriptor skips publishing until there is one. The seed loop republishes on every pass, so the only cost is the delay until registration succeeds; the self-test waits up to 60s for it so it still measures the publish/resolve chain instead of losing the race against it. Also fix the WebSocket handshake reader. On headers past the cap it did a bare break, leaving the socket parked in the middle of the header block -- and since the status line had already been read, the " 101 " check still passed, so the caller got a "connected" socket whose next bytes were leftover HTTP that the frame parser then read as garbage frames. It now errors out instead, and the cap is 8192 because relays behind Cloudflare send large header blocks.
Diffstat (limited to 'src/nostr.h')
-rw-r--r--src/nostr.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nostr.h b/src/nostr.h
index 37b3b05..04149e3 100644
--- a/src/nostr.h
+++ b/src/nostr.h
@@ -34,7 +34,8 @@ extern const int nNostrRelays;
34extern std::vector<std::string> vBtfMeetingRelays; 34extern std::vector<std::string> vBtfMeetingRelays;
35// The relay this node is currently registered at (set by ThreadBtfAccept). 35// The relay this node is currently registered at (set by ThreadBtfAccept).
36extern std::string strBtfActiveRelay; 36extern std::string strBtfActiveRelay;
37// The active relay, or the first seed if none active yet ("" if the list is empty). 37// The relay we are registered at, or "" if registration hasn't succeeded yet.
38// Never guesses a seed: an unregistered node has no meeting node to advertise.
38std::string BtfActiveRelay(); 39std::string BtfActiveRelay();
39// Record the relay this node just registered its service at (thread-safe). 40// Record the relay this node just registered its service at (thread-safe).
40void BtfSetActiveRelay(const std::string& relay); 41void BtfSetActiveRelay(const std::string& relay);