Files
gluetun/internal/healthcheck/server.go
Quentin McGaw (desktop) 0eccd068e5 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
2021-09-11 21:04:21 +00:00

39 lines
753 B
Go

package healthcheck
import (
"context"
"net"
"github.com/qdm12/gluetun/internal/configuration"
"github.com/qdm12/gluetun/internal/vpn"
"github.com/qdm12/golibs/logging"
)
var _ ServerRunner = (*Server)(nil)
type ServerRunner interface {
Run(ctx context.Context, done chan<- struct{})
}
type Server struct {
logger logging.Logger
handler *handler
resolver *net.Resolver
config configuration.Health
vpn vpnHealth
}
func NewServer(config configuration.Health,
logger logging.Logger, vpnLooper vpn.Looper) *Server {
return &Server{
logger: logger,
handler: newHandler(logger),
resolver: net.DefaultResolver,
config: config,
vpn: vpnHealth{
looper: vpnLooper,
healthyWait: config.VPN.Initial,
},
}
}