mirror of https://github.com/cbeuw/Cloak
Fix IP resolution in test
This commit is contained in:
parent
9800e3685d
commit
d06c208ace
|
|
@ -43,13 +43,22 @@ func TestParseRedirAddr(t *testing.T) {
|
||||||
t.Errorf("parsing %v error: %v", domainNoPort, err)
|
t.Errorf("parsing %v error: %v", domainNoPort, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expHost, err := net.ResolveIPAddr("ip", "example.com")
|
|
||||||
|
expIPs, err := net.LookupIP("example.com")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("tester error: cannot resolve example.com: %v", err)
|
t.Errorf("tester error: cannot resolve example.com: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if host.String() != expHost.String() {
|
|
||||||
t.Errorf("expected %v got %v", expHost.String(), host.String())
|
contain := false
|
||||||
|
for _, expIP := range expIPs {
|
||||||
|
if expIP.String() == host.String() {
|
||||||
|
contain = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !contain {
|
||||||
|
t.Errorf("expected one of %v got %v", expIPs, host.String())
|
||||||
}
|
}
|
||||||
if port != "" {
|
if port != "" {
|
||||||
t.Errorf("port not empty when there is no port")
|
t.Errorf("port not empty when there is no port")
|
||||||
|
|
@ -63,13 +72,22 @@ func TestParseRedirAddr(t *testing.T) {
|
||||||
t.Errorf("parsing %v error: %v", domainWPort, err)
|
t.Errorf("parsing %v error: %v", domainWPort, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
expHost, err := net.ResolveIPAddr("ip", "example.com")
|
|
||||||
|
expIPs, err := net.LookupIP("example.com")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("tester error: cannot resolve example.com: %v", err)
|
t.Errorf("tester error: cannot resolve example.com: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if host.String() != expHost.String() {
|
|
||||||
t.Errorf("expected %v got %v", expHost.String(), host.String())
|
contain := false
|
||||||
|
for _, expIP := range expIPs {
|
||||||
|
if expIP.String() == host.String() {
|
||||||
|
contain = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !contain {
|
||||||
|
t.Errorf("expected one of %v got %v", expIPs, host.String())
|
||||||
}
|
}
|
||||||
if port != "80" {
|
if port != "80" {
|
||||||
t.Errorf("wrong port: expected %v, got %v", "80", port)
|
t.Errorf("wrong port: expected %v, got %v", "80", port)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue