fix(dns): handle empty and invalid IP addresses gracefully

Add guard checks to prevent panics when processing client info with
empty IP addresses. Replace netip.MustParseAddr with ParseAddr to
handle invalid IP addresses gracefully instead of panicking.

Add test to verify queryFromSelf handles IP addresses safely.
This commit is contained in:
Cuong Manh Le
2026-01-26 16:56:46 +07:00
committed by Cuong Manh Le
parent acbebcf7c2
commit 209c9211b9
2 changed files with 22 additions and 2 deletions
+10
View File
@@ -464,3 +464,13 @@ func Test_isWanClient(t *testing.T) {
})
}
}
func Test_prog_queryFromSelf(t *testing.T) {
p := &prog{}
require.NotPanics(t, func() {
p.queryFromSelf("")
})
require.NotPanics(t, func() {
p.queryFromSelf("foo")
})
}