Skip to content

Fix config reverts, tunnel teardown, shutdown and key/config file safety - #10

Merged
dbpecka merged 1 commit into
mainfrom
claude/clever-ptolemy-he4pk7
Nov 4, 2026
Merged

dbpecka merged 1 commit into
mainfrom
claude/clever-ptolemy-he4pk7

Conversation

@dbpecka

@dbpecka dbpecka commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Config poll loop no longer rolls back the cluster: a config file at a lower
version than memory is stale (persisting failed, e.g. a read-only mount),
not a manual edit. It used to be re-broadcast at a higher version, undoing
every change cluster-wide within 10s. The file is now ignored with a
warning, and every config change persists under the dynamic_config lock so
the file is always written in version order.

proxy_bidirectional: the idle timeout now means no data in either
direction for 5 minutes; each direction used to time out on its own, so a
one-way stream (download, log tail) was cut at 5 minutes. EOF in one
direction now half-closes the other side and keeps the opposite direction
running, so a client that shuts down its write side still gets the reply.

Graceful shutdown runs on SIGTERM as well as SIGINT (docker stop, systemd,
Kubernetes). It used to exit at once on SIGTERM, or ignore it as PID 1,
with no NodeLeave and no drain.

The drain counts only work in progress: tunnels, mux streams, gossip and
admin requests, and subscriber client connections (TCP, HTTP, upgrades).
Idle pooled connections and mux sessions used to count, so every drain
waited the full 30s timeout. At shutdown idle connections are closed, HTTP
keep-alive connections finish their current request, new tunnels are
refused so subscribers retry another node, and NAT'd nodes stop their
reverse workers. Also fixes wait_zero missing the wakeup when the count
reached zero just before it waited.

ca.key and issued node.key are created 0600 (were 0644 under the default
umask, letting any local user mint certs); stouter warns at startup when an
existing key is readable by others.

Config::save writes a temp file and renames it over the config, so a
crash, kill or full disk can no longer leave a truncated file the daemon
can't start from. It follows symlinks, keeps mode and owner, and falls back
to an in-place write for single-file bind mounts and unwritable
directories.

Co-Authored-By: Claude Opus 5.5 [email protected]
Claude-Session: https://claude.ai/code/session_01Utzq7EMn2utxnXNNXDfLSL

Config poll loop no longer rolls back the cluster: a config file at a lower
version than memory is stale (persisting failed, e.g. a read-only mount),
not a manual edit. It used to be re-broadcast at a higher version, undoing
every change cluster-wide within 10s. The file is now ignored with a
warning, and every config change persists under the dynamic_config lock so
the file is always written in version order.

proxy_bidirectional: the idle timeout now means no data in either
direction for 5 minutes; each direction used to time out on its own, so a
one-way stream (download, log tail) was cut at 5 minutes. EOF in one
direction now half-closes the other side and keeps the opposite direction
running, so a client that shuts down its write side still gets the reply.

Graceful shutdown runs on SIGTERM as well as SIGINT (docker stop, systemd,
Kubernetes). It used to exit at once on SIGTERM, or ignore it as PID 1,
with no NodeLeave and no drain.

The drain counts only work in progress: tunnels, mux streams, gossip and
admin requests, and subscriber client connections (TCP, HTTP, upgrades).
Idle pooled connections and mux sessions used to count, so every drain
waited the full 30s timeout. At shutdown idle connections are closed, HTTP
keep-alive connections finish their current request, new tunnels are
refused so subscribers retry another node, and NAT'd nodes stop their
reverse workers. Also fixes wait_zero missing the wakeup when the count
reached zero just before it waited.

ca.key and issued node.key are created 0600 (were 0644 under the default
umask, letting any local user mint certs); stouter warns at startup when an
existing key is readable by others.

Config::save writes a temp file and renames it over the config, so a
crash, kill or full disk can no longer leave a truncated file the daemon
can't start from. It follows symlinks, keeps mode and owner, and falls back
to an in-place write for single-file bind mounts and unwritable
directories.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Utzq7EMn2utxnXNNXDfLSL
@dbpecka
dbpecka merged commit 7119f23 into main Nov 4, 2026
5 checks passed
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.

2 participants