fix(health): use TCP dialing instead of ping
- `HEALTH_TARGET_ADDRESS` to replace `HEALTH_ADDRESS_TO_PING` - Remove `github.com/go-ping/ping` dependency - Dial TCP the target address, appending `:443` if port is not set
This commit is contained in:
@@ -15,10 +15,10 @@ type Health struct {
|
||||
// for the health check server.
|
||||
// It cannot be the empty string in the internal state.
|
||||
ServerAddress string
|
||||
// AddressToPing is the IP address or domain name to
|
||||
// ping periodically for the health check.
|
||||
// TargetAddress is the address (host or host:port)
|
||||
// to TCP dial to periodically for the health check.
|
||||
// It cannot be the empty string in the internal state.
|
||||
AddressToPing string
|
||||
TargetAddress string
|
||||
VPN HealthyWait
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (h Health) Validate() (err error) {
|
||||
func (h *Health) copy() (copied Health) {
|
||||
return Health{
|
||||
ServerAddress: h.ServerAddress,
|
||||
AddressToPing: h.AddressToPing,
|
||||
TargetAddress: h.TargetAddress,
|
||||
VPN: h.VPN.copy(),
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (h *Health) copy() (copied Health) {
|
||||
// unset field of the receiver settings object.
|
||||
func (h *Health) MergeWith(other Health) {
|
||||
h.ServerAddress = helpers.MergeWithString(h.ServerAddress, other.ServerAddress)
|
||||
h.AddressToPing = helpers.MergeWithString(h.AddressToPing, other.AddressToPing)
|
||||
h.TargetAddress = helpers.MergeWithString(h.TargetAddress, other.TargetAddress)
|
||||
h.VPN.mergeWith(other.VPN)
|
||||
}
|
||||
|
||||
@@ -59,13 +59,13 @@ func (h *Health) MergeWith(other Health) {
|
||||
// settings.
|
||||
func (h *Health) OverrideWith(other Health) {
|
||||
h.ServerAddress = helpers.OverrideWithString(h.ServerAddress, other.ServerAddress)
|
||||
h.AddressToPing = helpers.OverrideWithString(h.AddressToPing, other.AddressToPing)
|
||||
h.TargetAddress = helpers.OverrideWithString(h.TargetAddress, other.TargetAddress)
|
||||
h.VPN.overrideWith(other.VPN)
|
||||
}
|
||||
|
||||
func (h *Health) SetDefaults() {
|
||||
h.ServerAddress = helpers.DefaultString(h.ServerAddress, "127.0.0.1:9999")
|
||||
h.AddressToPing = helpers.DefaultString(h.AddressToPing, "github.com")
|
||||
h.TargetAddress = helpers.DefaultString(h.TargetAddress, "github.com:443")
|
||||
h.VPN.setDefaults()
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func (h Health) String() string {
|
||||
func (h Health) toLinesNode() (node *gotree.Node) {
|
||||
node = gotree.New("Health settings:")
|
||||
node.Appendf("Server listening address: %s", h.ServerAddress)
|
||||
node.Appendf("Address to ping: %s", h.AddressToPing)
|
||||
node.Appendf("Target address: %s", h.TargetAddress)
|
||||
node.AppendNode(h.VPN.toLinesNode("VPN"))
|
||||
return node
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user