mirror of https://github.com/statping/statping
gh actions, ping command for windows
parent
2037359fad
commit
759798e1da
|
@ -5,6 +5,11 @@ on:
|
|||
- dev
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
|
||||
jobs:
|
||||
compile:
|
||||
|
|
|
@ -29,14 +29,14 @@ func DirWritable(path string) (bool, error) {
|
|||
func Ping(address string, secondsTimeout int) (int64, error) {
|
||||
ping, err := exec.LookPath("ping")
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
out, _, err := Command(ping, address, "-n", "1", "-w", strconv.Itoa(secondsTimeout*1000))
|
||||
if err != nil {
|
||||
return err
|
||||
return 0, err
|
||||
}
|
||||
if strings.Contains(out, "Destination Host Unreachable") {
|
||||
return errors.New("destination host unreachable")
|
||||
return 0, errors.New("destination host unreachable")
|
||||
}
|
||||
r := regexp.MustCompile(`Average = (.*)ms`)
|
||||
strs := r.FindStringSubmatch(out)
|
||||
|
|
Loading…
Reference in New Issue