~nhanb/pytaku

2693211f244690cbfd71fbb698ab9f0e173c6d79 — Bùi Thành Nhân a month ago f4c47aa
better outgoing proxy signature
2 files changed, 6 insertions(+), 7 deletions(-)

M src/mangoapi/base_site.py
M src/pytaku/conf.py
M src/mangoapi/base_site.py => src/mangoapi/base_site.py +4 -4
@@ 65,12 65,12 @@ class Site(ABC):
        # 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)

M src/pytaku/conf.py => src/pytaku/conf.py +2 -3
@@ 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"])