Skip to content

The only downloader you need. 下载器的集大成者。

修复 macOS 无法获取系统代理的问题

XiaoYouChRd6e10df3f0dc
diff --git a/app/common/methods.py b/app/common/methods.py
index a16b6939..e022fc4c 100644
--- a/app/common/methods.py
+++ b/app/common/methods.py
@@ -74,13 +74,26 @@ def getSystemProxy():
except Exception as e:
logger.error(f"Cannot get Windows proxy server:{e}")
return None
- else: # 读取 Linux 系统代理
+
+ elif sys.platform == "linux": # 读取 Linux 系统代理
try:
return os.environ.get("http_proxy")
except Exception as e:
logger.error(f"Cannot get Linux proxy server:{e}")
return None
+ elif sys.platform == "darwin":
+ import SystemConfiguration
+
+ _ = SystemConfiguration.SCDynamicStoreCopyProxies(None)
+
+ if _.get('SOCKSEnable', 0):
+ return f"socks5://{_.get('SOCKSProxy')}:{_.get('SOCKSPort')}"
+ elif _.get('HTTPEnable', 0):
+ return f"http://{_.get('HTTPProxy')}:{_.get('HTTPPort')}"
+ else:
+ return None
+
def getProxy():
# print(cfg.proxyServer.value)