commit
e55453bb66
@ -88,7 +88,7 @@ func init() {
|
|||||||
rootCmd.PersistentFlags().StringVarP(&logFile, "log_file", "", "console", "log file")
|
rootCmd.PersistentFlags().StringVarP(&logFile, "log_file", "", "console", "log file")
|
||||||
rootCmd.PersistentFlags().StringVarP(&logLevel, "log_level", "", "info", "log level")
|
rootCmd.PersistentFlags().StringVarP(&logLevel, "log_level", "", "info", "log level")
|
||||||
rootCmd.PersistentFlags().Int64VarP(&logMaxDays, "log_max_days", "", 3, "log max days")
|
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().BoolVarP(&disableLogColor, "disable_log_color", "", false, "disable log color in console")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "auth token")
|
rootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "auth token")
|
||||||
@ -181,7 +181,7 @@ func parseServerCommonCfgFromCmd() (cfg config.ServerCommonConf, err error) {
|
|||||||
cfg.LogFile = logFile
|
cfg.LogFile = logFile
|
||||||
cfg.LogLevel = logLevel
|
cfg.LogLevel = logLevel
|
||||||
cfg.LogMaxDays = logMaxDays
|
cfg.LogMaxDays = logMaxDays
|
||||||
cfg.LogDurationTypes = logDurationTypes
|
cfg.LogDurationTypes = logDurationTypes
|
||||||
cfg.SubDomainHost = subDomainHost
|
cfg.SubDomainHost = subDomainHost
|
||||||
cfg.TLSOnly = tlsOnly
|
cfg.TLSOnly = tlsOnly
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user