From 24d0192d559f28a67aede0f0d00ab6371b799f2e Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:56:47 +0800 Subject: [PATCH 1/5] Update root.go --- cmd/frps/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/frps/root.go b/cmd/frps/root.go index caad6cd2..95825aa9 100644 --- a/cmd/frps/root.go +++ b/cmd/frps/root.go @@ -88,7 +88,7 @@ func init() { rootCmd.PersistentFlags().StringVarP(&logFile, "log_file", "", "console", "log file") rootCmd.PersistentFlags().StringVarP(&logLevel, "log_level", "", "info", "log level") rootCmd.PersistentFlags().Int64VarP(&logMaxDays, "log_max_days", "", 3, "log max days") - rootCmd.PersistentFlags().StringVarP(&logDurationTypes, "log_duration_types", "", "ssh,rdp", "log duration types") + rootCmd.PersistentFlags().StringVarP(&logDurationTypes, "log_duration_types", "", "ssh,rdp", "log duration types") rootCmd.PersistentFlags().BoolVarP(&disableLogColor, "disable_log_color", "", false, "disable log color in console") rootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "auth token") From 8a1db433e91f186063fe89795a6eac6bbced9b33 Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:59:47 +0800 Subject: [PATCH 2/5] Update root.go --- cmd/frps/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/frps/root.go b/cmd/frps/root.go index 95825aa9..02efb372 100644 --- a/cmd/frps/root.go +++ b/cmd/frps/root.go @@ -181,7 +181,7 @@ func parseServerCommonCfgFromCmd() (cfg config.ServerCommonConf, err error) { cfg.LogFile = logFile cfg.LogLevel = logLevel cfg.LogMaxDays = logMaxDays - cfg.LogDurationTypes = logDurationTypes + cfg.LogDurationTypes = logDurationTypes cfg.SubDomainHost = subDomainHost cfg.TLSOnly = tlsOnly From c2cbd3f3ef82a207d086596e9ca302d35d916c8c Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:04:36 +0800 Subject: [PATCH 3/5] Update proxy.go --- server/proxy/proxy.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index ca97d8ce..d7372e18 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -300,29 +300,29 @@ func HandleUserTCPConnection(pxy Proxy, userConn net.Conn, serverCfg config.Serv metrics.Server.AddTrafficIn(name, proxyType, inCount) metrics.Server.AddTrafficOut(name, proxyType, outCount) - if IsTheTypeToLog(serverCfg.LogDurationTypes, name) { - endtime := time.Now().UnixNano() / 1000000 // time in microseconds - connection_duration := endtime - startime - xl.Debug("join connection closed, it remains [%d]ms, workConn(l[%s] r[%s]) userConn(l[%s] r[%s])", connection_duration, - 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, - userConn.LocalAddr().String(), userConn.RemoteAddr().String()) - } else { - xl.Debug("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String()) - } + if IsTheTypeToLog(serverCfg.LogDurationTypes, name) { + endtime := time.Now().UnixNano() / 1000000 // time in microseconds + connectionDuration := endtime - startime + 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()) + xl.Info("connection closed, it remains [%d]ms, userConn(l[%s] r[%s])", connectionDuration, + userConn.LocalAddr().String(), userConn.RemoteAddr().String()) + } else { + xl.Debug("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String()) + } } func IsTheTypeToLog(LogDurationTypes string, name string) bool { - if strings.Contains(LogDurationTypes, "all") { - return true - } - thestrlist := strings.Split(LogDurationTypes, ",") - for i := 0; i < len(thestrlist); i++ { - if strings.Contains(name, thestrlist[i]) { - return true - } - } - return false + if strings.Contains(LogDurationTypes, "all") { + return true + } + thestrlist := strings.Split(LogDurationTypes, ",") + for i := 0; i < len(thestrlist); i++ { + if strings.Contains(name, thestrlist[i]) { + return true + } + } + return false } type Manager struct { From 0f60ef3ecb7bec73857f0aaf22c572fe9162a792 Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:06:56 +0800 Subject: [PATCH 4/5] Update server.go --- pkg/config/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/server.go b/pkg/config/server.go index 0f0f2e3f..675a2454 100644 --- a/pkg/config/server.go +++ b/pkg/config/server.go @@ -115,10 +115,10 @@ type ServerCommonConf struct { // value is 0. LogMaxDays int64 `ini:"log_max_days" json:"log_max_days"` // 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 string `ini:"log_duration_types" json:"log_duration_types"` + // 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 string `ini:"log_duration_types" json:"log_duration_types"` // 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"` From 8ed42b967d9732ef159fe59baf7295e9d52f22fc Mon Sep 17 00:00:00 2001 From: berlin2123 <68841407+berlin2123@users.noreply.github.com> Date: Thu, 13 Oct 2022 10:10:46 +0800 Subject: [PATCH 5/5] Update proxy.go --- server/proxy/proxy.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/proxy/proxy.go b/server/proxy/proxy.go index d7372e18..df00608c 100644 --- a/server/proxy/proxy.go +++ b/server/proxy/proxy.go @@ -306,17 +306,17 @@ func HandleUserTCPConnection(pxy Proxy, userConn net.Conn, serverCfg config.Serv 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()) 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 { xl.Debug("join connection closed, userConn(l[%s] r[%s])", userConn.LocalAddr().String(), userConn.RemoteAddr().String()) } } -func IsTheTypeToLog(LogDurationTypes string, name string) bool { - if strings.Contains(LogDurationTypes, "all") { +func IsTheTypeToLog(logDurationTypes string, name string) bool { + if strings.Contains(logDurationTypes, "all") { return true } - thestrlist := strings.Split(LogDurationTypes, ",") + thestrlist := strings.Split(logDurationTypes, ",") for i := 0; i < len(thestrlist); i++ { if strings.Contains(name, thestrlist[i]) { return true