rename vtun to tungo

This commit is contained in:
ginuerzh
2025-07-26 16:17:04 +08:00
parent 281295d02f
commit 35a049fb03
30 changed files with 801 additions and 307 deletions
+12
View File
@@ -42,6 +42,10 @@ import (
"golang.org/x/time/rate"
)
const (
DefaultReadTimeout = 30 * time.Second
)
var (
DefaultCertPool = tls_util.NewMemoryCertPool()
)
@@ -124,6 +128,10 @@ func (h *Sniffer) HandleHTTP(ctx context.Context, conn net.Conn, opts ...HandleO
opt(&ho)
}
if h.ReadTimeout <= 0 {
h.ReadTimeout = DefaultReadTimeout
}
pStats := xstats.Stats{}
conn = stats_wrapper.WrapConn(conn, &pStats)
@@ -769,6 +777,10 @@ func (h *Sniffer) HandleTLS(ctx context.Context, conn net.Conn, opts ...HandleOp
opt(&ho)
}
if h.ReadTimeout <= 0 {
h.ReadTimeout = DefaultReadTimeout
}
buf := new(bytes.Buffer)
clientHello, err := dissector.ParseClientHello(io.TeeReader(conn, buf))
if err != nil {
+10
View File
@@ -39,6 +39,8 @@ import (
)
const (
DefaultReadTimeout = 30 * time.Second
// DefaultBodySize is the default HTTP body or websocket frame size to record.
DefaultBodySize = 64 * 1024 // 64KB
// MaxBodySize is the maximum HTTP body or websocket frame size to record.
@@ -115,6 +117,10 @@ func (h *Sniffer) HandleHTTP(ctx context.Context, conn net.Conn, opts ...HandleO
opt(&ho)
}
if h.ReadTimeout <= 0 {
h.ReadTimeout = DefaultReadTimeout
}
pStats := xstats.Stats{}
conn = stats_wrapper.WrapConn(conn, &pStats)
@@ -570,6 +576,10 @@ func (h *Sniffer) HandleTLS(ctx context.Context, conn net.Conn, opts ...HandleOp
opt(&ho)
}
if h.ReadTimeout <= 0 {
h.ReadTimeout = DefaultReadTimeout
}
buf := new(bytes.Buffer)
clientHello, err := dissector.ParseClientHello(io.TeeReader(conn, buf))
if err != nil {
+8
View File
@@ -24,6 +24,10 @@ func NewHandlerStats(service string, resetTraffic bool) *HandlerStats {
}
func (p *HandlerStats) Stats(client string) stats.Stats {
if p == nil {
return nil
}
p.mu.RLock()
pstats := p.stats[client]
p.mu.RUnlock()
@@ -43,6 +47,10 @@ func (p *HandlerStats) Stats(client string) stats.Stats {
}
func (p *HandlerStats) Events() (events []observer.Event) {
if p == nil {
return
}
p.mu.RLock()
defer p.mu.RUnlock()