-
Notifications
You must be signed in to change notification settings - Fork 20
/
lacnic.go
84 lines (69 loc) · 3.19 KB
/
lacnic.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
package ripego
type lacnic struct {
}
func LacnicCheck(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, lacnic_whois_server)
if err != nil {
return w, err
}
wi := WhoisInfo{}
wi.Inetnum = parseRPSLValue(whoisData, "inetnum", "inetnum")
wi.Status = parseRPSLValue(whoisData, "inetnum", "status")
wi.Netname = parseRPSLValue(whoisData, "inetnum", "ownerid")
wi.AdminC = parseRPSLValue(whoisData, "inetnum", "owner-c")
wi.Country = parseRPSLValue(whoisData, "inetnum", "country")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "owner")
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, "inetnum", "owner")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "nic-hdl", "nic-hdl")
p.AbuseMailbox = parseRPSLValue(whoisData, "nic-hdl", "e-mail")
p.Address = parseRPSLValue(whoisData, "nic-hdl", "address")
p.LastModified = parseRPSLValue(whoisData, "nic-hdl", "changed")
p.NicHdl = parseRPSLValue(whoisData, "role", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "role", "phone")
p.Source = parseRPSLValue(whoisData, "p.Co", "source")
wi.Person = p
return wi, err
}
func (r lacnic) Check(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, lacnic_whois_server)
if err != nil {
return w, err
}
wi := WhoisInfo{}
wi.Inetnum = parseRPSLValue(whoisData, "inetnum", "inetnum")
wi.Status = parseRPSLValue(whoisData, "inetnum", "status")
wi.Netname = parseRPSLValue(whoisData, "inetnum", "ownerid")
wi.AdminC = parseRPSLValue(whoisData, "inetnum", "owner-c")
wi.Country = parseRPSLValue(whoisData, "inetnum", "country")
wi.Descr = parseRPSLValue(whoisData, "inetnum", "owner")
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, "inetnum", "owner")
p := WhoisPerson{}
p.Name = parseRPSLValue(whoisData, "nic-hdl", "nic-hdl")
p.AbuseMailbox = parseRPSLValue(whoisData, "nic-hdl", "e-mail")
p.Address = parseRPSLValue(whoisData, "nic-hdl", "address")
p.LastModified = parseRPSLValue(whoisData, "nic-hdl", "changed")
p.NicHdl = parseRPSLValue(whoisData, "role", "nic-hdl")
p.Phone = parseRPSLValue(whoisData, "role", "phone")
p.Source = parseRPSLValue(whoisData, "p.Co", "source")
wi.Person = p
return wi, err
}
// hasIP function for derterming the right provider
func (r lacnic) hasIP(ipaddr string) bool {
//http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
ips := []string{"177", "179", "181", "186", "187", "189", "190", "191", "200", "201"}
return isProviderIP(ipaddr, ips)
}