Fix #182: Fix ICMP on Docker Linux

This commit is contained in:
TwinProduction 2021-10-07 01:21:13 -04:00
parent 835f768337
commit c423afb0bf

View File

@ -85,9 +85,12 @@ func Ping(address string, config *Config) (bool, time.Duration) {
}
pinger.Count = 1
pinger.Timeout = config.Timeout
// Set the pinger's privileged mode to true for windows
// https://github.com/TwinProduction/gatus/issues/132
pinger.SetPrivileged(runtime.GOOS == "windows")
// Set the pinger's privileged mode to true for every GOOS except darwin
// See https://github.com/TwinProduction/gatus/issues/132
//
// Note that for this to work on Linux, Gatus must run with sudo privileges.
// See https://github.com/go-ping/ping#linux
pinger.SetPrivileged(runtime.GOOS != "darwin")
err = pinger.Run()
if err != nil {
return false, 0