diff --git a/internal/nodes/listener_tcp.go b/internal/nodes/listener_tcp.go index 38eeeed..ba2c46f 100644 --- a/internal/nodes/listener_tcp.go +++ b/internal/nodes/listener_tcp.go @@ -55,6 +55,24 @@ func (this *TCPListener) handleConn(conn net.Conn) error { if firstServer.ReverseProxy == nil { return errors.New("no ReverseProxy configured for the server") } + + // 记录域名排行 + tlsConn, ok := conn.(*tls.Conn) + var recordStat = false + if ok { + var serverName = tlsConn.ConnectionState().ServerName + if len(serverName) > 0 { + // 统计 + stats.SharedTrafficStatManager.Add(firstServer.Id, serverName, 0, 0, 1, 0, 0, 0) + recordStat = true + } + } + + // 统计 + if !recordStat { + stats.SharedTrafficStatManager.Add(firstServer.Id, "", 0, 0, 1, 0, 0, 0) + } + originConn, err := this.connectOrigin(firstServer.ReverseProxy, conn.RemoteAddr().String()) if err != nil { return err diff --git a/internal/nodes/listener_udp.go b/internal/nodes/listener_udp.go index 1c00a30..2644e7b 100644 --- a/internal/nodes/listener_udp.go +++ b/internal/nodes/listener_udp.go @@ -147,6 +147,10 @@ func NewUDPConn(serverId int64, addr net.Addr, proxyConn *net.UDPConn, serverCon activatedAt: time.Now().Unix(), isOk: true, } + + // 统计 + stats.SharedTrafficStatManager.Add(serverId, "", 0, 0, 1, 0, 0, 0) + go func() { buffer := bytePool32k.Get() defer func() { diff --git a/internal/stats/traffic_stat_manager.go b/internal/stats/traffic_stat_manager.go index 26fe2c4..dfdedc2 100644 --- a/internal/stats/traffic_stat_manager.go +++ b/internal/stats/traffic_stat_manager.go @@ -87,7 +87,7 @@ func (this *TrafficStatManager) Start(configFunc func() *nodeconfigs.NodeConfig) // Add 添加流量 func (this *TrafficStatManager) Add(serverId int64, domain string, bytes int64, cachedBytes int64, countRequests int64, countCachedRequests int64, countAttacks int64, attackBytes int64) { - if bytes == 0 { + if bytes == 0 && countRequests == 0 { return }