add fallback to request if it fails

This commit is contained in:
Nils 2021-12-23 01:44:07 +01:00
parent 9af6ed7b41
commit 2b54af9b4b
Signed by: byreqz
GPG Key ID: 396A62D7D436749E
1 changed files with 5 additions and 1 deletions

View File

@ -52,7 +52,11 @@ func ping(w http.ResponseWriter, req *http.Request) {
geturl := strings.Split(req.URL.String(), "/")
target := geturl[2]
pingres := runner(req.RemoteAddr, "ping", "-c5", target)
fmt.Fprintln(w, pingres)
if pingres != "" {
fmt.Fprintln(w, pingres)
} else {
fmt.Fprintln(w, http.StatusInternalServerError)
}
}
func main() {