alroyso 4 months ago
parent
commit
e0c5c888bb
2 changed files with 6 additions and 2 deletions
  1. 2 0
      lib/app/service/connection_service.dart
  2. 4 2
      lib/app/utils/WindowsProxyManager.dart

+ 2 - 0
lib/app/service/connection_service.dart

@@ -167,6 +167,8 @@ class ConnectionService {
       } else{
         if (controllers.service.clashServiceIsRuning){
           await controllers.service.stopClash();
+          final proxyManager = WindowsProxyManager();
+          proxyManager.disableSystemProxy();
           await globalController.closeProxy();
           globalController.updateMsg("内核已重新加载");
         } else {

+ 4 - 2
lib/app/utils/WindowsProxyManager.dart

@@ -93,10 +93,12 @@ class WindowsProxyManager {
 
     // 释放内存
     calloc.free(proxyInfo);
-    calloc.free(options[1].Value.pszValue);
-    calloc.free(options[2].Value.pszValue);
+    calloc.free(options[1].Value.pszValue);  // 只释放字符串指针
+    calloc.free(options[2].Value.pszValue);  // 只释放字符串指针
     calloc.free(options);
   }
+
+
   void disableSystemProxy() {
     final proxyInfo = calloc<INTERNET_PER_CONN_OPTION_LIST>();
     proxyInfo.ref.dwSize = sizeOf<INTERNET_PER_CONN_OPTION_LIST>();