mirror of
https://github.com/masterking32/MasterHttpRelayVPN.git
synced 2026-05-17 21:24:37 +03:00
Major bugfix: added no-redirect to VPS exit node
This commit is contained in:
@@ -95,6 +95,21 @@ _OUTBOUND_TIMEOUT = 30
|
||||
# Pre-shared key loaded at startup.
|
||||
_PSK: str = ""
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# HTTP client — no-redirect opener
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
_NO_REDIRECT_OPENER = urllib.request.OpenerDirector()
|
||||
for _h in (
|
||||
urllib.request.UnknownHandler(),
|
||||
urllib.request.HTTPDefaultErrorHandler(),
|
||||
urllib.request.HTTPErrorProcessor(),
|
||||
urllib.request.HTTPHandler(),
|
||||
urllib.request.HTTPSHandler(),
|
||||
):
|
||||
_NO_REDIRECT_OPENER.add_handler(_h)
|
||||
del _h
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Helpers
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -152,7 +167,7 @@ def _relay_request(
|
||||
request.data = body
|
||||
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=_OUTBOUND_TIMEOUT) as resp:
|
||||
with _NO_REDIRECT_OPENER.open(request, timeout=_OUTBOUND_TIMEOUT) as resp:
|
||||
data = resp.read(_MAX_RESPONSE_BODY)
|
||||
resp_headers: dict[str, str] = {}
|
||||
for k, v in resp.headers.items():
|
||||
|
||||
Reference in New Issue
Block a user