Skip to content

Commit

Permalink
frpc: exit with code 1 if first login failed (#3740)
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier authored Nov 1, 2023
1 parent 5c4d820 commit 5760c1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Release.md
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 2 additions & 3 deletions client/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -93,7 +93,6 @@ func NewService(
ctx: context.Background(),
exit: 0,
}
return
}

func (svr *Service) GetController() *Control {
Expand Down
8 changes: 2 additions & 6 deletions cmd/frpc/sub/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,13 @@ 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.
if shouldGracefulClose {
go handleTermSignal(svr)
}

_ = svr.Run(context.Background())
return nil
return svr.Run(context.Background())
}

0 comments on commit 5760c1c

Please sign in to comment.