MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / _is_trusted_proxy

Function _is_trusted_proxy

apps/base/dependencies.py:16–28  ·  view source on GitHub ↗
(host: str)

Source from the content-addressed store, hash-verified

14
15
16def _is_trusted_proxy(host: str) -> bool:
17 try:
18 remote_addr = ip_address(host)
19 except ValueError:
20 return False
21
22 for proxy in _iter_trusted_proxies():
23 try:
24 if remote_addr in ip_network(proxy, strict=False):
25 return True
26 except ValueError:
27 continue
28 return False
29
30
31def _get_forwarded_for_ip(header_value: str, fallback_ip: str) -> str:

Callers 2

_get_forwarded_for_ipFunction · 0.85
get_client_ipFunction · 0.85

Calls 1

_iter_trusted_proxiesFunction · 0.85

Tested by

no test coverage detected