diff options
| author | Bitflash <btf01@proton.me> | 2026-07-31 09:38:10 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-31 09:38:10 -0300 |
| commit | 375415e2fb5af01eeea045dd9aa0522844d9b218 (patch) | |
| tree | 8567d0d98e8e42aba0a48eb4a2735ba8e69a2207 /src | |
| parent | f2ea483df4b2277abe13cc19bcc0bc5834c2e3e6 (diff) | |
relay: drop registrations whose far end is gone (#65)
A service registers at the relay and its socket sits in the waiting map
until a client dials it. Nothing ever checked whether that service was
still there. A node that went away left its registration behind, and the
next client to ask for that key got paired with a corpse: both sides were
told the pairing succeeded, then the tunnel failed with nothing to explain
it. That is the "tunnel to X failed" line the dialling node reports.
A reaper walks the waiting map every 60 seconds and drops registrations
whose far end is provably gone, and the pairing path checks the same thing
before handing a registration over, so a client gets a clean refusal
instead of a broken tunnel.
Provably gone means: the socket became readable and recv returned 0 or an
error. A registered service sends nothing while it waits, so readable is
already abnormal; recv distinguishes a closed peer from anything else.
Sockets that are simply idle are left alone. select() rather than
MSG_DONTWAIT so this compiles on Windows and never touches the socket's
blocking mode.
Deliberately no expiry by age. Nodes older than v1.2.7 register once and
block forever waiting to be dialled -- they never re-register, so a clock
based rule would quietly make every one of them unreachable, and being
blocked in recv they would never find out. Only provable death counts.
Known limit: this catches a peer that closed or reset, not one whose path
died silently with no FIN. Detecting that needs a probe, and there is no
byte the relay can send to a waiting service without corrupting the
protocol it is waiting on.
Verified on the VPS on a spare port: a node registered, was killed with
SIGKILL, and the next reaper pass logged
"reaper: dropped 1 dead registration(s), 0 waiting".
Diffstat (limited to 'src')
0 files changed, 0 insertions, 0 deletions