From 5760c1cf92b87a9d734e6c31c626f9a4d282fde0 Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 1 Nov 2023 17:06:55 +0800 Subject: [PATCH] frpc: exit with code 1 if first login failed (#3740) --- Release.md | 2 +- client/service.go | 5 ++--- cmd/frpc/sub/root.go | 8 ++------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Release.md b/Release.md index 1660f1e..16e8324 100644 --- a/Release.md +++ b/Release.md @@ -1,3 +1,3 @@ ### Fixes -* `admin_user` is not effective in the INI configuration. +* frpc: Return code 1 when the first login attempt fails and exits. diff --git a/client/service.go b/client/service.go index 184a87a..4b394d8 100644 --- a/client/service.go +++ b/client/service.go @@ -83,8 +83,8 @@ func NewService( pxyCfgs []v1.ProxyConfigurer, visitorCfgs []v1.VisitorConfigurer, cfgFile string, -) (svr *Service, err error) { - svr = &Service{ +) *Service { + return &Service{ authSetter: auth.NewAuthSetter(cfg.Auth), cfg: cfg, cfgFile: cfgFile, @@ -93,7 +93,6 @@ func NewService( ctx: context.Background(), exit: 0, } - return } func (svr *Service) GetController() *Control { diff --git a/cmd/frpc/sub/root.go b/cmd/frpc/sub/root.go index 915e6b3..125c88c 100644 --- a/cmd/frpc/sub/root.go +++ b/cmd/frpc/sub/root.go @@ -139,10 +139,7 @@ func startService( log.Info("start frpc service for config file [%s]", cfgFile) defer log.Info("frpc service for config file [%s] stopped", cfgFile) } - svr, err := client.NewService(cfg, pxyCfgs, visitorCfgs, cfgFile) - if err != nil { - return err - } + svr := client.NewService(cfg, pxyCfgs, visitorCfgs, cfgFile) shouldGracefulClose := cfg.Transport.Protocol == "kcp" || cfg.Transport.Protocol == "quic" // Capture the exit signal if we use kcp or quic. @@ -150,6 +147,5 @@ func startService( go handleTermSignal(svr) } - _ = svr.Run(context.Background()) - return nil + return svr.Run(context.Background()) }