aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/proxy/root_context.py11
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=()):