|
|
@ -5,6 +5,7 @@ import (
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/cert"
|
|
|
|
"github.com/lqqyt2423/go-mitmproxy/cert"
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -26,6 +27,7 @@ func (m *MitmForward) Dial(host string) (net.Conn, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 内部解析 https 流量
|
|
|
|
// 内部解析 https 流量
|
|
|
|
|
|
|
|
// 每个连接都会消耗掉两个文件描述符,可能会达到打开文件上限
|
|
|
|
type MitmServer struct {
|
|
|
|
type MitmServer struct {
|
|
|
|
Proxy *Proxy
|
|
|
|
Proxy *Proxy
|
|
|
|
CA *cert.CA
|
|
|
|
CA *cert.CA
|
|
|
@ -45,6 +47,7 @@ func NewMitmServer(proxy *Proxy) (Mitm, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
server := &http.Server{
|
|
|
|
server := &http.Server{
|
|
|
|
|
|
|
|
IdleTimeout: time.Millisecond * 100, // 尽快关闭内部的连接,释放文件描述符
|
|
|
|
Handler: m,
|
|
|
|
Handler: m,
|
|
|
|
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), // disable http2
|
|
|
|
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)), // disable http2
|
|
|
|
TLSConfig: &tls.Config{
|
|
|
|
TLSConfig: &tls.Config{
|
|
|
|