diff options
author | Ujjwal Verma <ujjwalverma1111@gmail.com> | 2017-02-10 01:26:06 +0530 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-02-09 20:56:06 +0100 |
commit | d6465b907f238f50c20c51304723260c9aaa61ab (patch) | |
tree | c70535fa648fc1f14e135412e23f60cd548ef13b /mitmproxy | |
parent | 380ff50e57a56d2ff25f04350341ae013dcd2443 (diff) | |
download | mitmproxy-d6465b907f238f50c20c51304723260c9aaa61ab.tar.gz mitmproxy-d6465b907f238f50c20c51304723260c9aaa61ab.tar.bz2 mitmproxy-d6465b907f238f50c20c51304723260c9aaa61ab.zip |
Closes #1580 Gives warning when explicit proxy configured in transparent mode (#1996)
Diffstat (limited to 'mitmproxy')
-rw-r--r-- | mitmproxy/proxy/protocol/http.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py index b70afe33..da9a8781 100644 --- a/mitmproxy/proxy/protocol/http.py +++ b/mitmproxy/proxy/protocol/http.py @@ -131,7 +131,7 @@ class HTTPMode(enum.Enum): # At this point, we see only a subset of the proxy modes MODE_REQUEST_FORMS = { HTTPMode.regular: ("authority", "absolute"), - HTTPMode.transparent: ("relative"), + HTTPMode.transparent: ("relative",), HTTPMode.upstream: ("authority", "absolute"), } @@ -143,9 +143,16 @@ def validate_request_form(mode, request): ) allowed_request_forms = MODE_REQUEST_FORMS[mode] if request.first_line_format not in allowed_request_forms: - err_message = "Invalid HTTP request form (expected: %s, got: %s)" % ( - " or ".join(allowed_request_forms), request.first_line_format - ) + if mode == HTTPMode.transparent: + err_message = ( + "Mitmproxy received an {} request even though it is not running in regular mode. " + "This usually indicates a misconfiguration, please see " + "http://docs.mitmproxy.org/en/stable/modes.html for details." + ).format("HTTP CONNECT" if request.first_line_format == "authority" else "absolute-form") + else: + err_message = "Invalid HTTP request form (expected: %s, got: %s)" % ( + " or ".join(allowed_request_forms), request.first_line_format + ) raise exceptions.HttpException(err_message) |