Maint: internal/vpn package for vpn loop
This commit is contained in:
@@ -5,20 +5,20 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/gluetun/internal/openvpn"
|
||||
"github.com/qdm12/gluetun/internal/vpn"
|
||||
)
|
||||
|
||||
type openvpnHealth struct {
|
||||
looper openvpn.Looper
|
||||
type vpnHealth struct {
|
||||
looper vpn.Looper
|
||||
healthyWait time.Duration
|
||||
healthyTimer *time.Timer
|
||||
}
|
||||
|
||||
func (s *Server) onUnhealthyOpenvpn(ctx context.Context) {
|
||||
s.logger.Info("program has been unhealthy for " +
|
||||
s.openvpn.healthyWait.String() + ": restarting OpenVPN")
|
||||
_, _ = s.openvpn.looper.ApplyStatus(ctx, constants.Stopped)
|
||||
_, _ = s.openvpn.looper.ApplyStatus(ctx, constants.Running)
|
||||
s.openvpn.healthyWait += s.config.OpenVPN.Addition
|
||||
s.openvpn.healthyTimer = time.NewTimer(s.openvpn.healthyWait)
|
||||
s.vpn.healthyWait.String() + ": restarting OpenVPN")
|
||||
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Stopped)
|
||||
_, _ = s.vpn.looper.ApplyStatus(ctx, constants.Running)
|
||||
s.vpn.healthyWait += s.config.OpenVPN.Addition
|
||||
s.vpn.healthyTimer = time.NewTimer(s.vpn.healthyWait)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user