-
Notifications
You must be signed in to change notification settings - Fork 20
/
afrinic.go
107 lines (91 loc) · 4.25 KB
/
afrinic.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
package ripego
type afrinic struct {
}
// AfrinicCheck function
func AfrinicCheck(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, afrinic_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.Created = parseRPSLValue(whoisData, "inetnum", "created")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inetnum", "last-modified")
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, "inetnum", "org")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "person", "person")
p.AbuseMailbox = parseRPSLValue(whoisData, "person", "abuse-mailbox")
p.Address = parseRPSLValue(whoisData, "person", "address")
p.Created = parseRPSLValue(whoisData, "person", "created")
p.LastModified = parseRPSLValue(whoisData, "person", "last-modified")
p.MntBy = parseRPSLValue(whoisData, "person", "mnt-by")
p.NicHdl = parseRPSLValue(whoisData, "person", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "person", "phone")
p.Source = parseRPSLValue(whoisData, "person", "source")
rt := WhoisRoute{}
rt.Origin = parseRPSLValue(whoisData, "route", "origin")
rt.Created = parseRPSLValue(whoisData, "route", "created")
rt.Descr = parseRPSLValue(whoisData, "route", "descr")
rt.LastModified = parseRPSLValue(whoisData, "route", "last-modified")
rt.Route = parseRPSLValue(whoisData, "route", "route")
rt.Source = parseRPSLValue(whoisData, "route", "source")
wi.Person = p
wi.Route = rt
return wi, err
}
// Check function (original)
func (r afrinic) Check(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, afrinic_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.Created = parseRPSLValue(whoisData, "inetnum", "created")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inetnum", "last-modified")
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, "inetnum", "org")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "person", "person")
p.AbuseMailbox = parseRPSLValue(whoisData, "person", "abuse-mailbox")
p.Address = parseRPSLValue(whoisData, "person", "address")
p.Created = parseRPSLValue(whoisData, "person", "created")
p.LastModified = parseRPSLValue(whoisData, "person", "last-modified")
p.MntBy = parseRPSLValue(whoisData, "person", "mnt-by")
p.NicHdl = parseRPSLValue(whoisData, "person", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "person", "phone")
p.Source = parseRPSLValue(whoisData, "person", "source")
rt := WhoisRoute{}
rt.Origin = parseRPSLValue(whoisData, "route", "origin")
rt.Created = parseRPSLValue(whoisData, "route", "created")
rt.Descr = parseRPSLValue(whoisData, "route", "descr")
rt.LastModified = parseRPSLValue(whoisData, "route", "last-modified")
rt.Route = parseRPSLValue(whoisData, "route", "route")
rt.Source = parseRPSLValue(whoisData, "route", "source")
wi.Person = p
wi.Route = rt
return wi, err
}
// hasIP function for derterming the right provider
func (r afrinic) hasIP(ipaddr string) bool {
//http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
ips := []string{"41", "102", "105", "154", "196", "197"}
return isProviderIP(ipaddr, ips)
}