[统计]记录流量(以5分钟作为间隔)

This commit is contained in:
GoEdgeLab
2020-12-11 17:27:35 +08:00
parent 6ef59a8e2f
commit e44678b734
7 changed files with 168 additions and 4 deletions

View File

@@ -69,7 +69,20 @@ func (this *HTTPRequest) doWebsocket() {
}()
go func() {
_, _ = io.Copy(clientConn, originConn)
buf := make([]byte, 4*1024) // TODO 使用内存池
for {
n, err := originConn.Read(buf)
if n > 0 {
this.writer.sentBodyBytes += int64(n)
_, err = clientConn.Write(buf[:n])
if err != nil {
break
}
}
if err != nil {
break
}
}
_ = clientConn.Close()
_ = originConn.Close()
}()