Skip to content

Commit

Permalink
Use getproxies_environment directly
Browse files Browse the repository at this point in the history
  • Loading branch information
tzyl committed Feb 10, 2021
1 parent e258497 commit d84117f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions synapse/rest/media/v1/preview_url_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import traceback
from typing import TYPE_CHECKING, Any, Dict, Generator, Iterable, Optional, Union
from urllib import parse as urlparse
from urllib.request import getproxies
from urllib.request import getproxies_environment

import attr

Expand Down Expand Up @@ -145,7 +145,7 @@ def __init__(
self.max_spider_size = hs.config.max_spider_size
self.server_name = hs.hostname
self.store = hs.get_datastore()
proxies = getproxies()
proxies = getproxies_environment()
self.client = SimpleHttpClient(
hs,
treq_args={"browser_like_redirects": True},
Expand Down
6 changes: 3 additions & 3 deletions synapse/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Union,
cast,
)
from urllib.request import getproxies
from urllib.request import getproxies_environment

import twisted.internet.base
import twisted.internet.tcp
Expand Down Expand Up @@ -370,7 +370,7 @@ def get_proxied_http_client(self) -> SimpleHttpClient:
"""
An HTTP client that uses configured HTTP(S) proxies.
"""
proxies = getproxies()
proxies = getproxies_environment()
return SimpleHttpClient(
self,
http_proxy=proxies["http"].encode() if "http" in proxies else None,
Expand All @@ -384,7 +384,7 @@ def get_proxied_blacklisted_http_client(self) -> SimpleHttpClient:
An HTTP client that uses configured HTTP(S) proxies and blacklists IPs
based on the IP range blacklist/whitelist.
"""
proxies = getproxies()
proxies = getproxies_environment()
return SimpleHttpClient(
self,
ip_whitelist=self.config.ip_range_whitelist,
Expand Down

0 comments on commit d84117f

Please sign in to comment.