diff --git a/README.md b/README.md index 190bfe0398..3c37b737e3 100644 --- a/README.md +++ b/README.md @@ -2641,7 +2641,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT] [--ca-file CA_FILE] [--ca-signing-key-file CA_SIGNING_KEY_FILE] [--auth-plugin AUTH_PLUGIN] [--cache-requests] [--cache-by-content-type] [--cache-dir CACHE_DIR] - [--proxy-pool PROXY_POOL] [--enable-web-server] + [--proxy-pool PROXY_POOL] [--forward-all] [--enable-web-server] [--enable-static-server] [--static-server-dir STATIC_SERVER_DIR] [--min-compression-length MIN_COMPRESSION_LENGTH] [--enable-reverse-proxy] [--rewrite-host-header] [--enable-metrics] @@ -2653,7 +2653,7 @@ usage: -m [-h] [--tunnel-hostname TUNNEL_HOSTNAME] [--tunnel-port TUNNEL_PORT] [--filtered-client-ips FILTERED_CLIENT_IPS] [--filtered-url-regex-config FILTERED_URL_REGEX_CONFIG] -proxy.py v2.4.8.dev8+gc703edac.d20241013 +proxy.py v0.1.dev946+gfec682b.d20251125 options: -h, --help show this help message and exit @@ -2815,6 +2815,8 @@ options: storage. --proxy-pool PROXY_POOL List of upstream proxies to use in the pool + --forward-all Default: False. Forwards all requests to the + remote proxy. --enable-web-server Default: False. Whether to enable proxy.HttpWebServerPlugin. --enable-static-server diff --git a/proxy/plugin/proxy_pool.py b/proxy/plugin/proxy_pool.py index c244adeda1..3bfea9ad58 100644 --- a/proxy/plugin/proxy_pool.py +++ b/proxy/plugin/proxy_pool.py @@ -60,6 +60,11 @@ help='List of upstream proxies to use in the pool', ) +flags.add_argument( + '--forward-all', + action='store_true', + help='Forward all requests to the proxy, including private IP requests', +) class ProxyPoolPlugin(TcpUpstreamConnectionHandler, HttpProxyBasePlugin): """Proxy pool plugin simply acts as a proxy adapter for proxy.py itself. @@ -93,10 +98,12 @@ def before_upstream_connection( """ # We don't want to send private IP requests to remote proxies try: - if ipaddress.ip_address(text_(request.host)).is_private: + if ipaddress.ip_address(text_(request.host)).is_private and not self.flags.forward_all: return request except ValueError: pass + except Exception as e: + logger.error("Unexpected error happened before upstream connection: %s", e) # If chosen proxy is the local instance, bypass upstream proxies assert self._endpoint.port and self._endpoint.hostname if self._endpoint.port == self.flags.port and \