From 20d12fe982b5bc3a4eb5df0d7028abb3b7dc89e8 Mon Sep 17 00:00:00 2001 From: IncSW Date: Fri, 28 Jan 2022 00:11:07 +0300 Subject: [PATCH] add new isp fields mobile_country_code and mobile_network_code --- anonymous_ip.go | 2 +- asn.go | 2 +- isp.go | 10 ++++++++++ traits.go | 10 ++++++++++ types.go | 4 ++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/anonymous_ip.go b/anonymous_ip.go index 0a43711..380a195 100644 --- a/anonymous_ip.go +++ b/anonymous_ip.go @@ -42,7 +42,7 @@ func readAnonymousIPMap(result *AnonymousIP, buffer []byte, mapSize uint, offset return 0, err } default: - return 0, errors.New("unknown isp key: " + string(key)) + return 0, errors.New("unknown anonymous ip key: " + string(key)) } } return offset, nil diff --git a/asn.go b/asn.go index f54aed6..a26adbe 100644 --- a/asn.go +++ b/asn.go @@ -22,7 +22,7 @@ func readASNMap(result *ASN, buffer []byte, mapSize uint, offset uint) (uint, er return 0, err } default: - return 0, errors.New("unknown isp key: " + string(key)) + return 0, errors.New("unknown asn key: " + string(key)) } } return offset, nil diff --git a/isp.go b/isp.go index bc3cfbd..c371742 100644 --- a/isp.go +++ b/isp.go @@ -31,6 +31,16 @@ func readISPMap(result *ISP, buffer []byte, mapSize uint, offset uint) (uint, er if err != nil { return 0, err } + case "mobile_country_code": + result.MobileCountryCode, offset, err = readString(buffer, offset) + if err != nil { + return 0, err + } + case "mobile_network_code": + result.MobileNetworkCode, offset, err = readString(buffer, offset) + if err != nil { + return 0, err + } default: return 0, errors.New("unknown isp key: " + string(key)) } diff --git a/traits.go b/traits.go index 9ad70f2..101272f 100644 --- a/traits.go +++ b/traits.go @@ -99,6 +99,16 @@ func readTraitsMap(traits *Traits, buffer []byte, mapSize uint, offset uint) (ui if err != nil { return 0, err } + case "mobile_country_code": + traits.MobileCountryCode, offset, err = readString(buffer, offset) + if err != nil { + return 0, err + } + case "mobile_network_code": + traits.MobileNetworkCode, offset, err = readString(buffer, offset) + if err != nil { + return 0, err + } default: return 0, errors.New("unknown traits key: " + string(key)) } diff --git a/types.go b/types.go index ff080a9..eda9e5b 100644 --- a/types.go +++ b/types.go @@ -72,6 +72,8 @@ type Traits struct { AutonomousSystemOrganization string // Enterprise AutonomousSystemNumber uint32 // Enterprise IsLegitimateProxy bool // Enterprise + MobileCountryCode string // Enterprise + MobileNetworkCode string // Enterprise IsAnonymousProxy bool IsSatelliteProvider bool } @@ -101,6 +103,8 @@ type ISP struct { AutonomousSystemOrganization string ISP string Organization string + MobileCountryCode string + MobileNetworkCode string } type ConnectionType struct {