Update proxy.go

This commit is contained in:
berlin2123 2022-10-13 10:04:36 +08:00 committed by GitHub
parent 8a1db433e9
commit c2cbd3f3ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -300,29 +300,29 @@ func HandleUserTCPConnection(pxy Proxy, userConn net.Conn, serverCfg config.Serv
metrics.Server.AddTrafficIn(name, proxyType, inCount) metrics.Server.AddTrafficIn(name, proxyType, inCount)
metrics.Server.AddTrafficOut(name, proxyType, outCount) metrics.Server.AddTrafficOut(name, proxyType, outCount)
if IsTheTypeToLog(serverCfg.LogDurationTypes, name) { if IsTheTypeToLog(serverCfg.LogDurationTypes, name) {
endtime := time.Now().UnixNano() / 1000000 // time in microseconds endtime := time.Now().UnixNano() / 1000000 // time in microseconds
connection_duration := endtime - startime connectionDuration := endtime - startime
xl.Debug("join connection closed, it remains [%d]ms, workConn(l[%s] r[%s]) userConn(l[%s] r[%s])", connection_duration, xl.Debug("join connection closed, it remains [%d]ms, workConn(l[%s] r[%s]) userConn(l[%s] r[%s])", connectionDuration,
workConn.LocalAddr().String(), workConn.RemoteAddr().String(), userConn.LocalAddr().String(), userConn.RemoteAddr().String()) workConn.LocalAddr().String(), workConn.RemoteAddr().String(), userConn.LocalAddr().String(), userConn.RemoteAddr().String())
xl.Info("connection closed, it remains [%d]ms, userConn(l[%s] r[%s])", connection_duration, xl.Info("connection closed, it remains [%d]ms, userConn(l[%s] r[%s])", connectionDuration,
userConn.LocalAddr().String(), userConn.RemoteAddr().String()) userConn.LocalAddr().String(), userConn.RemoteAddr().String())
} else { } else {
xl.Debug("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String()) xl.Debug("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String())
} }
} }
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
} }
thestrlist := strings.Split(LogDurationTypes, ",") thestrlist := strings.Split(LogDurationTypes, ",")
for i := 0; i < len(thestrlist); i++ { for i := 0; i < len(thestrlist); i++ {
if strings.Contains(name, thestrlist[i]) { if strings.Contains(name, thestrlist[i]) {
return true return true
} }
} }
return false return false
} }
type Manager struct { type Manager struct {