Skip to content

Commit

Permalink
Update ua
Browse files Browse the repository at this point in the history
Fix change outbound mode without check ip issues
  • Loading branch information
chen08209 committed Jul 13, 2024
1 parent c640798 commit 2dd4506
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down Expand Up @@ -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() {
Expand All @@ -237,7 +239,6 @@ class AppPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware

override fun onDetachedFromActivity() {
channel.invokeMethod("exit", null)
scope.cancel()
activity = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
flClashVpnService = binder.getService()
if (isStart) {
startVpn()
} else {
flClashVpnService?.initServiceEngine()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/common/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ");
}
1 change: 1 addition & 0 deletions lib/fragments/dashboard/outbound_mode.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class OutboundMode extends StatelessWidget {
if (value == null || clashConfig.mode == value) return;
clashConfig.mode = value;
await appController.updateClashConfig();
appController.addCheckIpNumDebounce();
}

@override
Expand Down
7 changes: 6 additions & 1 deletion lib/fragments/profiles/profiles.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';

import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/plugins/app.dart';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -110,6 +112,7 @@ Future<void> vpnService() async {
onStop: () async {
await app?.tip(appLocalizations.stopVpn);
await globalState.stopSystemProxy();
exit(0);
},
),
);
Expand Down
4 changes: 0 additions & 4 deletions lib/plugins/proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'

Expand Down

0 comments on commit 2dd4506

Please sign in to comment.