mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
we do not support https2http in upstream proxy mode
This commit is contained in:
parent
4d01e22f26
commit
c152e5da1a
@ -11,17 +11,3 @@ mitmproxy forwards ordinary HTTP requests to an upstream server.
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
Here, **schema** is one of http, https, http2https or https2http. The latter
|
|
||||||
two extended schema specifications control the use of HTTP and HTTPS on
|
|
||||||
mitmproxy and the upstream server. You can indicate that mitmproxy should use
|
|
||||||
HTTP, and the upstream server uses HTTPS like this:
|
|
||||||
|
|
||||||
http2https://hostname:port
|
|
||||||
|
|
||||||
And you can indicate that mitmproxy should use HTTPS while the upstream
|
|
||||||
service uses HTTP like this:
|
|
||||||
|
|
||||||
https2http://hostname:port
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,19 +100,13 @@ def parse_setheader(s):
|
|||||||
|
|
||||||
|
|
||||||
def parse_server_spec(url):
|
def parse_server_spec(url):
|
||||||
normalized_url = re.sub("^https?2", "", url)
|
p = http.parse_url(url)
|
||||||
|
if not p or not p[1] or p[0] not in ("http", "https"):
|
||||||
p = http.parse_url(normalized_url)
|
|
||||||
if not p or not p[1]:
|
|
||||||
raise configargparse.ArgumentTypeError(
|
raise configargparse.ArgumentTypeError(
|
||||||
"Invalid server specification: %s" % url
|
"Invalid server specification: %s" % url
|
||||||
)
|
)
|
||||||
|
|
||||||
if url.lower().startswith("https2http"):
|
if p[0].lower() == "https":
|
||||||
ssl = [True, False]
|
|
||||||
elif url.lower().startswith("http2https"):
|
|
||||||
ssl = [False, True]
|
|
||||||
elif url.lower().startswith("https"):
|
|
||||||
ssl = [True, True]
|
ssl = [True, True]
|
||||||
else:
|
else:
|
||||||
ssl = [False, False]
|
ssl = [False, False]
|
||||||
@ -120,6 +114,20 @@ def parse_server_spec(url):
|
|||||||
return ssl + list(p[1:3])
|
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):
|
def get_common_options(options):
|
||||||
stickycookie, stickyauth = None, None
|
stickycookie, stickyauth = None, None
|
||||||
if options.stickycookie_filt:
|
if options.stickycookie_filt:
|
||||||
@ -336,7 +344,7 @@ def common_options(parser):
|
|||||||
group.add_argument(
|
group.add_argument(
|
||||||
"-R", "--reverse",
|
"-R", "--reverse",
|
||||||
action="store",
|
action="store",
|
||||||
type=parse_server_spec,
|
type=parse_server_spec_special,
|
||||||
dest="reverse_proxy",
|
dest="reverse_proxy",
|
||||||
default=None,
|
default=None,
|
||||||
help="""
|
help="""
|
||||||
|
Loading…
Reference in New Issue
Block a user