From d873df5ca8ec070cf4faa15c94dc80c85291d94f Mon Sep 17 00:00:00 2001 From: fatedier Date: Fri, 15 Dec 2017 11:40:08 +0800 Subject: [PATCH 1/2] let role default value to 'server' --- models/config/proxy.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/models/config/proxy.go b/models/config/proxy.go index 21e8664d..ac9853f1 100644 --- a/models/config/proxy.go +++ b/models/config/proxy.go @@ -632,6 +632,9 @@ func (cfg *StcpProxyConf) LoadFromFile(name string, section ini.Section) (err er } tmpStr := section["role"] + if tmpStr == "" { + tmpStr = "server" + } if tmpStr == "server" || tmpStr == "visitor" { cfg.Role = tmpStr } else { @@ -721,6 +724,9 @@ func (cfg *XtcpProxyConf) LoadFromFile(name string, section ini.Section) (err er } tmpStr := section["role"] + if tmpStr == "" { + tmpStr = "server" + } if tmpStr == "server" || tmpStr == "visitor" { cfg.Role = tmpStr } else { From 69f8b08ac09f22d81f2f87ad0f059ddbb995d790 Mon Sep 17 00:00:00 2001 From: fatedier Date: Sat, 16 Dec 2017 21:56:13 +0800 Subject: [PATCH 2/2] update role error log info --- models/config/proxy.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/config/proxy.go b/models/config/proxy.go index ac9853f1..ce4c1c2d 100644 --- a/models/config/proxy.go +++ b/models/config/proxy.go @@ -638,7 +638,7 @@ func (cfg *StcpProxyConf) LoadFromFile(name string, section ini.Section) (err er if tmpStr == "server" || tmpStr == "visitor" { cfg.Role = tmpStr } else { - return fmt.Errorf("Parse conf error: incorrect role [%s]", tmpStr) + return fmt.Errorf("Parse conf error: proxy [%s] incorrect role [%s]", name, tmpStr) } cfg.Sk = section["sk"] @@ -730,7 +730,7 @@ func (cfg *XtcpProxyConf) LoadFromFile(name string, section ini.Section) (err er if tmpStr == "server" || tmpStr == "visitor" { cfg.Role = tmpStr } else { - return fmt.Errorf("Parse conf error: incorrect role [%s]", tmpStr) + return fmt.Errorf("Parse conf error: proxy [%s] incorrect role [%s]", name, tmpStr) } cfg.Sk = section["sk"]