mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
fix(proxy): keep service traffic on --proxy and warn about requests that bypass it
--proxy now overrides HTTP(S)_PROXY and the Windows system proxy while keeping the env CA bundle. Core fallback sessions use the run's proxy, and a warn-only audit hook names service code that sends a request or opens a raw socket outside the proxy; a session with proxy_exempt = True opts out.
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import Any, Callable, Optional
|
||||
import requests
|
||||
|
||||
from unshackle.core.cacher import Cacher
|
||||
from unshackle.core.utils import run_proxy
|
||||
|
||||
CACHE_KEY = "ip_info_v4"
|
||||
CACHE_TTL = 86400 # 24 hours
|
||||
@@ -113,7 +114,7 @@ def lookup_session(source: Optional[requests.Session]) -> requests.Session:
|
||||
if proxies:
|
||||
proxy = proxies.get("all") or proxies.get("https") or proxies.get("http")
|
||||
if proxy:
|
||||
sess.trust_env = False
|
||||
run_proxy.pin(sess)
|
||||
sess.proxies.update({"http": proxy, "https": proxy})
|
||||
return sess
|
||||
|
||||
|
||||
Reference in New Issue
Block a user