Skip to content

Commit 20d12fe

Browse files
committed
add new isp fields mobile_country_code and mobile_network_code
1 parent 2d2cad6 commit 20d12fe

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

anonymous_ip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func readAnonymousIPMap(result *AnonymousIP, buffer []byte, mapSize uint, offset
4242
return 0, err
4343
}
4444
default:
45-
return 0, errors.New("unknown isp key: " + string(key))
45+
return 0, errors.New("unknown anonymous ip key: " + string(key))
4646
}
4747
}
4848
return offset, nil

asn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func readASNMap(result *ASN, buffer []byte, mapSize uint, offset uint) (uint, er
2222
return 0, err
2323
}
2424
default:
25-
return 0, errors.New("unknown isp key: " + string(key))
25+
return 0, errors.New("unknown asn key: " + string(key))
2626
}
2727
}
2828
return offset, nil

isp.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ func readISPMap(result *ISP, buffer []byte, mapSize uint, offset uint) (uint, er
3131
if err != nil {
3232
return 0, err
3333
}
34+
case "mobile_country_code":
35+
result.MobileCountryCode, offset, err = readString(buffer, offset)
36+
if err != nil {
37+
return 0, err
38+
}
39+
case "mobile_network_code":
40+
result.MobileNetworkCode, offset, err = readString(buffer, offset)
41+
if err != nil {
42+
return 0, err
43+
}
3444
default:
3545
return 0, errors.New("unknown isp key: " + string(key))
3646
}

traits.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ func readTraitsMap(traits *Traits, buffer []byte, mapSize uint, offset uint) (ui
9999
if err != nil {
100100
return 0, err
101101
}
102+
case "mobile_country_code":
103+
traits.MobileCountryCode, offset, err = readString(buffer, offset)
104+
if err != nil {
105+
return 0, err
106+
}
107+
case "mobile_network_code":
108+
traits.MobileNetworkCode, offset, err = readString(buffer, offset)
109+
if err != nil {
110+
return 0, err
111+
}
102112
default:
103113
return 0, errors.New("unknown traits key: " + string(key))
104114
}

types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ type Traits struct {
7272
AutonomousSystemOrganization string // Enterprise
7373
AutonomousSystemNumber uint32 // Enterprise
7474
IsLegitimateProxy bool // Enterprise
75+
MobileCountryCode string // Enterprise
76+
MobileNetworkCode string // Enterprise
7577
IsAnonymousProxy bool
7678
IsSatelliteProvider bool
7779
}
@@ -101,6 +103,8 @@ type ISP struct {
101103
AutonomousSystemOrganization string
102104
ISP string
103105
Organization string
106+
MobileCountryCode string
107+
MobileNetworkCode string
104108
}
105109

106110
type ConnectionType struct {

0 commit comments

Comments
 (0)