Skip to content

Commit b5eb53a

Browse files
committed
Fix tunnel key exchange stale cache, LAN dual-stack detection, and daemon trust flag
Three fixes for tunnel connectivity: - Invalidate cached Ed25519 pubkey on mismatch and re-fetch from registry before rejecting, fixing persistent key exchange failures after peer restart - Treat wildcard listen addresses (::, 0.0.0.0) as dual-stack in address family check, allowing LAN peer detection when tunnel binds to IPv6 wildcard - Expose trust-auto-approve flag on raw daemon binary (was only available via pilotctl daemon start) Also removes leftover tui entry from pilotctl help text.
1 parent 5eae9f6 commit b5eb53a

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

cmd/daemon/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func main() {
4646
webhookURL := flag.String("webhook", "", "HTTP(S) endpoint for event notifications (empty = disabled)")
4747
adminToken := flag.String("admin-token", "", "admin token for network operations")
4848
networks := flag.String("networks", "", "comma-separated network IDs to auto-join at startup")
49+
trustAutoApprove := flag.Bool("trust-auto-approve", false, "automatically approve all incoming trust handshakes")
4950
showVersion := flag.Bool("version", false, "print version and exit")
5051
logLevel := flag.String("log-level", "info", "log level (debug, info, warn, error)")
5152
logFormat := flag.String("log-format", "text", "log format (text, json)")
@@ -94,6 +95,7 @@ func main() {
9495
AdminToken: *adminToken,
9596
Networks: parseNetworkIDs(*networks),
9697
Version: version,
98+
TrustAutoApprove: *trustAutoApprove,
9799
})
98100

99101
if err := d.Start(); err != nil {

pkg/daemon/daemon.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ func (d *Daemon) addrFamilyMismatch(addr string) bool {
733733
if localIP == nil || remoteIP == nil {
734734
return false
735735
}
736+
// Wildcard addresses (:: or 0.0.0.0) are dual-stack — they accept both families.
737+
if localIP.IsUnspecified() {
738+
return false
739+
}
736740
localIs4 := localIP.To4() != nil
737741
remoteIs4 := remoteIP.To4() != nil
738742
return localIs4 != remoteIs4

pkg/daemon/tunnel.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,23 @@ func (tm *TunnelManager) handleAuthKeyExchange(data []byte, from *net.UDPAddr, f
488488
return
489489
}
490490

491-
// Verify the packet-provided Ed25519 pubkey matches the registry
491+
// Verify the packet-provided Ed25519 pubkey matches the registry.
492+
// On mismatch, invalidate cache and re-fetch — the peer may have restarted
493+
// with a new identity since we last cached their key.
492494
if !peerEd25519PubKey.Equal(expectedPubKey) {
493-
slog.Error("auth key exchange: Ed25519 pubkey mismatch with registry", "peer_node_id", peerNodeID)
494-
return
495+
tm.mu.Lock()
496+
delete(tm.peerPubKeys, peerNodeID)
497+
tm.mu.Unlock()
498+
expectedPubKey, err = tm.getPeerPubKey(peerNodeID)
499+
if err != nil || expectedPubKey == nil {
500+
slog.Warn("auth key exchange rejected: cannot re-verify peer identity", "peer_node_id", peerNodeID, "error", err)
501+
return
502+
}
503+
if !peerEd25519PubKey.Equal(expectedPubKey) {
504+
slog.Error("auth key exchange: Ed25519 pubkey mismatch with registry", "peer_node_id", peerNodeID)
505+
return
506+
}
507+
slog.Info("auth key exchange: peer pubkey updated from registry", "peer_node_id", peerNodeID)
495508
}
496509

497510
// Verify signature against the registry-verified key

0 commit comments

Comments
 (0)