mirror of
https://gitee.com/IrisVega/frp.git
synced 2024-11-01 22:31:29 +08:00
DetailedErrorsToClient - only send detailed error info if this is on
This commit is contained in:
parent
c8748a2948
commit
f8c6795119
@ -98,6 +98,9 @@ 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 `json:"disable_log_color"`
|
DisableLogColor bool `json:"disable_log_color"`
|
||||||
|
// DetailedErrorsToClient defines whether to send the specific error (with
|
||||||
|
// debug info) to frpc. By default, this value is true.
|
||||||
|
DetailedErrorsToClient bool `json:"detailed_errors_to_client"`
|
||||||
// Token specifies the authorization token used to authenticate keys
|
// Token specifies the authorization token used to authenticate keys
|
||||||
// received from clients. Clients must have a matching token to be
|
// received from clients. Clients must have a matching token to be
|
||||||
// authorized to use the server. By default, this value is "".
|
// authorized to use the server. By default, this value is "".
|
||||||
@ -161,6 +164,7 @@ func GetDefaultServerConf() ServerCommonConf {
|
|||||||
LogLevel: "info",
|
LogLevel: "info",
|
||||||
LogMaxDays: 3,
|
LogMaxDays: 3,
|
||||||
DisableLogColor: false,
|
DisableLogColor: false,
|
||||||
|
DetailedErrorsToClient: true,
|
||||||
Token: "",
|
Token: "",
|
||||||
SubDomainHost: "",
|
SubDomainHost: "",
|
||||||
TcpMux: true,
|
TcpMux: true,
|
||||||
@ -314,6 +318,12 @@ func UnmarshalServerConfFromIni(content string) (cfg ServerCommonConf, err error
|
|||||||
cfg.DisableLogColor = true
|
cfg.DisableLogColor = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if tmpStr, ok = conf.Get("common", "detailed_errors_to_client"); ok && tmpStr == "false" {
|
||||||
|
cfg.DetailedErrorsToClient = false
|
||||||
|
} else {
|
||||||
|
cfg.DetailedErrorsToClient = true
|
||||||
|
}
|
||||||
|
|
||||||
cfg.Token, _ = conf.Get("common", "token")
|
cfg.Token, _ = conf.Get("common", "token")
|
||||||
|
|
||||||
if allowPortsStr, ok := conf.Get("common", "allow_ports"); ok {
|
if allowPortsStr, ok := conf.Get("common", "allow_ports"); ok {
|
||||||
|
@ -438,7 +438,11 @@ func (ctl *Control) manager() {
|
|||||||
ProxyName: m.ProxyName,
|
ProxyName: m.ProxyName,
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if ctl.serverCfg.DetailedErrorsToClient {
|
||||||
resp.Error = err.Error()
|
resp.Error = err.Error()
|
||||||
|
} else {
|
||||||
|
resp.Error = fmt.Sprintf("new proxy [%s] error", m.ProxyName)
|
||||||
|
}
|
||||||
xl.Warn("new proxy [%s] error: %v", m.ProxyName, err)
|
xl.Warn("new proxy [%s] error: %v", m.ProxyName, err)
|
||||||
} else {
|
} else {
|
||||||
resp.RemoteAddr = remoteAddr
|
resp.RemoteAddr = remoteAddr
|
||||||
|
@ -320,9 +320,13 @@ func (svr *Service) HandleListener(l net.Listener) {
|
|||||||
// Otherwise send success message in control's work goroutine.
|
// Otherwise send success message in control's work goroutine.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
xl.Warn("register control error: %v", err)
|
xl.Warn("register control error: %v", err)
|
||||||
|
errStr := "register control error"
|
||||||
|
if svr.cfg.DetailedErrorsToClient {
|
||||||
|
errStr = err.Error()
|
||||||
|
}
|
||||||
msg.WriteMsg(conn, &msg.LoginResp{
|
msg.WriteMsg(conn, &msg.LoginResp{
|
||||||
Version: version.Full(),
|
Version: version.Full(),
|
||||||
Error: err.Error(),
|
Error: errStr,
|
||||||
})
|
})
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
@ -331,9 +335,13 @@ func (svr *Service) HandleListener(l net.Listener) {
|
|||||||
case *msg.NewVisitorConn:
|
case *msg.NewVisitorConn:
|
||||||
if err = svr.RegisterVisitorConn(conn, m); err != nil {
|
if err = svr.RegisterVisitorConn(conn, m); err != nil {
|
||||||
xl.Warn("register visitor conn error: %v", err)
|
xl.Warn("register visitor conn error: %v", err)
|
||||||
|
errStr := "register visitor conn error"
|
||||||
|
if svr.cfg.DetailedErrorsToClient {
|
||||||
|
errStr = err.Error()
|
||||||
|
}
|
||||||
msg.WriteMsg(conn, &msg.NewVisitorConnResp{
|
msg.WriteMsg(conn, &msg.NewVisitorConnResp{
|
||||||
ProxyName: m.ProxyName,
|
ProxyName: m.ProxyName,
|
||||||
Error: err.Error(),
|
Error: errStr,
|
||||||
})
|
})
|
||||||
conn.Close()
|
conn.Close()
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user