|
@@ -23,8 +23,38 @@ class ConnectionService {
|
|
|
ConnectionService(this.globalController, this.updateStatus);
|
|
|
|
|
|
|
|
|
- Future<void> startConnection() async {
|
|
|
+ Future<void> startConnectionWin() async {
|
|
|
try {
|
|
|
+ updateStatus(ConnectionStatus.connecting);
|
|
|
+ globalController.updateMsg("正在启动连接...");
|
|
|
+ await globalController.updateNode();
|
|
|
+
|
|
|
+ await Future.delayed(Duration(seconds: 2));
|
|
|
+ updateStatus(ConnectionStatus.connected);
|
|
|
+ globalController.connectStatus.value = true;
|
|
|
+ globalController.updateMsg("连接成功");
|
|
|
+
|
|
|
+ final proxyManager = WlBaseHelp();
|
|
|
+
|
|
|
+ if(Platform.isWindows){
|
|
|
+ int? port = controllers.config.mixedPort.value;
|
|
|
+ if (port == 0) {
|
|
|
+ port = null;
|
|
|
+ }
|
|
|
+ int? socksPort = controllers.config.mixedPort.value;
|
|
|
+ if (socksPort == 0) {
|
|
|
+ socksPort = null;
|
|
|
+ }
|
|
|
+ int? mixedPort = controllers.config.mixedPort.value;
|
|
|
+ if (mixedPort == 0) {
|
|
|
+ mixedPort = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(port !=null){
|
|
|
+ await proxyManager.startProxy(port);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -51,98 +81,72 @@ class ConnectionService {
|
|
|
|
|
|
|
|
|
|
|
|
- updateStatus(ConnectionStatus.connecting);
|
|
|
- globalController.updateMsg("正在启动连接...");
|
|
|
-
|
|
|
- if(Platform.isMacOS){
|
|
|
- if (serviceController.serviceIsRuning) {
|
|
|
- await globalController.makeProxy();
|
|
|
- await serviceController.reloadClashCore();
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- await globalController.updateNode();
|
|
|
|
|
|
|
|
|
-
|
|
|
- await Future.delayed(Duration(seconds: 2));
|
|
|
-
|
|
|
- if(Platform.isMacOS){
|
|
|
- if (serviceController.serviceIsRuning) {
|
|
|
-
|
|
|
- await serviceController.fetchSetProxy();
|
|
|
- await globalController.openProxy();
|
|
|
- } else {
|
|
|
- if (controllers.service.clashServiceIsRuning) {
|
|
|
- globalController.connectStatus.value = true;
|
|
|
-
|
|
|
- } else {
|
|
|
- throw Exception("内核启动失败");
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (controllers.service.clashServiceIsRuning) {
|
|
|
- updateStatus(ConnectionStatus.connected);
|
|
|
- globalController.connectStatus.value = true;
|
|
|
- globalController.updateMsg("连接成功");
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- } else {
|
|
|
- throw Exception("内核启动失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- final proxyManager = WlBaseHelp();
|
|
|
|
|
|
- if(Platform.isWindows){
|
|
|
- int? port = controllers.config.mixedPort.value;
|
|
|
- if (port == 0) {
|
|
|
- port = null;
|
|
|
- }
|
|
|
- int? socksPort = controllers.config.mixedPort.value;
|
|
|
- if (socksPort == 0) {
|
|
|
- socksPort = null;
|
|
|
- }
|
|
|
- int? mixedPort = controllers.config.mixedPort.value;
|
|
|
- if (mixedPort == 0) {
|
|
|
- mixedPort = null;
|
|
|
- }
|
|
|
|
|
|
- if(port !=null){
|
|
|
- await proxyManager.startProxy(port);
|
|
|
- }
|
|
|
|
|
|
- } else {
|
|
|
- controllers.global.systemProxySwitch(true);
|
|
|
- }
|
|
|
- updateStatus(ConnectionStatus.connected);
|
|
|
- globalController.updateMsg("连接成功");
|
|
|
- controllers.global.connectStatus.value = true;
|
|
|
|
|
|
-
|
|
|
- if(Platform.isWindows){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- if(!await proxyManager.isProxyEnabled()){
|
|
|
- globalController.updateMsg("当前没有设置系统代理,20秒后切换成网卡模式");
|
|
|
- await Future.delayed(Duration(seconds: 20));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- LogHelper().d("重置网卡模式");
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
} catch (e) {
|