mirror of
https://github.com/fatedier/frp.git
synced 2025-04-24 16:51:27 +00:00
change default to empty string
This commit is contained in:
parent
ac9b121314
commit
2d6712aed2
@ -128,7 +128,7 @@ type ServerCommonConf struct {
|
||||
// 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".
|
||||
// 'web_my_rdp'. By default, this value is "".
|
||||
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.
|
||||
@ -215,7 +215,7 @@ func GetDefaultServerConf() ServerCommonConf {
|
||||
DashboardAddr: "0.0.0.0",
|
||||
LogFile: "console",
|
||||
LogWay: "console",
|
||||
LogDurationTypes: "ssh,rdp",
|
||||
LogDurationTypes: "",
|
||||
DetailedErrorsToClient: true,
|
||||
TCPMux: true,
|
||||
AllowPorts: make(map[int]struct{}),
|
||||
|
@ -113,7 +113,7 @@ type LogConfig struct {
|
||||
// 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".
|
||||
// 'web_my_rdp'. By default, this value is "".
|
||||
DurationTypes string `json:"durationtypes,omitempty"`
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ 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")
|
||||
c.DurationTypes = util.EmptyOr(c.DurationTypes, "")
|
||||
}
|
||||
|
||||
type HTTPPluginOptions struct {
|
||||
|
@ -63,6 +63,7 @@ type Proxy interface {
|
||||
|
||||
type BaseProxy struct {
|
||||
name string
|
||||
logDuration bool
|
||||
rc *controller.ResourceController
|
||||
listeners []net.Listener
|
||||
usedPortsNum int
|
||||
@ -272,7 +273,7 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) {
|
||||
metrics.Server.AddTrafficOut(name, proxyType, outCount)
|
||||
|
||||
// Log the duration of connection.
|
||||
if IsTheTypeToLog(serverCfg.Log.DurationTypes, name) {
|
||||
if pxy.logDuration {
|
||||
endtime := time.Now().UnixNano() / 1000000 // time in microseconds
|
||||
connectionDuration := endtime - startime
|
||||
xl.Debugf("join connection closed, it remains [%d]ms, workConn(l[%s] r[%s]) userConn(l[%s] r[%s])", connectionDuration,
|
||||
@ -285,13 +286,15 @@ func (pxy *BaseProxy) handleUserTCPConnection(userConn net.Conn) {
|
||||
}
|
||||
|
||||
// Check Duration should be loged or not. True: while connection name contain a string in logDurationTypes.
|
||||
func IsTheTypeToLog(logDurationTypes string, name string) bool {
|
||||
func IsTheTypeToLog(logDurationTypes string, name string, xl *xlog.Logger) bool {
|
||||
if strings.Contains(logDurationTypes, "all") {
|
||||
xl.Infof("The duration of each connection through this Proxy will be logged.")
|
||||
return true
|
||||
}
|
||||
thestrlist := strings.Split(logDurationTypes, ",")
|
||||
for i := 0; i < len(thestrlist); i++ {
|
||||
if strings.Contains(name, thestrlist[i]) {
|
||||
if (thestrlist[i]!="") && strings.Contains(name, thestrlist[i]) {
|
||||
xl.Infof("The duration of each connection through this Proxy will be logged.")
|
||||
return true
|
||||
}
|
||||
}
|
||||
@ -320,6 +323,7 @@ func NewProxy(ctx context.Context, options *Options) (pxy Proxy, err error) {
|
||||
|
||||
basePxy := BaseProxy{
|
||||
name: configurer.GetBaseConfig().Name,
|
||||
logDuration: IsTheTypeToLog(options.ServerCfg.Log.DurationTypes, configurer.GetBaseConfig().Name, xl),
|
||||
rc: options.ResourceController,
|
||||
listeners: make([]net.Listener, 0),
|
||||
poolCount: options.PoolCount,
|
||||
|
Loading…
x
Reference in New Issue
Block a user