forked from netheril96/MEOW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
directip_test.go
51 lines (39 loc) · 809 Bytes
/
directip_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"net"
"testing"
)
func TestIPShouldDirect(t *testing.T) {
initCNIPData()
blockedIPDomains := []string{
"gist.github.com",
"twitter.com",
}
for _, domain := range blockedIPDomains {
hostIPs, err := net.LookupIP(domain)
if err != nil {
continue
}
var ip string
ip = hostIPs[0].String()
if ipShouldDirect(ip) {
t.Errorf("ip %s should be considered using proxy, domain: %s", ip, domain)
}
}
directIPDomains := []string{
"baidu.com",
"www.ahut.edu.cn",
"bt.byr.cn",
}
for _, domain := range directIPDomains {
hostIPs, err := net.LookupIP(domain)
if err != nil {
continue
}
var ip string
ip = hostIPs[0].String()
if !ipShouldDirect(ip) {
t.Errorf("ip %s should be considered using direct, domain: %s", ip, domain)
}
}
}