Repository navigation
Conversation
/readyz only looked at CheckAlive pings, so it always returned 200 without CheckAlive even if the tunnel was dead. The published image is distroless, so a container health check cannot use curl or wget either. Add an optional [Interface] MaxHandshakeAge (seconds, disabled by default). When set, /readyz also returns 503 if any peer's last handshake is older than that or has never happened, and lists each peer's last handshake time in the response body under "handshake:<public key>". Add -H/--healthcheck <address>, which requests /readyz from the --info address without loading a configuration and exits 0 on a 200 and 1 otherwise, so it can be used as the HEALTHCHECK command of the image. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A peer configured without an Endpoint only answers handshakes and has never connected, so it never gets a last handshake time. Counting it as "never handshook" kept /readyz at 503 forever for configs that mix initiating and responder-only peers. Track the endpoint line per peer in the IPC output and drop peers without one from both the staleness check and the reported records. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The MaxHandshakeAge tests only covered stale and never-handshaked peers. Bring up two wireguard devices over loopback and assert the initiator's /readyz turns 200, with a non-zero handshake time, once they handshake. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
wireguard-go also reports an "endpoint=" line for endpoints learned from incoming packets, so a responder-only peer that connected once and went idle was counted again and kept /readyz at 503. Skip peers that have no Endpoint in the configuration instead, matching them by public key (the IPC uses hex, the configuration hex or base64). Skipped peers stay in the /readyz body, with a "handshake_skipped:<public key>": 1 entry, and are only left out of the staleness verdict. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MaxHandshakeAge([Interface], seconds, off by default):/readyzalso returns 503 when any peer's last handshake is older than that, or a peer has never completed one. It works withoutCheckAlive, so a stale tunnel is detected without sending pings. Each peer's last handshake time is added to the response body. Peers with noEndpointin the config only answer handshakes, so they are skipped (listed ashandshake_skipped:<key>), even after they connect once and gain a learned endpoint.-H/--healthcheck <addr:port>: requests/readyzfrom the--infoendpoint and exits 0 if healthy, 1 otherwise. That gives distroless/scratch images a containerHEALTHCHECKwithout curl.README documents both, and notes that idle peers need
PersistentKeepalivefor the handshake age to stay fresh.This PR may conflict with the endpoint re-resolve PR in
config.goand README (adjacent[Interface]keys). Happy to rebase.Test plan
go test -race ./...,go vet ./...,gofmt -l ., golangci-lint (fork CI green).-Hclient.🤖 Generated with Claude Code