This commit is contained in:
adman
2026-03-20 17:08:54 +01:00
parent b107eba37c
commit 43fea40d08
2 changed files with 18 additions and 29 deletions
+12 -6
View File
@@ -4,18 +4,24 @@ import "testing"
func TestDoDNS(t *testing.T) {
type Case struct {
Input string
Output string
Input string
Host string
portN uint16
}
for _, c := range []Case{{"localhost", "127.0.0.1:25565"}, {"1f2d.net", "50.114.4.126:25565"}} {
cases := []Case{
{"localhost", "localhost", 25565},
{"play.hypixel.net", "play.hypixel.net", 25565},
{"1f2d.net", "tcpshield.1f2d.net", 25565},
}
for _, c := range cases {
t.Logf("Testing %s", c.Input)
out, err := DoDns(c.Input)
_, host, portN, err := DoDns(c.Input)
if err != nil {
t.Error(err)
continue
}
if out != c.Output {
t.Errorf("Expected %s, got %s", c.Output, out)
if host != c.Host || portN != c.portN {
t.Errorf("expected %s:%d, got %s:%d", c.Host, c.portN, host, portN)
}
}
}