Update ws_client.py to support proxy

This commit is contained in:
AyliD 2019-08-29 07:46:40 +03:00 committed by GitHub
parent 4b8e89f95d
commit 34f3d05c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,11 @@ class WSClient:
ssl_opts['keyfile'] = configuration.key_file
self.sock = WebSocket(sslopt=ssl_opts, skip_utf8_validation=False)
self.sock.connect(url, header=header)
if configuration.proxy:
proxy_url = urlparse(configuration.proxy)
self.sock.connect(url, header=header, http_proxy_host=proxy_url.hostname, http_proxy_port=proxy_url.port)
else:
self.sock.connect(url, header=header)
self._connected = True
def peek_channel(self, channel, timeout=0):