Support desktop hotkey

Support android ipv6 inbound

Support android system dns

fix some bugs
This commit is contained in:
chen08209
2024-09-08 21:21:21 +08:00
parent 4e766d9407
commit 5d6bd6466f
125 changed files with 5898 additions and 4435 deletions

View File

@@ -5,6 +5,7 @@ import 'dart:isolate';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -21,8 +22,6 @@ class App {
if (onExit != null) {
await onExit!();
}
case "gc":
clashCore.requestGc();
default:
throw MissingPluginException();
}
@@ -86,12 +85,6 @@ class App {
"value": value,
});
}
Future<String?> resolverProcess(Process process) async {
return await methodChannel.invokeMethod<String>("resolverProcess", {
"data": json.encode(process),
});
}
}
final app = Platform.isAndroid ? App() : null;

View File

@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:io';
import 'dart:isolate';
import 'package:fl_clash/state.dart';
import 'package:flutter/services.dart';
class Service {
@@ -26,4 +27,5 @@ class Service {
}
}
final service = Platform.isAndroid ? Service() : null;
final service =
Platform.isAndroid && !globalState.isVpnService ? Service() : null;

View File

@@ -6,6 +6,8 @@ import 'dart:isolate';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/services.dart';
class Vpn {
@@ -19,9 +21,16 @@ class Vpn {
methodChannel.setMethodCallHandler((call) async {
switch (call.method) {
case "started":
final fd = call.arguments;
onStarted(fd);
final tunProps = call.arguments != null
? TunProps.fromJson(json.decode((call.arguments)))
: null;
onStarted(tunProps);
break;
case "gc":
clashCore.requestGc();
case "dnsChanged":
final dns = call.arguments as String;
clashCore.updateDns(dns);
default:
throw MissingPluginException();
}
@@ -49,6 +58,12 @@ class Vpn {
return await methodChannel.invokeMethod<bool?>("setProtect", {'fd': fd});
}
Future<String?> resolverProcess(Process process) async {
return await methodChannel.invokeMethod<String>("resolverProcess", {
"data": json.encode(process),
});
}
Future<bool?> startForeground({
required String title,
required String content,
@@ -59,7 +74,7 @@ class Vpn {
});
}
onStarted(int? fd) {
onStarted(TunProps? tunProps) {
if (receiver != null) {
receiver!.close();
receiver == null;
@@ -68,7 +83,7 @@ class Vpn {
receiver!.listen((message) {
_handleServiceMessage(message);
});
clashCore.startTun(fd ?? 0, receiver!.sendPort.nativePort);
clashCore.startTun(tunProps, receiver!.sendPort.nativePort);
}
setServiceMessageHandler(ServiceMessageListener serviceMessageListener) {
@@ -90,4 +105,4 @@ class Vpn {
}
}
final vpn = Platform.isAndroid ? Vpn() : null;
final vpn = Platform.isAndroid && globalState.isVpnService ? Vpn() : null;