Maint: rename health OpenVPN names to VPN

- `HEALTH_OPENVPN_DURATION_INITIAL` renamed to `HEALTH_VPN_DURATION_INITIAL` with retro-compatiblity
- `HEALTH_OPENVPN_DURATION_ADDITION` renamed to `HEALTH_VPN_DURATION_ADDITION` with retro-compatiblity
This commit is contained in:
Quentin McGaw (desktop)
2021-09-11 21:04:21 +00:00
parent 87f4b9e422
commit 0eccd068e5
6 changed files with 53 additions and 51 deletions

View File

@@ -23,7 +23,7 @@ func (s *Server) runHealthcheckLoop(ctx context.Context, done chan<- struct{}) {
if previousErr != nil && err == nil {
s.logger.Info("healthy!")
s.vpn.healthyTimer.Stop()
s.vpn.healthyWait = s.config.OpenVPN.Initial
s.vpn.healthyWait = s.config.VPN.Initial
} else if previousErr == nil && err != nil {
s.logger.Info("unhealthy: " + err.Error())
s.vpn.healthyTimer.Stop()
@@ -40,7 +40,7 @@ func (s *Server) runHealthcheckLoop(ctx context.Context, done chan<- struct{}) {
return
case <-timer.C:
case <-s.vpn.healthyTimer.C:
s.onUnhealthyOpenvpn(ctx)
s.onUnhealthyVPN(ctx)
}
continue
}

View File

@@ -14,11 +14,11 @@ type vpnHealth struct {
healthyTimer *time.Timer
}
func (s *Server) onUnhealthyOpenvpn(ctx context.Context) {
func (s *Server) onUnhealthyVPN(ctx context.Context) {
s.logger.Info("program has been unhealthy for " +
s.vpn.healthyWait.String() + ": restarting OpenVPN")
s.vpn.healthyWait.String() + ": restarting VPN")
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Stopped)
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Running)
s.vpn.healthyWait += s.config.OpenVPN.Addition
s.vpn.healthyWait += s.config.VPN.Addition
s.vpn.healthyTimer = time.NewTimer(s.vpn.healthyWait)
}

View File

@@ -32,7 +32,7 @@ func NewServer(config configuration.Health,
config: config,
vpn: vpnHealth{
looper: vpnLooper,
healthyWait: config.OpenVPN.Initial,
healthyWait: config.VPN.Initial,
},
}
}