From c07013adf7fe0bc29b4cd7ed2874794ca84f7e40 Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Tue, 4 Mar 2025 19:05:46 +0800 Subject: [PATCH] fix --- pkg/config/legacy/server.go | 8 ++++---- pkg/config/v1/common.go | 6 ++++++ server/proxy/proxy.go | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/config/legacy/server.go b/pkg/config/legacy/server.go index 08cbb02a..0f659a2d 100644 --- a/pkg/config/legacy/server.go +++ b/pkg/config/legacy/server.go @@ -125,10 +125,10 @@ type ServerCommonConf struct { // DisableLogColor disables log colors when LogWay == "console" when set to // true. By default, this value is false. DisableLogColor bool `ini:"disable_log_color" json:"disable_log_color"` - // LogDurationTypes specifies the type of connection name, which will log - // the duration of those connections. if it is setting as 'ssh,rdp', it - // will log the duration of the name as 'ssh', 'ssh_1', 'sshname', 'rdp', - // 'rdp_test1' or 'web_my_rdp' . By default, this value is "ssh,rdp". + // LogDurationTypes specifies the types of connection names for which the + // duration will be logged. If set to 'ssh,rdp', it will log the duration + // of connections named 'ssh', 'ssh_1', 'sshname', 'rdp', 'rdp_test1', or + // 'web_my_rdp'. By default, this value is "ssh,rdp". LogDurationTypes string `ini:"log_duration_types" json:"log_duration_types"` // DetailedErrorsToClient defines whether to send the specific error (with // debug info) to frpc. By default, this value is true. diff --git a/pkg/config/v1/common.go b/pkg/config/v1/common.go index ddb23356..f8769def 100644 --- a/pkg/config/v1/common.go +++ b/pkg/config/v1/common.go @@ -110,12 +110,18 @@ type LogConfig struct { MaxDays int64 `json:"maxDays"` // DisablePrintColor disables log colors when log.to is "console". DisablePrintColor bool `json:"disablePrintColor,omitempty"` + // DurationTypes specifies the types of connection names for which the + // duration will be logged. If set to 'ssh,rdp', it will log the duration + // of connections named 'ssh', 'ssh_1', 'sshname', 'rdp', 'rdp_test1', or + // 'web_my_rdp'. By default, this value is "ssh,rdp". + DurationTypes string `json:"durationtypes,omitempty"` } func (c *LogConfig) Complete() { c.To = util.EmptyOr(c.To, "console") c.Level = util.EmptyOr(c.Level, "info") c.MaxDays = util.EmptyOr(c.MaxDays, 3) + c.DurationTypes = util.EmptyOr(c.DurationTypes, "ssh,rdp") } type HTTPPluginOptions struct { diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index dd2f7a72..64e50982 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -276,7 +276,7 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) { connectionDuration := endtime - startime xl.Debugf("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()) - xl.Info("connection closed, it remains [%d]ms, userConn(l[%s] r[%s])", connectionDuration, + xl.Infof("connection closed, it remains [%d]ms, userConn(l[%s] r[%s])", connectionDuration, userConn.LocalAddr().String(), userConn.RemoteAddr().String()) } else { xl.Debugf("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String())