new: add warp fake packet delay, add warp detour, add new ipinfo api

This commit is contained in:
Hiddify
2024-02-21 20:03:20 +01:00
parent 1fcd9cdbef
commit b16295bee5
9 changed files with 83 additions and 5 deletions

View File

@@ -121,6 +121,8 @@ class ProxyRepositoryImpl
final Map<String, IpInfo Function(Map<String, dynamic> response)>
_ipInfoSources = {
// "https://geolocation-db.com/json/": IpInfo.fromGeolocationDbComJson,
"https://api.ip.sb/geoip/": IpInfo.fromIpSbJson,
"https://ipapi.co/json/": IpInfo.fromIpApiCoJson,
"https://ipinfo.io/json/": IpInfo.fromIpInfoIoJson,
};

View File

@@ -67,4 +67,46 @@ class IpInfo with IpInfoMappable {
_ => throw const FormatException("invalid json"),
};
}
static IpInfo fromIpSbJson(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,
"asn_organization": final String org,
} =>
IpInfo(
ip: ip,
countryCode: countryCode,
region: region,
city: city,
timezone: timezone,
asn: '$asn',
org: org,
),
_ => throw const FormatException("invalid json"),
};
}
static IpInfo fromGeolocationDbComJson(Map<String, dynamic> json) {
return switch (json) {
{
"ip": final String ip,
"country_code": final String countryCode,
"state": final String region,
"city": final String city
} =>
IpInfo(
ip: ip,
countryCode: countryCode,
region: region,
city: city,
),
_ => throw const FormatException("invalid json"),
};
}
}