diff options
author | Maximilian Hils <git@maximilianhils.com> | 2017-08-03 16:46:53 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2017-08-03 16:46:53 +0200 |
commit | 9ca6785d40ebe0293f36683250d72998f438bba9 (patch) | |
tree | 8a1d6aa4cb236b30491aa7bba350dc6dd9f62fd1 | |
parent | 1f98c7be4f3fa6eb56e7760fb99dfaaadbf0f541 (diff) | |
download | mitmproxy-9ca6785d40ebe0293f36683250d72998f438bba9.tar.gz mitmproxy-9ca6785d40ebe0293f36683250d72998f438bba9.tar.bz2 mitmproxy-9ca6785d40ebe0293f36683250d72998f438bba9.zip |
Revert "Remove promotion to raw TCP based on heuristics"
This reverts commit fbaade429845546d751110caa0f886f7b1a62717 for the following reasons:
- The commit only removed the proxy logic, while keeping the corresponding command line
options etc. intact. That is quite confusing.
- The switch is (and has been) off-by-default and the option help now clearly states
that this needs to be used with caution. I'd argue that constrains the potential danger.
- I have a specific use case that needs this, and implementing it as an addon is rather
difficult at the moment.
That being said, this revert is a rather pragmatic temporary decision,
the functionality should clearly be made more explicit and protocol switching should
be moved to an addon.
-rw-r--r-- | mitmproxy/proxy/root_context.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index 3d21b13c..c0ec64c9 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -104,7 +104,16 @@ class RootContext: if alpn == b'http/1.1': return protocol.Http1Layer(top_layer, http.HTTPMode.transparent) - # 6. Assume HTTP1 by default + # 6. Check for raw tcp mode + is_ascii = ( + len(d) == 3 and + # expect A-Za-z + all(65 <= x <= 90 or 97 <= x <= 122 for x in d) + ) + if self.config.options.rawtcp and not is_ascii: + return protocol.RawTCPLayer(top_layer) + + # 7. Assume HTTP1 by default return protocol.Http1Layer(top_layer, http.HTTPMode.transparent) def log(self, msg, level, subs=()): |