client: add login_fail_exit params, default is true

if login_fail_exit is false, when frpc first login to server failed, it
    will continues relogin to server every 30 seconds.
This commit is contained in:
fatedier
2017-05-25 01:10:58 +08:00
parent 6c13b6d37a
commit 4dc96f41c9
9 changed files with 174 additions and 156 deletions

View File

@ -106,9 +106,20 @@ func NewControl(svr *Service, pxyCfgs map[string]config.ProxyConf) *Control {
// 7. In controler(): start new reader(), writer(), manager()
// controler() will keep running
func (ctl *Control) Run() error {
err := ctl.login()
if err != nil {
return err
for {
err := ctl.login()
if err != nil {
// if login_fail_exit is true, just exit this program
// otherwise sleep a while and continues relogin to server
if config.ClientCommonCfg.LoginFailExit {
return err
} else {
ctl.Warn("login to server fail: %v", err)
time.Sleep(30 * time.Second)
}
} else {
break
}
}
go ctl.controler()