-
Notifications
You must be signed in to change notification settings - Fork 12
/
anonymous_ip.go
49 lines (47 loc) · 1.2 KB
/
anonymous_ip.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
package geoip2
import "errors"
func readAnonymousIPMap(result *AnonymousIP, buffer []byte, mapSize uint, offset uint) (uint, error) {
var key []byte
var err error
for i := uint(0); i < mapSize; i++ {
key, offset, err = readMapKey(buffer, offset)
if err != nil {
return 0, err
}
switch b2s(key) {
case "is_anonymous":
result.IsAnonymous, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
case "is_anonymous_vpn":
result.IsAnonymousVPN, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
case "is_hosting_provider":
result.IsHostingProvider, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
case "is_public_proxy":
result.IsPublicProxy, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
case "is_tor_exit_node":
result.IsTorExitNode, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
case "is_residential_proxy":
result.IsResidentialProxy, offset, err = readBool(buffer, offset)
if err != nil {
return 0, err
}
default:
return 0, errors.New("unknown anonymous ip key: " + string(key))
}
}
return offset, nil
}