|
@@ -27,6 +27,7 @@ import (
|
|
|
"net"
|
|
"net"
|
|
|
"os"
|
|
"os"
|
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
|
|
+ "strconv"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common"
|
|
"github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common"
|
|
@@ -50,6 +51,7 @@ type GeoIPData struct {
|
|
|
Country string
|
|
Country string
|
|
|
City string
|
|
City string
|
|
|
ISP string
|
|
ISP string
|
|
|
|
|
+ ASN string
|
|
|
DiscoveryValue int
|
|
DiscoveryValue int
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -60,6 +62,7 @@ func NewGeoIPData() GeoIPData {
|
|
|
Country: GEOIP_UNKNOWN_VALUE,
|
|
Country: GEOIP_UNKNOWN_VALUE,
|
|
|
City: GEOIP_UNKNOWN_VALUE,
|
|
City: GEOIP_UNKNOWN_VALUE,
|
|
|
ISP: GEOIP_UNKNOWN_VALUE,
|
|
ISP: GEOIP_UNKNOWN_VALUE,
|
|
|
|
|
+ ASN: GEOIP_UNKNOWN_VALUE,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -195,8 +198,11 @@ func (geoIP *GeoIPService) Lookup(ipAddress string) GeoIPData {
|
|
|
Names map[string]string `maxminddb:"names"`
|
|
Names map[string]string `maxminddb:"names"`
|
|
|
} `maxminddb:"city"`
|
|
} `maxminddb:"city"`
|
|
|
ISP string `maxminddb:"isp"`
|
|
ISP string `maxminddb:"isp"`
|
|
|
|
|
+ ASN int `maxminddb:"autonomous_system_number"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ geoIPFields.ASN = -1
|
|
|
|
|
+
|
|
|
// Each database will populate geoIPFields with the values it contains. In the
|
|
// Each database will populate geoIPFields with the values it contains. In the
|
|
|
// current MaxMind deployment, the City database populates Country and City and
|
|
// current MaxMind deployment, the City database populates Country and City and
|
|
|
// the separate ISP database populates ISP.
|
|
// the separate ISP database populates ISP.
|
|
@@ -222,6 +228,10 @@ func (geoIP *GeoIPService) Lookup(ipAddress string) GeoIPData {
|
|
|
result.ISP = geoIPFields.ISP
|
|
result.ISP = geoIPFields.ISP
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if geoIPFields.ASN != -1 {
|
|
|
|
|
+ result.ASN = strconv.Itoa(geoIPFields.ASN)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
result.DiscoveryValue = calculateDiscoveryValue(
|
|
result.DiscoveryValue = calculateDiscoveryValue(
|
|
|
geoIP.discoveryValueHMACKey, ipAddress)
|
|
geoIP.discoveryValueHMACKey, ipAddress)
|
|
|
|
|
|