From 0d4784d09832aaed0b52e86adc1393a21caf3721 Mon Sep 17 00:00:00 2001 From: Junyan Qin Date: Mon, 11 Nov 2024 19:12:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=A3=E7=90=86=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=88=B0=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/utils/proxy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/utils/proxy.py b/pkg/utils/proxy.py index 3091bdd..06d1a9c 100644 --- a/pkg/utils/proxy.py +++ b/pkg/utils/proxy.py @@ -25,10 +25,14 @@ class ProxyManager: "https://": os.getenv("HTTPS_PROXY") or os.getenv("https_proxy"), } - if 'http' in self.ap.system_cfg.data['network-proxies']: + if 'http' in self.ap.system_cfg.data['network-proxies'] and self.ap.system_cfg.data['network-proxies']['http']: self.forward_proxies['http://'] = self.ap.system_cfg.data['network-proxies']['http'] - if 'https' in self.ap.system_cfg.data['network-proxies']: + if 'https' in self.ap.system_cfg.data['network-proxies'] and self.ap.system_cfg.data['network-proxies']['https']: self.forward_proxies['https://'] = self.ap.system_cfg.data['network-proxies']['https'] + # 设置到环境变量 + os.environ['HTTP_PROXY'] = self.forward_proxies['http://'] + os.environ['HTTPS_PROXY'] = self.forward_proxies['https://'] + def get_forward_proxies(self) -> dict: return self.forward_proxies.copy()