This commit is contained in:
berlin2123 2025-03-05 10:28:57 +08:00 committed by GitHub
parent 3b577109d4
commit ac9b121314
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -271,6 +271,7 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) {
metrics.Server.AddTrafficIn(name, proxyType, inCount) metrics.Server.AddTrafficIn(name, proxyType, inCount)
metrics.Server.AddTrafficOut(name, proxyType, outCount) metrics.Server.AddTrafficOut(name, proxyType, outCount)
// Log the duration of connection.
if IsTheTypeToLog(serverCfg.Log.DurationTypes, name) { if IsTheTypeToLog(serverCfg.Log.DurationTypes, name) {
endtime := time.Now().UnixNano() / 1000000 // time in microseconds endtime := time.Now().UnixNano() / 1000000 // time in microseconds
connectionDuration := endtime - startime connectionDuration := endtime - startime
@ -283,6 +284,7 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) {
} }
} }
// Check Duration should be loged or not. True: while connection name contain a string in logDurationTypes.
func IsTheTypeToLog(logDurationTypes string, name string) bool { func IsTheTypeToLog(logDurationTypes string, name string) bool {
if strings.Contains(logDurationTypes, "all") { if strings.Contains(logDurationTypes, "all") {
return true return true