feat(client): Add network config for ICMP endpoint client (#661)
* feat(client): Add network to config * feat(client): Use network client config for pinger * feat(client): Add client network configuration and demo to README * feat(client): Add tests for pinger using network config * feat(client): Drop integration tests * feat(client): Add comment to tests * feat(client): Add tests * Update README.md --------- Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
@ -235,10 +235,7 @@ func ExecuteSSHCommand(sshClient *ssh.Client, body string, config *Config) (bool
|
||||
//
|
||||
// Note that this function takes at least 100ms, even if the address is 127.0.0.1
|
||||
func Ping(address string, config *Config) (bool, time.Duration) {
|
||||
pinger, err := ping.NewPinger(address)
|
||||
if err != nil {
|
||||
return false, 0
|
||||
}
|
||||
pinger := ping.New(address)
|
||||
pinger.Count = 1
|
||||
pinger.Timeout = config.Timeout
|
||||
// Set the pinger's privileged mode to true for every GOOS except darwin
|
||||
@ -247,7 +244,8 @@ func Ping(address string, config *Config) (bool, time.Duration) {
|
||||
// Note that for this to work on Linux, Gatus must run with sudo privileges.
|
||||
// See https://github.com/prometheus-community/pro-bing#linux
|
||||
pinger.SetPrivileged(runtime.GOOS != "darwin")
|
||||
err = pinger.Run()
|
||||
pinger.SetNetwork(config.Network)
|
||||
err := pinger.Run()
|
||||
if err != nil {
|
||||
return false, 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user