Skip to content

Portable Tool for an Ideal Windows Setup

add Chinese IP geolocation API endpoints

Greedeksc3dabbade697
diff --git a/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs b/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs
index 74b8f6e0..ef2caa9f 100644
--- a/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs
+++ b/.Source/GTweak/Utilities/Configuration/NetworkProvider.cs
@@ -35,11 +35,17 @@ namespace GTweak.Utilities.Configuration
{
if (!string.IsNullOrWhiteSpace(response))
{
- JObject jObject = JObject.Parse(response);
- string ip = jObject["ip"]?.ToString() ?? jObject["ipAddress"]?.ToString() ?? jObject["query"]?.ToString() ?? string.Empty;
- string country = jObject["country_code"]?.ToString() ?? jObject["countryCode"]?.ToString() ?? string.Empty;
- return new IPMetadata { Ip = ip, Country = country };
+ response = Regex.Match(response, @"\{.*\}", RegexOptions.Singleline).Value;
+ try
+ {
+ JObject jObject = JObject.Parse(response);
+ string ip = jObject["ip"]?.ToString() ?? jObject["ipAddress"]?.ToString() ?? jObject["query"]?.ToString() ?? string.Empty;
+ string country = jObject["country_code"]?.ToString() ?? jObject["countryCode"]?.ToString() ?? jObject["addr"]?.ToString() ?? string.Empty;
+ return new IPMetadata { Ip = ip, Country = country.Trim() };
+ }
+ catch (Exception ex) { ErrorLogging.LogDebug(ex); }
}
+
return new IPMetadata { Ip = string.Empty, Country = string.Empty };
}
}
diff --git a/.Source/GTweak/Utilities/Controls/PathLocator.cs b/.Source/GTweak/Utilities/Controls/PathLocator.cs
index 0cca5957..08033bd9 100644
--- a/.Source/GTweak/Utilities/Controls/PathLocator.cs
+++ b/.Source/GTweak/Utilities/Controls/PathLocator.cs
@@ -36,6 +36,8 @@ namespace GTweak.Utilities.Controls
"https://ipapi.co/json/",
"https://reallyfreegeoip.org/json/",
"https://get.geojs.io/v1/ip/geo.json",
+ "https://api.ip.sb/geoip",
+ "https://whois.pconline.com.cn/ipJson.jsp?json=true",
"http://ip-api.com/json/"
});