alroyso 1 jaar geleden
bovenliggende
commit
ced87875b9
2 gewijzigde bestanden met toevoegingen van 57 en 49 verwijderingen
  1. 1 1
      lib/app/common/constants.dart
  2. 56 48
      lib/app/controller/GlobalController.dart

+ 1 - 1
lib/app/common/constants.dart

@@ -8,4 +8,4 @@ const KLogout = "/api/client/v2/logout";
 const KAuthUser = "/api/client/v2/authUser";
 const KAuthUser = "/api/client/v2/authUser";
 const kNode = '';
 const kNode = '';
 
 
-const kVersion = '2.0.5';
+const kVersion = '2.0.6';

+ 56 - 48
lib/app/controller/GlobalController.dart

@@ -389,21 +389,35 @@ class GlobalController extends GetxController {
     }
     }
     port = port ?? mixedPort ?? 0;
     port = port ?? mixedPort ?? 0;
     if (port != 0) {
     if (port != 0) {
-      String loa = '127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*';
-      int? exitCode;
-      // Process sysproxy = await Process.start(Files.assetsSysProxyWin.path,,mode: ProcessStartMode.inheritStdio);
-      // sysproxy.exitCode.then((code) => exitCode = code);
-      try {
-        var result = await Process.run(
-          Files.assetsSysProxyWin.path,
-          ['global','127.0.0.1:$port',loa],
-          runInShell: true,
+      if(Platform.isWindows){
+        String loa = '127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*';
+        int? exitCode;
+        // Process sysproxy = await Process.start(Files.assetsSysProxyWin.path,,mode: ProcessStartMode.inheritStdio);
+        // sysproxy.exitCode.then((code) => exitCode = code);
+        try {
+          var result = await Process.run(
+            Files.assetsSysProxyWin.path,
+            ['global','127.0.0.1:$port',loa],
+            runInShell: true,
+          );
+          LogHelper().d(result.stderr);
+          LogHelper().d(result.stdout);
+        } on ProcessException catch (e) {
+          //.e('Failed to start $coreName: ${e.message}');
+          throw Exception('Failed to start sysproxy: ${e.message}');
+        }
+      } else {
+        await proxyManager.setAsSystemProxy(
+          ProxyTypes.http,
+          "127.0.0.1",
+          port,
         );
         );
-        LogHelper().d(result.stderr);
-        LogHelper().d(result.stdout);
-      } on ProcessException catch (e) {
-        //.e('Failed to start $coreName: ${e.message}');
-        throw Exception('Failed to start sysproxy: ${e.message}');
+        await proxyManager.setAsSystemProxy(
+          ProxyTypes.https,
+          "127.0.0.1",
+          port,
+        );
+        systemProxy = true;
       }
       }
     }
     }
 
 
@@ -412,47 +426,41 @@ class GlobalController extends GetxController {
     //
     //
     // port = port ?? mixedPort ?? 0;
     // port = port ?? mixedPort ?? 0;
     // if (port != 0) {
     // if (port != 0) {
-    //   await proxyManager.setAsSystemProxy(
-    //     ProxyTypes.http,
-    //     "127.0.0.1",
-    //     port,
-    //   );
-    //   await proxyManager.setAsSystemProxy(
-    //     ProxyTypes.https,
-    //     "127.0.0.1",
-    //     port,
-    //   );
-    //   systemProxy = true;
-    // }
-    // socksPort = socksPort ?? mixedPort ?? 0;
-    // if (socksPort != 0) {
-    //   if (!Platform.isWindows) {
-    //     await proxyManager.setAsSystemProxy(
-    //       ProxyTypes.socks,
-    //       "127.0.0.1",
-    //       socksPort,
-    //     );
-    //   }
-    //   systemProxy = true;
+
     // }
     // }
+    socksPort = socksPort ?? mixedPort ?? 0;
+    if (socksPort != 0) {
+
+      if (!Platform.isWindows) {
+        await proxyManager.setAsSystemProxy(
+          ProxyTypes.socks,
+          "127.0.0.1",
+          socksPort,
+        );
+      }
+      systemProxy = true;
+    }
   }
   }
 
 
   /// 关闭代理
   /// 关闭代理
 
 
   Future<void> closeProxy() async {
   Future<void> closeProxy() async {
-    // proxyManager.cleanSystemProxy();
-    try {
-      var result =  await Process.run(
-        Files.assetsSysProxyWin.path,
-        ['set','1','','',''],
-        runInShell: true,
-      );
-      LogHelper().d(result.stderr);
-      LogHelper().d(result.stdout);
-    } on ProcessException catch (e) {
-      //.e('Failed to start $coreName: ${e.message}');
-      throw Exception('Failed to start sysproxy: ${e.message}');
+    //
+    if (Platform.isWindows) {
+      try {
+        var result =  await Process.run(
+          Files.assetsSysProxyWin.path,
+          ['set','1','','',''],
+          runInShell: true,
+        );
+        LogHelper().d(result.stderr);
+        LogHelper().d(result.stdout);
+      } on ProcessException catch (e) {
+        //.e('Failed to start $coreName: ${e.message}');
+        throw Exception('Failed to start sysproxy: ${e.message}');
+      }
     }
     }
+    proxyManager.cleanSystemProxy();
     systemProxy = false;
     systemProxy = false;
   }
   }
   Future<void> stopAllCore() async {
   Future<void> stopAllCore() async {