-
Notifications
You must be signed in to change notification settings - Fork 20
/
apnic.go
124 lines (103 loc) · 4.83 KB
/
apnic.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package ripego
type apnic struct {
}
func ApnicCheck(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, apnic_whois_server)
if err != nil {
return w, err
}
wi := WhoisInfo{}
wi.Inetnum = parseRPSLValue(whoisData, "inetnum", "inetnum")
wi.Netname = parseRPSLValue(whoisData, "inetnum", "netname")
wi.AdminC = parseRPSLValue(whoisData, "inetnum", "admin-c")
wi.Country = parseRPSLValue(whoisData, "inetnum", "country")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inetnum", "changed")
wi.MntBy = parseRPSLValue(whoisData, "inetnum", "mnt-by")
wi.MntLower = parseRPSLValue(whoisData, "inetnum", "mnt-lower")
wi.MntRoutes = parseRPSLValue(whoisData, "inetnum", "mnt-routes")
wi.Source = parseRPSLValue(whoisData, "inetnum", "source")
wi.TechC = parseRPSLValue(whoisData, "inetnum", "tech-c")
wi.Organization = parseRPSLValue(whoisData, "irt", "irt")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "role", "role")
p.AbuseMailbox = parseRPSLValue(whoisData, "irt", "abuse-mailbox")
p.Address = parseRPSLValue(whoisData, "role", "address")
p.LastModified = parseRPSLValue(whoisData, "role", "changed")
p.MntBy = parseRPSLValue(whoisData, "role", "mnt-by")
p.NicHdl = parseRPSLValue(whoisData, "role", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "role", "phone")
p.Source = parseRPSLValue(whoisData, "role", "source")
wi.Person = p
return wi, err
}
func ApnicCheck6(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, apnic_whois_server)
if err != nil {
return w, err
}
wi := WhoisInfo{}
wi.Inetnum = parseRPSLValue(whoisData, "inet6num", "inet6num")
wi.Netname = parseRPSLValue(whoisData, "inet6num", "netname")
wi.AdminC = parseRPSLValue(whoisData, "inet6num", "admin-c")
wi.Country = parseRPSLValue(whoisData, "inet6num", "country")
wi.Descr = parseRPSLValue(whoisData, "inet6num", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inet6num", "changed")
wi.MntBy = parseRPSLValue(whoisData, "inet6num", "mnt-by")
wi.MntLower = parseRPSLValue(whoisData, "inet6num", "mnt-lower")
wi.MntRoutes = parseRPSLValue(whoisData, "inet6num", "mnt-routes")
wi.Source = parseRPSLValue(whoisData, "inet6num", "source")
wi.TechC = parseRPSLValue(whoisData, "inet6num", "tech-c")
wi.Organization = parseRPSLValue(whoisData, "irt", "irt")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "role", "role")
p.AbuseMailbox = parseRPSLValue(whoisData, "irt", "abuse-mailbox")
p.Address = parseRPSLValue(whoisData, "role", "address")
p.LastModified = parseRPSLValue(whoisData, "role", "changed")
p.MntBy = parseRPSLValue(whoisData, "role", "mnt-by")
p.NicHdl = parseRPSLValue(whoisData, "role", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "role", "phone")
p.Source = parseRPSLValue(whoisData, "role", "source")
wi.Person = p
return wi, err
}
func (r apnic) Check(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, apnic_whois_server)
if err != nil {
return w, err
}
wi := WhoisInfo{}
wi.Inetnum = parseRPSLValue(whoisData, "inetnum", "inetnum")
wi.Netname = parseRPSLValue(whoisData, "inetnum", "netname")
wi.AdminC = parseRPSLValue(whoisData, "inetnum", "admin-c")
wi.Country = parseRPSLValue(whoisData, "inetnum", "country")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inetnum", "changed")
wi.MntBy = parseRPSLValue(whoisData, "inetnum", "mnt-by")
wi.MntLower = parseRPSLValue(whoisData, "inetnum", "mnt-lower")
wi.MntRoutes = parseRPSLValue(whoisData, "inetnum", "mnt-routes")
wi.Source = parseRPSLValue(whoisData, "inetnum", "source")
wi.TechC = parseRPSLValue(whoisData, "inetnum", "tech-c")
wi.Organization = parseRPSLValue(whoisData, "irt", "irt")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "role", "role")
p.AbuseMailbox = parseRPSLValue(whoisData, "irt", "abuse-mailbox")
p.Address = parseRPSLValue(whoisData, "role", "address")
p.LastModified = parseRPSLValue(whoisData, "role", "changed")
p.MntBy = parseRPSLValue(whoisData, "role", "mnt-by")
p.NicHdl = parseRPSLValue(whoisData, "role", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "role", "phone")
p.Source = parseRPSLValue(whoisData, "role", "source")
wi.Person = p
return wi, err
}
// hasIP function for derterming the right provider
func (r apnic) hasIP(ipaddr string) bool {
//http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
ips := []string{"1", "14", "27", "36", "39", "42", "49", "49", "58", "59",
"60", "61", "101", "103", "106", "110", "111", "112", "113", "114",
"115", "116", "117", "118", "119", "120", "121", "122", "123", "124",
"125", "126", "133", "150", "153", "163", "171", "175", "180", "182", "183",
"202", "203", "210", "211", "218", "219", "220", "221", "222", "223"}
return isProviderIP(ipaddr, ips)
}