|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/cert"
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/cert"
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/flow"
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/flow"
|
|
|
@ -90,7 +89,7 @@ func NewMiddle(proxy *Proxy, caPath string) (Interceptor, error) {
|
|
|
|
|
|
|
|
|
|
|
|
server := &http.Server{
|
|
|
|
server := &http.Server{
|
|
|
|
Handler: m,
|
|
|
|
Handler: m,
|
|
|
|
IdleTimeout: 5 * time.Second,
|
|
|
|
// IdleTimeout: 5 * time.Second,
|
|
|
|
|
|
|
|
|
|
|
|
ConnContext: func(ctx context.Context, c net.Conn) context.Context {
|
|
|
|
ConnContext: func(ctx context.Context, c net.Conn) context.Context {
|
|
|
|
return context.WithValue(ctx, flow.ConnContextKey, c.(*tls.Conn).NetConn().(*pipeConn).connContext)
|
|
|
|
return context.WithValue(ctx, flow.ConnContextKey, c.(*tls.Conn).NetConn().(*pipeConn).connContext)
|
|
|
@ -115,6 +114,7 @@ func (m *Middle) Start() error {
|
|
|
|
return m.Server.ServeTLS(m.Listener, "", "")
|
|
|
|
return m.Server.ServeTLS(m.Listener, "", "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// todo: should block until ServerConnected
|
|
|
|
func (m *Middle) Dial(req *http.Request) (net.Conn, error) {
|
|
|
|
func (m *Middle) Dial(req *http.Request) (net.Conn, error) {
|
|
|
|
pipeClientConn, pipeServerConn := newPipes(req)
|
|
|
|
pipeClientConn, pipeServerConn := newPipes(req)
|
|
|
|
go m.intercept(pipeServerConn)
|
|
|
|
go m.intercept(pipeServerConn)
|
|
|
|