Repos / pytaku / 2693211f24
commit 2693211f244690cbfd71fbb698ab9f0e173c6d79
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Tue Jun 22 20:58:57 2021 +0700
better outgoing proxy signature
diff --git a/src/mangoapi/base_site.py b/src/mangoapi/base_site.py
index 9189367..e308cea 100644
--- a/src/mangoapi/base_site.py
+++ b/src/mangoapi/base_site.py
@@ -65,12 +65,12 @@ def _http_request(self, method, url, *args, **kwargs):
# Proxy shit
parsed_url = urlparse(url)
url = parsed_url._replace(
- netloc=config.FAASPROXY_NETLOC,
+ netloc=config.OUTGOING_PROXY_NETLOC,
scheme="https",
- path=config.FAASPROXY_PATH + parsed_url.path,
).geturl()
- headers["Faasproxy-Target-Host"] = parsed_url.netloc
- headers["Faasproxy-Key"] = config.FAASPROXY_KEY
+ headers["X-Proxy-Target-Host"] = parsed_url.netloc
+ headers["X-Proxy-Key"] = config.OUTGOING_PROXY_KEY
+ headers["X-Proxy-Scheme"] = parsed_url.scheme
kwargs["headers"] = headers
request_func = getattr(self._session, method)
diff --git a/src/pytaku/conf.py b/src/pytaku/conf.py
index ff1a9cc..aa53ca4 100644
--- a/src/pytaku/conf.py
+++ b/src/pytaku/conf.py
@@ -14,9 +14,8 @@ class Config(GoodConf):
PROXY_CACHE_MAX_SIZE = Value(default=1024 * 1024 * 1024 * 5) # 5GiB in bytes
PROXY_CACHE_MAX_AGE = Value(default=3600 * 24 * 2) # 2 days in seconds
- FAASPROXY_NETLOC = Value()
- FAASPROXY_PATH = Value()
- FAASPROXY_KEY = Value()
+ OUTGOING_PROXY_NETLOC = Value()
+ OUTGOING_PROXY_KEY = Value()
config = Config(default_files=["pytaku.conf.json"])