2014-06-16 05:38:10 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"github.com/Sean-Der/fail2go"
|
2014-06-16 10:15:26 +02:00
|
|
|
"github.com/gorilla/mux"
|
2014-06-16 05:38:10 +02:00
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
func jailGetHandler(res http.ResponseWriter, req *http.Request) {
|
|
|
|
jailStatus, _ := fail2go.JailStatus(mux.Vars(req)["jail"])
|
2014-06-16 10:15:26 +02:00
|
|
|
jailFailRegex, _ := fail2go.JailFailRegex(mux.Vars(req)["jail"])
|
2014-06-16 05:38:10 +02:00
|
|
|
|
|
|
|
output := make(map[string]interface{})
|
|
|
|
|
|
|
|
for key, value := range jailStatus {
|
|
|
|
output[key] = value
|
|
|
|
}
|
2014-06-16 10:15:26 +02:00
|
|
|
for key, value := range jailFailRegex {
|
|
|
|
output[key] = value
|
|
|
|
}
|
|
|
|
|
2014-06-16 05:38:10 +02:00
|
|
|
encodedOutput, err := json.Marshal(output)
|
|
|
|
if err != nil {
|
|
|
|
}
|
|
|
|
|
|
|
|
res.Write(encodedOutput)
|
|
|
|
}
|
|
|
|
|
|
|
|
func jailHandler(jailRouter *mux.Router) {
|
|
|
|
jailRouter.HandleFunc("/{jail}", jailGetHandler).Methods("GET")
|
2014-06-16 10:15:26 +02:00
|
|
|
|
2014-06-16 05:38:10 +02:00
|
|
|
}
|