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

@@ -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) {
return switch (json) {
{