summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorAndrew Morgan <1342360+anoadragon453@users.noreply.github.com>2021-03-22 17:48:42 +0000
committerGitHub <noreply@github.com>2021-03-22 17:48:42 +0000
commit232b324c38b3914509550aa895b791a33874c915 (patch)
tree7c324a040e452979aa0eddd6d7af5638f2369908 /synapse/server.py
parentRemove extraneous print (#94) (diff)
downloadsynapse-232b324c38b3914509550aa895b791a33874c915.tar.xz
Port "Add support for no_proxy and case insensitive env variables" from mainline to dinsic (#93)
This PR is simply porting https://github.com/matrix-org/synapse/pull/9372 to dinsic.

I also had to bring in https://github.com/matrix-org/synapse/pull/8821 and https://github.com/matrix-org/synapse/pull/9084 for this code to work properly - a sign that we should merge mainline into dinsic again soon.
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py36
1 files changed, 25 insertions, 11 deletions
diff --git a/synapse/server.py b/synapse/server.py

index b017e3489f..78f665a51c 100644 --- a/synapse/server.py +++ b/synapse/server.py
@@ -24,7 +24,6 @@ import abc import functools import logging -import os from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, TypeVar, cast import twisted.internet.base @@ -350,15 +349,37 @@ class HomeServer(metaclass=abc.ABCMeta): @cache_in_self def get_simple_http_client(self) -> SimpleHttpClient: + """ + An HTTP client with no special configuration. + """ return SimpleHttpClient(self) @cache_in_self def get_proxied_http_client(self) -> SimpleHttpClient: + """ + An HTTP client that uses configured HTTP(S) proxies. + """ + return SimpleHttpClient(self, use_proxy=True) + + @cache_in_self + 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. + """ return SimpleHttpClient( - self, - http_proxy=os.getenvb(b"http_proxy"), - https_proxy=os.getenvb(b"HTTPS_PROXY"), + self, ip_blacklist=self.config.ip_range_blacklist, use_proxy=True, + ) + + @cache_in_self + def get_federation_http_client(self) -> MatrixFederationHttpClient: + """ + An HTTP client for federation. + """ + tls_client_options_factory = context_factory.FederationPolicyForHTTPS( + self.config ) + return MatrixFederationHttpClient(self, tls_client_options_factory) @cache_in_self def get_room_creation_handler(self) -> RoomCreationHandler: @@ -515,13 +536,6 @@ class HomeServer(metaclass=abc.ABCMeta): return PusherPool(self) @cache_in_self - def get_http_client(self) -> MatrixFederationHttpClient: - tls_client_options_factory = context_factory.FederationPolicyForHTTPS( - self.config - ) - return MatrixFederationHttpClient(self, tls_client_options_factory) - - @cache_in_self def get_media_repository_resource(self) -> MediaRepositoryResource: # build the media repo resource. This indirects through the HomeServer # to ensure that we only have a single instance of