forked from IPQualityScore/GoIPQSDBReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IPQSRecord.go
137 lines (113 loc) · 2.08 KB
/
IPQSRecord.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
package GoIPQSDBReader
type IPQSRecord struct {
IsProxy bool
IsVPN bool
IsTOR bool
IsCrawler bool
IsBot bool
RecentAbuse bool
IsBlacklisted bool
IsPrivate bool
IsMobile bool
HasOpenPorts bool
IsHostingProvider bool
ActiveVPN bool
ActiveTOR bool
PublicAccessPoint bool
ConnectionType *ConnectionType
AbuseVelocity *AbuseVelocity
Country string
City string
Region string
ISP string
Organization string
ASN int
Timezone string
Latitude float32
Longitude float32
FraudScore *FraudScore
Columns []*Column
}
type ConnectionType struct {
Raw int
}
type AbuseVelocity struct {
Raw int
}
type FraudScore struct {
Strictness map[int]int
}
func (conn *ConnectionType) ToString() string {
switch conn.Raw {
case 1:
return "Residential"
case 2:
return "Mobile"
case 3:
return "Corporate"
case 4:
return "Data Center"
case 5:
return "Education"
default:
return "Unknown"
}
}
func (av *AbuseVelocity) ToString() string {
switch av.Raw {
case 1:
return "low"
case 2:
return "medium"
case 3:
return "high"
default:
return "none"
}
}
func (record *IPQSRecord) processFirstByte(b *BinaryOption) {
if b.Has(IsProxy) {
record.IsProxy = true
}
if b.Has(IsVPN) {
record.IsVPN = true
}
if b.Has(IsTOR) {
record.IsTOR = true
}
if b.Has(IsCrawler) {
record.IsCrawler = true
}
if b.Has(IsBot) {
record.IsBot = true
}
if b.Has(RecentAbuse) {
record.RecentAbuse = true
}
if b.Has(IsBlacklisted) {
record.IsBlacklisted = true
}
if b.Has(IsPrivate) {
record.IsPrivate = true
}
}
func (record *IPQSRecord) processSecondByte(b *BinaryOption) {
if b.Has(IsMobile) {
record.IsMobile = true
}
if b.Has(HasOpenPorts) {
record.HasOpenPorts = true
}
if b.Has(IsHostingProvider) {
record.IsHostingProvider = true
}
if b.Has(ActiveVPN) {
record.ActiveVPN = true
}
if b.Has(ActiveTOR) {
record.ActiveTOR = true
}
if b.Has(PublicAccessPoint) {
record.PublicAccessPoint = true
}
}