Skip to content

Connectivity pre-flight, and a TCP fallback for networks that block UDP - #5

Merged
jimbotonic merged 1 commit into
mainfrom
feat/tcp-fallback-and-preflight
Aug 16, 2026
Merged

jimbotonic merged 1 commit into
mainfrom
feat/tcp-fallback-and-preflight

Conversation

@jimbotonic

Copy link
Copy Markdown
Contributor

The thing that stops a deployment first is not the security review, it is the firewall. Enterprise ingress is closed by default and plenty of policies decline inbound UDP outright — and until now a blocked port meant this engine did not degrade, it failed.

favonius check <host:port> probes the TCP fallback, the UDP control port and the UDP data port, prints the firewall rule to send the network team, and exits non-zero when no transfer is possible so it can gate a script.

The daemon now answers a probe datagram — the first draft did not, so the check reported a healthy daemon as unreachable, a false negative worse than not checking. The reply is exactly as long as the probe, since an unauthenticated responder that answers with more bytes than it receives is a reflection amplifier; a test pins that.

The data port is judged only on a definite rejection: an idle daemon does not read that socket, so silence there is normal and is reported as such.

TCP fallback (--transport tcp) listens on the TCP socket bearing the control port's number, so a deployment opens one port rather than two. No congestion control, no multi-stream, no performance claim — it exists so that "can we move a file at all" is always yes. Bytes stream to a .part, are hashed on the way past, and are committed by rename only when the payload is complete and the trailing BLAKE3 matches. Confinement calls the same --dest-root check the UDP receiver uses rather than reimplementing it.

Senders remain unauthenticated, as on the UDP path. Opening the TCP port widens that posture from one protocol to two rather than changing it; README and module docs say so. Disable with --no-tcp-fallback.

Verified: 4 MiB over TCP with a matching SHA-256 into a created subdirectory, no .part residue; a hand-rolled client sending a wrong hash refused with nothing committed; the check correct against a healthy daemon and a dead port. 577 tests pass; ahp-cli, ahp-daemon and ahp-proto check clean for x86_64-pc-windows-msvc.

The thing that stops a deployment first is not the security review, it is
the firewall. Enterprise ingress is closed by default, reaching a daemon
needs inbound UDP permitted, and plenty of policies decline that outright.
Until now a blocked port meant this engine did not degrade -- it failed --
and there was no way to find out except by evaluating for a week,
involving a security team, asking for a rule and waiting three weeks for
the answer to be no.

favonius check probes the TCP fallback, the UDP control port and the UDP
data port, and prints the rule to send the network team rather than
leaving someone to compose it. It exits non-zero when no transfer is
possible, so it can gate a script instead of only informing a reader.

The daemon now answers a probe datagram. The first draft did not, so the
check reported a healthy daemon as unreachable -- a false negative that
would have sent an evaluator to their network team over a working
deployment, which is worse than not checking at all. The reply is exactly
as long as the probe: an unauthenticated responder that answers with more
bytes than it receives is a reflection amplifier, and this port is open to
anyone who can reach it. A test pins that invariant.

The data port is treated differently on purpose. An idle daemon does not
read that socket, so silence there is expected and is reported as normal
rather than as a fault; only a definite rejection counts against it. The
rule printed still names it, because a firewall permitting the control
port and not the data port is common.

The TCP fallback is deliberately dull. No congestion control, no
multi-stream, none of the measurements in the README, and the kernel's
stack doing the work. It exists so that "can we move a file at all" is
always yes. A transfer that arrives slowly beats one that needs a change
request.

It listens on the TCP socket bearing the control port's number, so a
deployment asks for one port rather than two, in a sentence a network team
can act on. It keeps what matters: bytes stream to a .part, are hashed on
the way past, and are renamed into place only when the payload is complete
and the trailing BLAKE3 matches, so a truncated or altered transfer is
refused rather than written. Confinement calls the same --dest-root check
the UDP receiver uses rather than reimplementing it, because a second
write path with its own idea of where files may land is how that bug is
introduced.

One defect found while testing and fixed here: when the daemon refuses
after reading the header -- a path outside its root, say -- it stops
reading and closes, so the sender's next write failed with "broken pipe"
while the real reason sat unread on the socket. The sender now reads the
verdict before reporting, so a mis-typed destination says so instead of
sending someone to look at their network.

Verified end to end: 4 MiB over TCP with a matching SHA-256 into a created
subdirectory and no .part left behind; a hand-rolled client sending a
deliberately wrong hash is refused with nothing committed and no residue;
the check reports correctly against a healthy daemon, against a dead port,
and exits 1 only in the second case. 577 tests pass, and ahp-cli,
ahp-daemon and ahp-proto check clean for x86_64-pc-windows-msvc.

Senders are still not authenticated. Opening the TCP port widens that
posture from one protocol to two rather than changing it, and both the
README and the module say so.

Signed-off-by: Jimmy <jimbotonic@users.noreply.github.com>
@jimbotonic
jimbotonic merged commit bff8690 into main Aug 16, 2026
7 checks passed
@jimbotonic
jimbotonic deleted the feat/tcp-fallback-and-preflight branch August 16, 2026 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant