new: add ipwho.is

This commit is contained in:
Hiddify
2024-02-23 00:24:04 +01:00
parent 7aa94be6cb
commit b1803948e6
4 changed files with 27 additions and 2 deletions

View File

@@ -1 +1 @@
core.version=0.16.1 core.version=0.16.4

View File

@@ -127,6 +127,7 @@ class ProxyRepositoryImpl
final Map<String, IpInfo Function(Map<String, dynamic> response)> final Map<String, IpInfo Function(Map<String, dynamic> response)>
_ipInfoSources = { _ipInfoSources = {
// "https://geolocation-db.com/json/": IpInfo.fromGeolocationDbComJson, //bug response is not json // "https://geolocation-db.com/json/": IpInfo.fromGeolocationDbComJson, //bug response is not json
"https://ipwho.is/": IpInfo.fromIpwhoIsJson,
"https://api.ip.sb/geoip/": IpInfo.fromIpSbJson, "https://api.ip.sb/geoip/": IpInfo.fromIpSbJson,
"https://ipapi.co/json/": IpInfo.fromIpApiCoJson, "https://ipapi.co/json/": IpInfo.fromIpApiCoJson,
"https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson, "https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson,

View File

@@ -92,6 +92,30 @@ class IpInfo with IpInfoMappable {
}; };
} }
static IpInfo fromIpwhoIsJson(Map<String, dynamic> json) {
return switch (json) {
{
"ip": final String ip,
"country_code": final String countryCode,
// "region": final String region,
// "city": final String city,
// "timezone": final String timezone,
// "asn": final int asn,
"connection": final Map<String, dynamic> connection,
} =>
IpInfo(
ip: ip,
countryCode: countryCode,
// region: region,
// city: city,
// timezone: timezone,
asn: '$connection["asn"]',
org: '$connection["org"]',
),
_ => throw const FormatException("invalid json"),
};
}
static IpInfo fromGeolocationDbComJson(Map<String, dynamic> json) { static IpInfo fromGeolocationDbComJson(Map<String, dynamic> json) {
return switch (json) { return switch (json) {
{ {

Submodule libcore updated: 48297a74ae...4dad3022f3