Skip to content

Commit 8509bd8

Browse files
committed
refactor(proxy-anonymity): simplify AZEnv parsing with header filtering
- iterate directly over matched <pre> content without intermediate variable - normalize header keys to uppercase - filter to keep only REMOTE_ADDR and HTTP_* headers - skip noisy/heavy headers like HTTP_COOKIE - ignore malformed lines without '=' Improves parsing clarity, performance, and reduces noise for downstream classification
1 parent 3216af1 commit 8509bd8

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎proxy_checker/ProxyAnonymity.py‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,25 @@ def parse_azenv_to_dict(response: str) -> Dict[str, str]:
3434
if not match:
3535
return {}
3636

37-
content = match.group(1)
3837
headers: Dict[str, str] = {}
3938

40-
for line in content.splitlines():
41-
if "=" in line:
42-
k, v = line.split("=", 1)
43-
headers[k.strip()] = v.strip()
39+
for line in match.group(1).splitlines():
40+
if "=" not in line:
41+
continue
42+
43+
k, v = line.split("=", 1)
44+
key = k.strip().upper()
45+
value = v.strip()
46+
47+
# ✅ keep only REMOTE_ADDR and HTTP_* headers
48+
if key != "REMOTE_ADDR" and not key.startswith("HTTP_"):
49+
continue
50+
51+
# 🚫 skip noisy/heavy headers
52+
if key == "HTTP_COOKIE":
53+
continue
54+
55+
headers[key] = value
4456

4557
return headers
4658

0 commit comments

Comments
 (0)