This commit is contained in:
berlin2123 2025-03-04 19:05:46 +08:00 committed by GitHub
parent 62aecae16a
commit c07013adf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View File

@ -125,10 +125,10 @@ type ServerCommonConf struct {
// DisableLogColor disables log colors when LogWay == "console" when set to // DisableLogColor disables log colors when LogWay == "console" when set to
// true. By default, this value is false. // true. By default, this value is false.
DisableLogColor bool `ini:"disable_log_color" json:"disable_log_color"` DisableLogColor bool `ini:"disable_log_color" json:"disable_log_color"`
// LogDurationTypes specifies the type of connection name, which will log // LogDurationTypes specifies the types of connection names for which the
// the duration of those connections. if it is setting as 'ssh,rdp', it // duration will be logged. If set to 'ssh,rdp', it will log the duration
// will log the duration of the name as 'ssh', 'ssh_1', 'sshname', 'rdp', // of connections named 'ssh', 'ssh_1', 'sshname', 'rdp', 'rdp_test1', or
// 'rdp_test1' or 'web_my_rdp' . By default, this value is "ssh,rdp". // 'web_my_rdp'. By default, this value is "ssh,rdp".
LogDurationTypes string `ini:"log_duration_types" json:"log_duration_types"` LogDurationTypes string `ini:"log_duration_types" json:"log_duration_types"`
// DetailedErrorsToClient defines whether to send the specific error (with // DetailedErrorsToClient defines whether to send the specific error (with
// debug info) to frpc. By default, this value is true. // debug info) to frpc. By default, this value is true.

View File

@ -110,12 +110,18 @@ type LogConfig struct {
MaxDays int64 `json:"maxDays"` MaxDays int64 `json:"maxDays"`
// DisablePrintColor disables log colors when log.to is "console". // DisablePrintColor disables log colors when log.to is "console".
DisablePrintColor bool `json:"disablePrintColor,omitempty"` 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() { func (c *LogConfig) Complete() {
c.To = util.EmptyOr(c.To, "console") c.To = util.EmptyOr(c.To, "console")
c.Level = util.EmptyOr(c.Level, "info") c.Level = util.EmptyOr(c.Level, "info")
c.MaxDays = util.EmptyOr(c.MaxDays, 3) c.MaxDays = util.EmptyOr(c.MaxDays, 3)
c.DurationTypes = util.EmptyOr(c.DurationTypes, "ssh,rdp")
} }
type HTTPPluginOptions struct { type HTTPPluginOptions struct {

View File

@ -276,7 +276,7 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) {
connectionDuration := endtime - startime connectionDuration := endtime - startime
xl.Debugf("join connection closed, it remains [%d]ms, workConn(l[%s] r[%s]) userConn(l[%s] r[%s])", connectionDuration, 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()) 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()) userConn.LocalAddr().String(), userConn.RemoteAddr().String())
} else { } else {
xl.Debugf("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String()) xl.Debugf("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String())