Skip to content

Commit f54bd16

Browse files
authored
Add flag to forward all requests to proxy
Added a flag '--forward-all' that sets the ProxyPool plugin to forward all requests to the remote proxy, including private requests.
1 parent fec682b commit f54bd16

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

proxy/plugin/proxy_pool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@
6060
help='List of upstream proxies to use in the pool',
6161
)
6262

63+
flags.add_argument(
64+
'--forward-all',
65+
action='store_true',
66+
help='Forward all requests to the proxy, including private IP requests'
67+
)
6368

6469
class ProxyPoolPlugin(TcpUpstreamConnectionHandler, HttpProxyBasePlugin):
6570
"""Proxy pool plugin simply acts as a proxy adapter for proxy.py itself.
@@ -93,10 +98,12 @@ def before_upstream_connection(
9398
"""
9499
# We don't want to send private IP requests to remote proxies
95100
try:
96-
if ipaddress.ip_address(text_(request.host)).is_private:
101+
if ipaddress.ip_address(text_(request.host)).is_private and not self.flags.forward_all:
97102
return request
98103
except ValueError:
99104
pass
105+
except Exception as e:
106+
logger.error(f"Unexpected error happened before upstream connection: {e}")
100107
# If chosen proxy is the local instance, bypass upstream proxies
101108
assert self._endpoint.port and self._endpoint.hostname
102109
if self._endpoint.port == self.flags.port and \

0 commit comments

Comments
 (0)