mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-31 02:26:36 +08:00
把tcp/udp的连接数记为访问量,增加tcp域名排名记录(需要SNI连接)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user