[management] Fix DNS peer IP corruption to ::1 during migration#5477
[management] Fix DNS peer IP corruption to ::1 during migration#5477John-Dixon-IV wants to merge 1 commit intonetbirdio:mainfrom
Conversation
The blob-to-JSON migration for peer IPs silently fell back to net.IPv6loopback (::1) when parsing failed, permanently corrupting the peer's IP in the database. This caused peers to lose their DNS records (miekg/dns rejects ::1 in A records), breaking Windows mapped drives that depend on DNS resolution. Replace the silent fallback with an error return so invalid data is caught at migration time. Also add IP validation in GetPeersCustomZone as defense-in-depth, skipping peers with nil, IPv6, loopback, or unspecified IPs instead of generating invalid A records.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChanges add stricter validation for IP addresses in two contexts: during database migration to detect and report invalid IP blob data, and in DNS zone generation to filter out invalid peer IPs (non-IPv4, loopback, nil, or unspecified). Migration failures now return explicit errors instead of falling back to defaults. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|



Summary
net.IPv6loopback(::1) when parsing failed, permanently corrupting the peer's IP in the database. Replaced with an error return so invalid data is caught at migration time.GetPeersCustomZone— peers with nil, IPv6, loopback, or unspecified IPs are now skipped with a logged error instead of generating invalid A records thatmiekg/dnssilently rejects.Impact
Peers with corrupted IPs (e.g. from failed blob migration on hosts with IPv6 disabled) would lose their DNS records entirely. On Windows clients, this broke mapped drives because Windows would fall through to upstream DNS and prefer IPv6 loopback over the correct WireGuard IP.
Test plan
TestMigrateNetIPFieldFromBlobToJSON_WithInvalidBlobData— verifies migration fails on corrupt IP blobs instead of silently using::1TestGetPeersCustomZone_InvalidIPs— verifies peers with nil/IPv6/loopback/unspecified IPs are skippedSummary by CodeRabbit
Bug Fixes
Tests