mirror of
https://github.com/byReqz/probehost2.git
synced 2024-11-14 11:23:13 +00:00
add logging for successful requests
This commit is contained in:
parent
2b54af9b4b
commit
053b958a60
11
main.go
11
main.go
@ -40,6 +40,11 @@ func runner(remoteip string, command string, args... string) string{
|
||||
"error": err.Error(),
|
||||
}).Warn("the following request failed:")
|
||||
}
|
||||
} else {
|
||||
logfile.WithFields(log.Fields{
|
||||
"remote_ip": remoteip,
|
||||
"command": fmt.Sprint(command, args),
|
||||
}).Info("the following request was issued without error")
|
||||
}
|
||||
return string(cmd)
|
||||
}
|
||||
@ -52,10 +57,10 @@ func ping(w http.ResponseWriter, req *http.Request) {
|
||||
geturl := strings.Split(req.URL.String(), "/")
|
||||
target := geturl[2]
|
||||
pingres := runner(req.RemoteAddr, "ping", "-c5", target)
|
||||
if pingres != "" {
|
||||
fmt.Fprintln(w, pingres)
|
||||
} else {
|
||||
if pingres == "" {
|
||||
fmt.Fprintln(w, http.StatusInternalServerError)
|
||||
} else {
|
||||
fmt.Fprintln(w, pingres)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user