-
Notifications
You must be signed in to change notification settings - Fork 20
/
ripe.go
160 lines (136 loc) · 6.57 KB
/
ripe.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package ripego
// ripe struct
type ripe struct {
}
func RipeCheck(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, ripe_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")
wi.Status = parseRPSLValue(whoisData, "inetnum", "status")
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
}
func RipeCheck6(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, ripe_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.Created = parseRPSLValue(whoisData, "inet6num", "created")
wi.Descr = parseRPSLValue(whoisData, "inet6num", "descr")
wi.LastModified = parseRPSLValue(whoisData, "inet6num", "last-modified")
wi.MntBy = parseRPSLValue(whoisData, "inet6num", "mnt-by")
wi.MntLower = parseRPSLValue(whoisData, "inet6num", "mnt-lower")
wi.MntRoutes = parseRPSLValue(whoisData, "inetnum", "mnt-routes")
wi.Source = parseRPSLValue(whoisData, "inet6num", "source")
wi.TechC = parseRPSLValue(whoisData, "inet6num", "tech-c")
wi.Organization = parseRPSLValue(whoisData, "inet6num", "org")
wi.Status = parseRPSLValue(whoisData, "inet6num", "status")
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, "route6", "origin")
rt.Created = parseRPSLValue(whoisData, "route6", "created")
rt.Descr = parseRPSLValue(whoisData, "route6", "descr")
rt.LastModified = parseRPSLValue(whoisData, "route6", "last-modified")
rt.Route = parseRPSLValue(whoisData, "route6", "route6")
rt.Source = parseRPSLValue(whoisData, "route6", "source")
wi.Person = p
wi.Route = rt
return wi, err
}
func (r ripe) Check(search string) (w WhoisInfo, err error) {
whoisData, err := getTcpContent(search, ripe_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")
wi.Status = parseRPSLValue(whoisData, "inetnum", "status")
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 ripe) hasIP(ipaddr string) bool {
//http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
ips := []string{"2", "5", "25", "31", "37", "46", "51", "53", "57", "62",
"77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89",
"90", "91", "92", "93", "94", "95", "109", "141", "145", "151", "176", "178",
"185", "188", "193", "194", "195", "212", "213", "217"}
return isProviderIP(ipaddr, ips)
}