Feature: make tls sni sniffing switch config

This commit is contained in:
yaling888
2022-05-16 01:34:25 +08:00
parent 891a56fd99
commit 3d25f16b3b
6 changed files with 48 additions and 21 deletions

View File

@@ -38,6 +38,9 @@ var (
// Outbound Rule
mode = Rule
// sniffing switch
sniffing = false
// default timeout for UDP session
udpTimeout = 60 * time.Second
@@ -99,6 +102,14 @@ func SetMode(m TunnelMode) {
mode = m
}
func Sniffing() bool {
return sniffing
}
func SetSniffing(s bool) {
sniffing = s
}
// SetMitmOutbound set the MITM outbound
func SetMitmOutbound(outbound C.ProxyAdapter) {
if outbound != nil {
@@ -341,6 +352,9 @@ func handleTCPConn(connCtx C.ConnContext) {
if remoteConn.Chains().Last() != "REJECT" && !isMitmOutbound {
remoteConn = statistic.NewTCPTracker(remoteConn, statistic.DefaultManager, metadata, rule)
if sniffing {
remoteConn = statistic.NewSniffing(remoteConn, metadata, rule)
}
}
defer func(remoteConn C.Conn) {