Files
gluetun/internal/healthcheck/server.go
Quentin McGaw (desktop) 6627cda96c Feat: HEALTH_ADDRESS_TO_PING variable
- Defaults to `1.1.1.1`
- Add more Ping integration tests with different addresses
- Add unit test pinging 127.0.0.1
- Add comment explaining why we need to use ICMP instead of UDP
2021-09-11 22:22:55 +00:00

38 lines
742 B
Go

package healthcheck
import (
"context"
"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
pinger Pinger
config configuration.Health
vpn vpnHealth
}
func NewServer(config configuration.Health,
logger logging.Logger, vpnLooper vpn.Looper) *Server {
return &Server{
logger: logger,
handler: newHandler(logger),
pinger: newPinger(config.AddressToPing),
config: config,
vpn: vpnHealth{
looper: vpnLooper,
healthyWait: config.VPN.Initial,
},
}
}