Update ua

Fix change outbound mode without check ip issues
This commit is contained in:
chen08209
2024-07-13 20:23:54 +08:00
parent c6407984ac
commit 2dd45062f1
9 changed files with 20 additions and 11 deletions
@@ -48,13 +48,16 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
private val iconMap = mutableMapOf<String, String?>()
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
scope = CoroutineScope(Dispatchers.Default)
context = flutterPluginBinding.applicationContext;
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "app")
channel.setMethodCallHandler(this)
}
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
scope.cancel()
}
private fun tip(message: String?) {
@@ -224,7 +227,6 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
override fun onAttachedToActivity(binding: ActivityPluginBinding) {
activity = binding.activity;
scope = CoroutineScope(Dispatchers.Default)
}
override fun onDetachedFromActivityForConfigChanges() {
@@ -237,7 +239,6 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware
override fun onDetachedFromActivity() {
channel.invokeMethod("exit", null)
scope.cancel()
activity = null
}
}
@@ -46,8 +46,6 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
flClashVpnService = binder.getService()
if (isStart) {
startVpn()
} else {
flClashVpnService?.initServiceEngine()
}
}
@@ -44,6 +44,11 @@ class FlClashVpnService : VpnService() {
"192.168.*"
)
override fun onCreate() {
super.onCreate()
initServiceEngine()
}
fun start(port: Int, props: Props?): Int? {
return with(Builder()) {
addAddress("172.16.0.1", 30)
+1 -1
View File
@@ -7,7 +7,7 @@ import 'common.dart';
extension PackageInfoExtension on PackageInfo {
String get ua => [
"$appName/v$version",
"clash-verge/v1.6.6",
"clash-verge",
"Platform/${Platform.operatingSystem}",
].join(" ");
}
@@ -16,6 +16,7 @@ class OutboundMode extends StatelessWidget {
if (value == null || clashConfig.mode == value) return;
clashConfig.mode = value;
await appController.updateClashConfig();
appController.addCheckIpNumDebounce();
}
@override
+6 -1
View File
@@ -216,7 +216,12 @@ class _ProfileItemState extends State<ProfileItem> {
Future updateProfile([isSingle = true]) async {
isUpdating.value = true;
try {
await globalState.appController.updateProfile(widget.profile);
final appController = globalState.appController;
await appController.updateProfile(widget.profile);
if (widget.profile.id == appController.config.currentProfile?.id &&
!appController.appState.isStart) {
globalState.appController.rawApplyProfile();
}
} catch (e) {
isUpdating.value = false;
if (!isSingle) {
+3
View File
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/plugins/app.dart';
@@ -66,6 +67,7 @@ Future<void> vpnService() async {
clashCore.setFdMap(fd.id);
},
onProcess: (Process process) async {
print(process);
var packageName = await app?.resolverProcess(process);
clashCore.setProcessMap(
ProcessMapItem(
@@ -110,6 +112,7 @@ Future<void> vpnService() async {
onStop: () async {
await app?.tip(appLocalizations.stopVpn);
await globalState.stopSystemProxy();
exit(0);
},
),
);
-4
View File
@@ -105,16 +105,12 @@ class Proxy extends ProxyPlatform {
switch (m.type) {
case ServiceMessageType.protect:
_serviceMessageHandler?.onProtect(Fd.fromJson(m.data));
break;
case ServiceMessageType.process:
_serviceMessageHandler?.onProcess(Process.fromJson(m.data));
break;
case ServiceMessageType.started:
_serviceMessageHandler?.onStarted(m.data);
break;
case ServiceMessageType.loaded:
_serviceMessageHandler?.onLoaded(m.data);
break;
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none'
version: 0.8.36+202407131
version: 0.8.36+202407132
environment:
sdk: '>=3.1.0 <4.0.0'