diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-11-16 13:37:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-16 13:37:12 +0100 |
commit | 47ec1c9570b32ecb09dc8b904f98b4305b472b28 (patch) | |
tree | ac15580d97a956a5c8c42938f11eff2e1fca066d | |
parent | 3d26bd4aa141968ef94df289be1089e6c03c3b48 (diff) | |
parent | 4cfda51c37d314c4706e93ae627189f3792b9623 (diff) | |
download | mitmproxy-47ec1c9570b32ecb09dc8b904f98b4305b472b28.tar.gz mitmproxy-47ec1c9570b32ecb09dc8b904f98b4305b472b28.tar.bz2 mitmproxy-47ec1c9570b32ecb09dc8b904f98b4305b472b28.zip |
Merge pull request #1742 from dwfreed/patch-2
Make the upstream bind address a separate option
-rw-r--r-- | mitmproxy/options.py | 2 | ||||
-rw-r--r-- | mitmproxy/proxy/protocol/base.py | 2 | ||||
-rw-r--r-- | mitmproxy/tools/cmdline.py | 6 |
3 files changed, 9 insertions, 1 deletions
diff --git a/mitmproxy/options.py b/mitmproxy/options.py index 49791400..45f18372 100644 --- a/mitmproxy/options.py +++ b/mitmproxy/options.py @@ -69,6 +69,7 @@ class Options(optmanager.OptManager): ignore_hosts: Sequence[str] = (), listen_host: str = "", listen_port: int = LISTEN_PORT, + upstream_bind_address: str = "", mode: str = "regular", no_upstream_cert: bool = False, rawtcp: bool = False, @@ -131,6 +132,7 @@ class Options(optmanager.OptManager): self.ignore_hosts = ignore_hosts self.listen_host = listen_host self.listen_port = listen_port + self.upstream_bind_address = upstream_bind_address self.mode = mode self.no_upstream_cert = no_upstream_cert self.rawtcp = rawtcp diff --git a/mitmproxy/proxy/protocol/base.py b/mitmproxy/proxy/protocol/base.py index 4d67bb71..783d1cc8 100644 --- a/mitmproxy/proxy/protocol/base.py +++ b/mitmproxy/proxy/protocol/base.py @@ -114,7 +114,7 @@ class ServerConnectionMixin: server_address, (self.ctx.client_conn.address.host, 0), True) else: self.server_conn = connections.ServerConnection( - server_address, (self.config.options.listen_host, 0)) + server_address, (self.config.options.upstream_bind_address, 0)) self.__check_self_connect() diff --git a/mitmproxy/tools/cmdline.py b/mitmproxy/tools/cmdline.py index 8b579952..4be107a8 100644 --- a/mitmproxy/tools/cmdline.py +++ b/mitmproxy/tools/cmdline.py @@ -251,6 +251,7 @@ def get_common_options(args): ignore_hosts = args.ignore_hosts, listen_host = args.addr, listen_port = args.port, + upstream_bind_address = args.upstream_bind_address, mode = mode, no_upstream_cert = args.no_upstream_cert, spoof_source_address = args.spoof_source_address, @@ -486,6 +487,11 @@ def proxy_options(parser): action="store_true", dest="spoof_source_address", help="Use the client's IP for server-side connections" ) + group.add_argument( + "--upstream-bind-address", + action="store", type=str, dest="upstream_bind_address", default='', + help="Address to bind upstream requests to (defaults to none)" + ) def proxy_ssl_options(parser): |