upleb.uk

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

summaryrefslogtreecommitdiff
path: root/src/btfrv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/btfrv.cpp')
-rw-r--r--src/btfrv.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/btfrv.cpp b/src/btfrv.cpp
index 0d02ca8..63e092e 100644
--- a/src/btfrv.cpp
+++ b/src/btfrv.cpp
@@ -250,11 +250,20 @@ RvSocket RvServiceRegister(const char* relay_host, unsigned short port,
250 hdr[0] = (unsigned char)'S'; 250 hdr[0] = (unsigned char)'S';
251 memcpy(hdr + 1, my_pubkey, 32); 251 memcpy(hdr + 1, my_pubkey, 32);
252 if (!WriteN(s, hdr, 33)) { CLOSESOCK(s); return RV_INVALID; } 252 if (!WriteN(s, hdr, 33)) { CLOSESOCK(s); return RV_INVALID; }
253 unsigned char paired = 0; 253 // Return here: registered, not yet paired. The relay lists the service as
254 if (!ReadN(s, &paired, 1) || paired != 0x01) { CLOSESOCK(s); return RV_INVALID; } 254 // soon as it reads this header. The 0x01 that used to be consumed below
255 // only arrives when somebody dials us, so blocking on it made "registered"
256 // and "already in use" indistinguishable to the caller -- and left the node
257 // unable to advertise a meeting node until after it had been reached there.
255 return (RvSocket)s; 258 return (RvSocket)s;
256} 259}
257 260
261bool RvServiceWaitPaired(RvSocket s)
262{
263 unsigned char paired = 0;
264 return ReadN((SOCKET)s, &paired, 1) && paired == 0x01;
265}
266
258RvSocket RvClientConnect(const char* relay_host, unsigned short port, 267RvSocket RvClientConnect(const char* relay_host, unsigned short port,
259 const unsigned char target_pubkey[32]) 268 const unsigned char target_pubkey[32])
260{ 269{