diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-01-01 22:07:49 +0100 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-01-01 22:07:49 +0100 |
commit | c152e5da1a1a559a29d77dabd121f06ed7c7bc3e (patch) | |
tree | ccf369ca09474a5901599cf7def854c5bffa0aed /libmproxy | |
parent | 4d01e22f26dd301d2335a2dbb5890cdf38ca90e0 (diff) | |
download | mitmproxy-c152e5da1a1a559a29d77dabd121f06ed7c7bc3e.tar.gz mitmproxy-c152e5da1a1a559a29d77dabd121f06ed7c7bc3e.tar.bz2 mitmproxy-c152e5da1a1a559a29d77dabd121f06ed7c7bc3e.zip |
we do not support https2http in upstream proxy mode
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/cmdline.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libmproxy/cmdline.py b/libmproxy/cmdline.py index f5c66caa..185944da 100644 --- a/libmproxy/cmdline.py +++ b/libmproxy/cmdline.py @@ -100,19 +100,13 @@ def parse_setheader(s): def parse_server_spec(url): - normalized_url = re.sub("^https?2", "", url) - - p = http.parse_url(normalized_url) - if not p or not p[1]: + p = http.parse_url(url) + if not p or not p[1] or p[0] not in ("http", "https"): raise configargparse.ArgumentTypeError( "Invalid server specification: %s" % url ) - if url.lower().startswith("https2http"): - ssl = [True, False] - elif url.lower().startswith("http2https"): - ssl = [False, True] - elif url.lower().startswith("https"): + if p[0].lower() == "https": ssl = [True, True] else: ssl = [False, False] @@ -120,6 +114,20 @@ def parse_server_spec(url): return ssl + list(p[1:3]) +def parse_server_spec_special(url): + """ + Provides additional support for http2https and https2http schemes. + """ + normalized_url = re.sub("^https?2", "", url) + ret = parse_server_spec(normalized_url) + if url.lower().startswith("https2http"): + ret[0] = True + elif url.lower().startswith("http2https"): + ret[0] = False + return ret + + + def get_common_options(options): stickycookie, stickyauth = None, None if options.stickycookie_filt: @@ -336,7 +344,7 @@ def common_options(parser): group.add_argument( "-R", "--reverse", action="store", - type=parse_server_spec, + type=parse_server_spec_special, dest="reverse_proxy", default=None, help=""" |