alroyso 1 year ago
parent
commit
d284061b04

+ 8 - 8
lib/app/controller/GlobalController.dart

@@ -221,14 +221,14 @@ class GlobalController extends GetxController {
 
   Future<void> systemProxySwitch(bool open) async {
     systemProxySwitchIng.value = true;
-    //await SystemProxy.instance.set(open ? controllers.core.proxyConfig : SystemProxyConfig());
-    //wait controllers.config.setSystemProxy(open);
-    if(open)
-    {
-     await openProxy();
-    } else {
-     await  closeProxy();
-    }
+    await SystemProxy.instance.set(open ? controllers.core.proxyConfig : SystemProxyConfig());
+    await controllers.config.setSystemProxy(open);
+    // if(open)
+    // {
+    //  await openProxy();
+    // } else {
+    //  await  closeProxy();
+    // }
     systemProxySwitchIng.value = false;
   }
 

+ 2 - 2
lib/app/controller/core.dart

@@ -53,8 +53,8 @@ class CoreController extends GetxController {
     final socksPort = mixedPort ?? config.value.socksPort;
     return SystemProxyConfig(
       http: httpPort == 0 ? null : '127.0.0.1:$httpPort',
-      https: httpsPort == 0 ? null : '127.0.0.1:$httpsPort',
-      socks: socksPort == 0 ? null : '127.0.0.1:$socksPort',
+      //https: httpsPort == 0 ? null : '127.0.0.1:$httpsPort',
+     // socks: socksPort == 0 ? null : '127.0.0.1:$socksPort',
     );
   }
 

+ 6 - 3
lib/app/utils/system_proxy.dart

@@ -107,12 +107,15 @@ class WinSystemProxy extends SystemProxyPlatform {
     // http=127.0.0.1:7893;                                             chrome, firefox not use
     // http=xxx 不建议使用
     String servers = "";
-    if (conf.http != null) servers += "http://${conf.http};";
-    if (conf.https != null) servers += "https=${conf.https};";
-    if (conf.socks != null) servers += "socks=${conf.socks};";
+    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.*';
+    if (conf.http != null) servers += "${conf.http}";
+    // if (conf.https != null) servers += "https=${conf.https};";
+    // if (conf.socks != null) servers += "socks=${conf.socks};";
     if (servers.isNotEmpty) {
       await Process.run('reg', ['add', regPath, '/v', 'ProxyEnable', '/t', 'REG_DWORD', '/d', '1', '/f']);
       await Process.run('reg', ['add', regPath, '/v', 'ProxyServer', '/t', 'REG_SZ', '/d', servers, '/f']);
+
+      await Process.run('reg', ['add', regPath, '/v', 'ProxyOverride', '/t', 'REG_SZ', '/d', loa, '/f']);
     } else {
       await Process.run('reg', ['add', regPath, '/v', 'ProxyEnable', '/t', 'REG_DWORD', '/d', '0', '/f']);
       await Process.run('reg', ['add', regPath, '/v', 'ProxyServer', '/t', 'REG_SZ', '/d', '', '/f']);