Compare commits
1 Commits
v0.8.88-pr
...
v0.8.86-pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d798628fcf |
@@ -104,7 +104,7 @@ fun ConnectivityManager.resolveDns(network: Network?): List<String> {
|
|||||||
fun InetAddress.asSocketAddressText(port: Int): String {
|
fun InetAddress.asSocketAddressText(port: Int): String {
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is Inet6Address ->
|
is Inet6Address ->
|
||||||
"[${numericToTextFormat(this.address)}]:$port"
|
"[${numericToTextFormat(this)}]:$port"
|
||||||
|
|
||||||
is Inet4Address ->
|
is Inet4Address ->
|
||||||
"${this.hostAddress}:$port"
|
"${this.hostAddress}:$port"
|
||||||
@@ -141,7 +141,8 @@ fun Context.getActionPendingIntent(action: String): PendingIntent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun numericToTextFormat(src: ByteArray): String {
|
private fun numericToTextFormat(address: Inet6Address): String {
|
||||||
|
val src = address.address
|
||||||
val sb = StringBuilder(39)
|
val sb = StringBuilder(39)
|
||||||
for (i in 0 until 8) {
|
for (i in 0 until 8) {
|
||||||
sb.append(
|
sb.append(
|
||||||
@@ -154,6 +155,10 @@ private fun numericToTextFormat(src: ByteArray): String {
|
|||||||
sb.append(":")
|
sb.append(":")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (address.scopeId > 0) {
|
||||||
|
sb.append("%")
|
||||||
|
sb.append(address.scopeId)
|
||||||
|
}
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ data object VpnPlugin : FlutterPlugin, MethodChannel.MethodCallHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun handleStart(options: VpnOptions): Boolean {
|
fun handleStart(options: VpnOptions): Boolean {
|
||||||
|
onUpdateNetwork();
|
||||||
if (options.enable != this.options?.enable) {
|
if (options.enable != this.options?.enable) {
|
||||||
this.flClashService = null
|
this.flClashService = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ Future<void> _service(List<String> flags) async {
|
|||||||
vpn?.addListener(
|
vpn?.addListener(
|
||||||
_VpnListenerWithService(
|
_VpnListenerWithService(
|
||||||
onDnsChanged: (String dns) {
|
onDnsChanged: (String dns) {
|
||||||
|
print("handle dns $dns");
|
||||||
clashLibHandler.updateDns(dns);
|
clashLibHandler.updateDns(dns);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -200,6 +200,24 @@ class Tun with _$Tun {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension TunExt on Tun {
|
||||||
|
Tun getRealTun(RouteMode routeMode) {
|
||||||
|
final mRouteAddress = routeMode == RouteMode.bypassPrivate
|
||||||
|
? defaultBypassPrivateRouteAddress
|
||||||
|
: routeAddress;
|
||||||
|
return switch (system.isDesktop) {
|
||||||
|
true => copyWith(
|
||||||
|
autoRoute: true,
|
||||||
|
routeAddress: [],
|
||||||
|
),
|
||||||
|
false => copyWith(
|
||||||
|
autoRoute: mRouteAddress.isEmpty ? true : false,
|
||||||
|
routeAddress: mRouteAddress,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class FallbackFilter with _$FallbackFilter {
|
class FallbackFilter with _$FallbackFilter {
|
||||||
const factory FallbackFilter({
|
const factory FallbackFilter({
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ final coreStateProvider = AutoDisposeProvider<CoreState>.internal(
|
|||||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
typedef CoreStateRef = AutoDisposeProviderRef<CoreState>;
|
typedef CoreStateRef = AutoDisposeProviderRef<CoreState>;
|
||||||
String _$updateParamsHash() => r'79fd7a5a8650fabac3a2ca7ce903c1d9eb363ed2';
|
String _$updateParamsHash() => r'012df72ab0e769a51c573f4692031506d7b1f1b4';
|
||||||
|
|
||||||
/// See also [updateParams].
|
/// See also [updateParams].
|
||||||
@ProviderFor(updateParams)
|
@ProviderFor(updateParams)
|
||||||
@@ -126,7 +126,7 @@ final proxyStateProvider = AutoDisposeProvider<ProxyState>.internal(
|
|||||||
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
@Deprecated('Will be removed in 3.0. Use Ref instead')
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
typedef ProxyStateRef = AutoDisposeProviderRef<ProxyState>;
|
typedef ProxyStateRef = AutoDisposeProviderRef<ProxyState>;
|
||||||
String _$trayStateHash() => r'39ff84c50ad9c9cc666fa2538fe13ec0d7236b2e';
|
String _$trayStateHash() => r'61c99bbae2cb7ed69dc9ee0f2149510eb6a87df4';
|
||||||
|
|
||||||
/// See also [trayState].
|
/// See also [trayState].
|
||||||
@ProviderFor(trayState)
|
@ProviderFor(trayState)
|
||||||
|
|||||||
@@ -105,10 +105,15 @@ CoreState coreState(Ref ref) {
|
|||||||
|
|
||||||
@riverpod
|
@riverpod
|
||||||
UpdateParams updateParams(Ref ref) {
|
UpdateParams updateParams(Ref ref) {
|
||||||
|
final routeMode = ref.watch(
|
||||||
|
networkSettingProvider.select(
|
||||||
|
(state) => state.routeMode,
|
||||||
|
),
|
||||||
|
);
|
||||||
return ref.watch(
|
return ref.watch(
|
||||||
patchClashConfigProvider.select(
|
patchClashConfigProvider.select(
|
||||||
(state) => UpdateParams(
|
(state) => UpdateParams(
|
||||||
tun: state.tun,
|
tun: state.tun.getRealTun(routeMode),
|
||||||
allowLan: state.allowLan,
|
allowLan: state.allowLan,
|
||||||
findProcessMode: state.findProcessMode,
|
findProcessMode: state.findProcessMode,
|
||||||
mode: state.mode,
|
mode: state.mode,
|
||||||
@@ -153,9 +158,11 @@ TrayState trayState(Ref ref) {
|
|||||||
final appSetting = ref.watch(
|
final appSetting = ref.watch(
|
||||||
appSettingProvider,
|
appSettingProvider,
|
||||||
);
|
);
|
||||||
final groups = ref.watch(
|
final groups = ref
|
||||||
groupsProvider,
|
.watch(
|
||||||
);
|
currentGroupsStateProvider,
|
||||||
|
)
|
||||||
|
.value;
|
||||||
final brightness = ref.watch(
|
final brightness = ref.watch(
|
||||||
appBrightnessProvider,
|
appBrightnessProvider,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -315,19 +315,9 @@ class GlobalState {
|
|||||||
final profileId = profile.id;
|
final profileId = profile.id;
|
||||||
final configMap = await getProfileConfig(profileId);
|
final configMap = await getProfileConfig(profileId);
|
||||||
final rawConfig = await handleEvaluate(configMap);
|
final rawConfig = await handleEvaluate(configMap);
|
||||||
final routeAddress =
|
final realPatchConfig = patchConfig.copyWith(
|
||||||
config.networkProps.routeMode == RouteMode.bypassPrivate
|
tun: patchConfig.tun.getRealTun(config.networkProps.routeMode),
|
||||||
? defaultBypassPrivateRouteAddress
|
);
|
||||||
: patchConfig.tun.routeAddress;
|
|
||||||
final realPatchConfig = !system.isDesktop
|
|
||||||
? patchConfig.copyWith.tun(
|
|
||||||
autoRoute: routeAddress.isEmpty ? true : false,
|
|
||||||
routeAddress: routeAddress,
|
|
||||||
)
|
|
||||||
: patchConfig.copyWith.tun(
|
|
||||||
autoRoute: true,
|
|
||||||
routeAddress: [],
|
|
||||||
);
|
|
||||||
rawConfig["external-controller"] = realPatchConfig.externalController.value;
|
rawConfig["external-controller"] = realPatchConfig.externalController.value;
|
||||||
rawConfig["external-ui"] = "";
|
rawConfig["external-ui"] = "";
|
||||||
rawConfig["interface-name"] = "";
|
rawConfig["interface-name"] = "";
|
||||||
@@ -411,21 +401,23 @@ class GlobalState {
|
|||||||
for (final host in realPatchConfig.hosts.entries) {
|
for (final host in realPatchConfig.hosts.entries) {
|
||||||
rawConfig["hosts"][host.key] = host.value.splitByMultipleSeparators;
|
rawConfig["hosts"][host.key] = host.value.splitByMultipleSeparators;
|
||||||
}
|
}
|
||||||
|
if (rawConfig["dns"] == null) {
|
||||||
|
rawConfig["dns"] = {};
|
||||||
|
}
|
||||||
|
final isEnableDns = rawConfig["dns"]["enable"] == true;
|
||||||
final overrideDns = globalState.config.overrideDns;
|
final overrideDns = globalState.config.overrideDns;
|
||||||
if (overrideDns) {
|
if (overrideDns || !isEnableDns) {
|
||||||
rawConfig["dns"] = realPatchConfig.dns.toJson();
|
final dns = switch (!isEnableDns) {
|
||||||
|
true => realPatchConfig.dns.copyWith(
|
||||||
|
nameserver: [...realPatchConfig.dns.nameserver, "system://"]),
|
||||||
|
false => realPatchConfig.dns,
|
||||||
|
};
|
||||||
|
rawConfig["dns"] = dns.toJson();
|
||||||
rawConfig["dns"]["nameserver-policy"] = {};
|
rawConfig["dns"]["nameserver-policy"] = {};
|
||||||
for (final entry in realPatchConfig.dns.nameserverPolicy.entries) {
|
for (final entry in dns.nameserverPolicy.entries) {
|
||||||
rawConfig["dns"]["nameserver-policy"][entry.key] =
|
rawConfig["dns"]["nameserver-policy"][entry.key] =
|
||||||
entry.value.splitByMultipleSeparators;
|
entry.value.splitByMultipleSeparators;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (rawConfig["dns"] == null) {
|
|
||||||
rawConfig["dns"] = {};
|
|
||||||
}
|
|
||||||
if (rawConfig["dns"]["enable"] != false) {
|
|
||||||
rawConfig["dns"]["enable"] = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
var rules = [];
|
var rules = [];
|
||||||
if (rawConfig["rules"] != null) {
|
if (rawConfig["rules"] != null) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: fl_clash
|
name: fl_clash
|
||||||
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
version: 0.8.85+202506071
|
version: 0.8.86+202506141
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.1.0 <4.0.0'
|
sdk: '>=3.1.0 <4.0.0'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user