Add General.proxy setting, supports HTTP & SOCKS5

This commit is contained in:
miruka
2021-03-02 12:11:54 -04:00
parent b0d31af3c0
commit f6f0a0c1ee
5 changed files with 44 additions and 1 deletions

View File

@@ -167,11 +167,18 @@ class MatrixClient(nio.AsyncClient):
store = Path(backend.appdirs.user_data_dir) / "encryption"
store.mkdir(parents=True, exist_ok=True)
proxy = backend.settings.General.proxy
host = re.sub(r":\d+$", "", urlparse(homeserver).netloc)
if host in ("127.0.0.1", "localhost", "::1"):
proxy = None
super().__init__(
homeserver = homeserver,
user = user,
device_id = device_id,
store_path = store,
proxy = proxy,
config = nio.AsyncClientConfig(
max_timeout_retry_wait_time = 10,
# TODO: pass a custom encryption DB pickle key?