diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 09:03:01 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-02 09:03:01 +0000 |
| commit | 7c70eb4498e88725241493033edfe89554ff1b18 (patch) | |
| tree | a053678bf029d17c3a0b193fbaaf1abaf3778aff /src/btfrv.cpp | |
| parent | e4f898c4a6b9900553c64b9804889b5fdae3e55f (diff) | |
tunnel: report which stage failed instead of guessing the cause
Diffstat (limited to 'src/btfrv.cpp')
| -rw-r--r-- | src/btfrv.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/btfrv.cpp b/src/btfrv.cpp index 133eb89..864fe3d 100644 --- a/src/btfrv.cpp +++ b/src/btfrv.cpp | |||
| @@ -334,17 +334,29 @@ bool RvServiceWaitPaired(RvSocket s, int nTimeoutSecs) | |||
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | RvSocket RvClientConnect(const char* relay_host, unsigned short port, | 336 | RvSocket RvClientConnect(const char* relay_host, unsigned short port, |
| 337 | const unsigned char target_pubkey[32]) | 337 | const unsigned char target_pubkey[32], |
| 338 | RvClientFail* pFail) | ||
| 338 | { | 339 | { |
| 340 | if (pFail) *pFail = RVC_FAIL_DIAL; | ||
| 339 | if (!RvInit()) return RV_INVALID; | 341 | if (!RvInit()) return RV_INVALID; |
| 340 | SOCKET s = ConnectTo(relay_host, port); | 342 | SOCKET s = ConnectTo(relay_host, port); |
| 341 | if (s == INVALID_SOCKET) return RV_INVALID; | 343 | if (s == INVALID_SOCKET) return RV_INVALID; |
| 344 | if (pFail) *pFail = RVC_FAIL_PAIR; | ||
| 342 | unsigned char hdr[33]; | 345 | unsigned char hdr[33]; |
| 343 | hdr[0] = (unsigned char)'C'; | 346 | hdr[0] = (unsigned char)'C'; |
| 344 | memcpy(hdr + 1, target_pubkey, 32); | 347 | memcpy(hdr + 1, target_pubkey, 32); |
| 345 | if (!WriteN(s, hdr, 33)) { CLOSESOCK(s); return RV_INVALID; } | 348 | if (!WriteN(s, hdr, 33)) { CLOSESOCK(s); return RV_INVALID; } |
| 346 | unsigned char paired = 0; | 349 | unsigned char paired = 0; |
| 347 | if (!ReadN(s, &paired, 1) || paired != 0x01) { CLOSESOCK(s); return RV_INVALID; } | 350 | if (!ReadN(s, &paired, 1)) { CLOSESOCK(s); return RV_INVALID; } |
| 351 | if (paired != 0x01) | ||
| 352 | { | ||
| 353 | // The relay answered and declined: HandleIncoming writes 0x00 and | ||
| 354 | // closes when no service is parked under this pubkey right now. | ||
| 355 | if (pFail) *pFail = RVC_FAIL_REFUSED; | ||
| 356 | CLOSESOCK(s); | ||
| 357 | return RV_INVALID; | ||
| 358 | } | ||
| 359 | if (pFail) *pFail = RVC_FAIL_NONE; | ||
| 348 | return (RvSocket)s; | 360 | return (RvSocket)s; |
| 349 | } | 361 | } |
| 350 | 362 | ||