浏览代码

Make proxy_handler optional in mauigpapi

Tulir Asokan 2 年之前
父节点
当前提交
72ceaf8eee
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 1 1
      mauigpapi/http/base.py
  2. 2 2
      mauigpapi/mqtt/conn.py

+ 1 - 1
mauigpapi/http/base.py

@@ -143,7 +143,7 @@ class BaseAndroidAPI:
 
     def setup_http(self, cookie_jar: CookieJar) -> None:
         connector = None
-        http_proxy = self.proxy_handler.get_proxy_url()
+        http_proxy = self.proxy_handler.get_proxy_url() if self.proxy_handler else None
         if http_proxy:
             if ProxyConnector:
                 connector = ProxyConnector.from_url(http_proxy)

+ 2 - 2
mauigpapi/mqtt/conn.py

@@ -149,7 +149,7 @@ class AndroidMQTT:
         self._client.on_socket_unregister_write = self._on_socket_unregister_write
 
     def setup_proxy(self):
-        http_proxy = self.proxy_handler.get_proxy_url()
+        http_proxy = self.proxy_handler.get_proxy_url() if self.proxy_handler else None
         if http_proxy:
             if not socks:
                 self.log.warning("http_proxy is set, but pysocks is not installed")
@@ -610,7 +610,7 @@ class AndroidMQTT:
                 elif rc == pmc.MQTT_ERR_NO_CONN:
                     if connection_retries > retry_limit:
                         raise MQTTNotConnected(f"Connection failed {connection_retries} times")
-                    if self.proxy_handler.update_proxy_url():
+                    if self.proxy_handler and self.proxy_handler.update_proxy_url():
                         self.setup_proxy()
                         await self._dispatch(ProxyUpdate())
                     sleep = connection_retries * 2