From 19c8a798091365c4c03965fd388cdc9479d71f36 Mon Sep 17 00:00:00 2001 From: lqqyt2423 <974923609@qq.com> Date: Sat, 26 Mar 2022 16:04:50 +0800 Subject: [PATCH] fix #15: is tls record magic --- proxy/middle.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/proxy/middle.go b/proxy/middle.go index b387be8..a5d093c 100644 --- a/proxy/middle.go +++ b/proxy/middle.go @@ -73,7 +73,7 @@ type Middle struct { Server *http.Server } -func NewMiddle(proxy *Proxy,caPath string) (Interceptor, error) { +func NewMiddle(proxy *Proxy, caPath string) (Interceptor, error) { ca, err := cert.NewCA(caPath) if err != nil { return nil, err @@ -141,7 +141,8 @@ func (m *Middle) intercept(serverConn *connBuf) { return } - if buf[0] == 0x16 && buf[1] == 0x03 && (buf[2] >= 0x0 || buf[2] <= 0x03) { + // https://github.com/mitmproxy/mitmproxy/blob/main/mitmproxy/net/tls.py is_tls_record_magic + if buf[0] == 0x16 && buf[1] == 0x03 && (buf[2] >= 0x0 && buf[2] <= 0x03) { // tls m.Listener.(*listener).connChan <- serverConn } else {