new: add warp fake packet delay, add warp detour, add new ipinfo api
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -76,6 +76,7 @@ jobs:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
if: matrix.platform != 'android-aab' || ${{ inputs.upload-artifact && inputs.tag-name != 'draft' }}
|
||||
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
@@ -291,7 +291,8 @@
|
||||
"warpLicenseKey": "License Key",
|
||||
"warpCleanIp": "Clean IP",
|
||||
"warpPort": "Port",
|
||||
"warpNoise": "Noise"
|
||||
"warpNoise": "Noise Count",
|
||||
"warpNoiseDelay": "Noise Delay"
|
||||
},
|
||||
"geoAssets": {
|
||||
"pageTitle": "Routing Assets",
|
||||
|
||||
@@ -77,7 +77,11 @@ class DioHttpClient with InfraLogger {
|
||||
url,
|
||||
path,
|
||||
cancelToken: cancelToken,
|
||||
options: _options(url, userAgent: userAgent, credentials: credentials),
|
||||
options: _options(
|
||||
url,
|
||||
userAgent: userAgent,
|
||||
credentials: credentials,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,6 +108,8 @@ class DioHttpClient with InfraLogger {
|
||||
headers: {
|
||||
if (userAgent != null) "User-Agent": userAgent,
|
||||
if (basicAuth != null) "authorization": basicAuth,
|
||||
// "Accept": "application/json",
|
||||
// "Content-Type": "application/json",
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,11 @@ class ConfigOptionEntity with _$ConfigOptionEntity {
|
||||
@Default("auto") String warpCleanIp,
|
||||
@Default(0) int warpPort,
|
||||
@OptionalRangeJsonConverter()
|
||||
@Default(OptionalRange())
|
||||
@Default(OptionalRange(min: 5, max: 10))
|
||||
OptionalRange warpNoise,
|
||||
@OptionalRangeJsonConverter()
|
||||
@Default(OptionalRange(min: 20, max: 200))
|
||||
OptionalRange warpNoiseDelay,
|
||||
@Default("") String warpWireguardConfig,
|
||||
}) = _ConfigOptionEntity;
|
||||
|
||||
@@ -141,6 +144,7 @@ class ConfigOptionEntity with _$ConfigOptionEntity {
|
||||
warpCleanIp: patch.warpCleanIp ?? warpCleanIp,
|
||||
warpPort: patch.warpPort ?? warpPort,
|
||||
warpNoise: patch.warpNoise ?? warpNoise,
|
||||
warpNoiseDelay: patch.warpNoiseDelay ?? warpNoiseDelay,
|
||||
warpWireguardConfig: patch.warpWireguardConfig ?? warpWireguardConfig,
|
||||
);
|
||||
}
|
||||
@@ -198,6 +202,7 @@ class ConfigOptionEntity with _$ConfigOptionEntity {
|
||||
cleanIp: warpCleanIp,
|
||||
cleanPort: warpPort,
|
||||
warpNoise: warpNoise,
|
||||
warpNoiseDelay: warpNoiseDelay,
|
||||
wireguardConfig: warpWireguardConfig,
|
||||
),
|
||||
);
|
||||
@@ -253,6 +258,7 @@ class ConfigOptionPatch with _$ConfigOptionPatch {
|
||||
String? warpCleanIp,
|
||||
int? warpPort,
|
||||
@OptionalRangeJsonConverter() OptionalRange? warpNoise,
|
||||
@OptionalRangeJsonConverter() OptionalRange? warpNoiseDelay,
|
||||
String? warpWireguardConfig,
|
||||
}) = _ConfigOptionPatch;
|
||||
|
||||
|
||||
@@ -172,6 +172,25 @@ class WarpOptionsTiles extends HookConsumerWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text(t.settings.config.warpNoiseDelay),
|
||||
subtitle: Text(options.warpNoiseDelay.present(t)),
|
||||
enabled: canChangeOptions,
|
||||
onTap: () async {
|
||||
final warpNoiseDelay = await SettingsInputDialog(
|
||||
title: t.settings.config.warpNoiseDelay,
|
||||
initialValue: options.warpNoiseDelay.format(),
|
||||
resetValue: defaultOptions.warpNoiseDelay.format(),
|
||||
).show(context);
|
||||
if (warpNoiseDelay == null) return;
|
||||
await onChange(
|
||||
ConfigOptionPatch(
|
||||
warpNoise:
|
||||
OptionalRange.tryParse(warpNoiseDelay, allowEmpty: true),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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"),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class SingboxWarpOption with _$SingboxWarpOption {
|
||||
required String cleanIp,
|
||||
required int cleanPort,
|
||||
@OptionalRangeJsonConverter() required OptionalRange warpNoise,
|
||||
@OptionalRangeJsonConverter() required OptionalRange warpNoiseDelay,
|
||||
}) = _SingboxWarpOption;
|
||||
|
||||
factory SingboxWarpOption.fromJson(Map<String, dynamic> json) =>
|
||||
|
||||
2
libcore
2
libcore
Submodule libcore updated: 298ca9b1b8...70157d1ac6
Reference in New Issue
Block a user