diff --git a/pkg/utils/proxy.py b/pkg/utils/proxy.py index 3091bddf..06d1a9c4 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()