1
This commit is contained in:
1 parent
2ea1a79bda
commit
85425483c0
50 files changed
+6468
-1854
No files matched your search
+4
-1
@@ -11,6 +11,7 @@ program than the engine's python.exe) and add pythonw.exe to the VPN's app exclu
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from request_security import trusted_request
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
@@ -26,12 +27,14 @@ class Proxy(BaseHTTPRequestHandler):
|
||||
pass
|
||||
|
||||
def _forward(self, method: str) -> None:
|
||||
if not self.client_address[0].startswith("127.") and self.client_address[0] != "::1":
|
||||
if not trusted_request(self, command=method == "POST"):
|
||||
self.send_error(403, "only from this computer")
|
||||
return
|
||||
length = int(self.headers.get("Content-Length") or 0)
|
||||
body = self.rfile.read(length) if length else None
|
||||
headers = {k: v for k, v in self.headers.items() if k.lower() not in HOP_HEADERS}
|
||||
# Preserve the validated authority so the engine can compare the browser Origin.
|
||||
headers["Host"] = self.headers["Host"]
|
||||
req = urllib.request.Request(ENGINE + self.path, data=body, method=method, headers=headers)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=30) as resp:
|
||||
|
||||
Reference in new issue
Block a user