mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-05 15:23:33 +00:00
https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5899791359 https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5901287980 https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5903680113 https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5904123488 https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5904647772 https://github.com/XTLS/Xray-core/pull/6853#issuecomment-5905047424 Fixes https://github.com/XTLS/Xray-core/issues/6454#issuecomment-5863800676 --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
772 B
Go
28 lines
772 B
Go
package internet_test
|
|
|
|
import (
|
|
"net/netip"
|
|
"testing"
|
|
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
)
|
|
|
|
func TestSkipDNSServers(t *testing.T) {
|
|
internet.SkipDNSServers([]netip.Addr{netip.MustParseAddr("::ffff:203.0.113.53"), netip.MustParseAddr("2001:db8::53")})
|
|
t.Cleanup(func() { internet.SkipDNSServers(nil) })
|
|
for address, want := range map[string]bool{
|
|
"203.0.113.53:53": true,
|
|
"[2001:db8::53]:53": true,
|
|
"198.51.100.53:53": false,
|
|
"localhost:53": false,
|
|
} {
|
|
if got := internet.IsSkippedDNSServer(address); got != want {
|
|
t.Errorf("IsSkippedDNSServer(%q) = %v, want %v", address, got, want)
|
|
}
|
|
}
|
|
internet.SkipDNSServers(nil)
|
|
if internet.IsSkippedDNSServer("203.0.113.53:53") {
|
|
t.Error("still skipped after SkipDNSServers(nil)")
|
|
}
|
|
}
|