mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 13:42:17 +01:00
Implement jailActionHandler at jail/{jail}/action/{action} this will be used to list properties for an jail action
This commit is contained in:
parent
4d84eda7db
commit
eda3f9d57c
1 changed files with 16 additions and 0 deletions
16
jail.go
16
jail.go
|
@ -203,6 +203,18 @@ func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goC
|
|||
res.Write(encodedOutput)
|
||||
}
|
||||
|
||||
func jailActionHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
||||
port, err := fail2goConn.JailActionProperty(mux.Vars(req)["jail"], mux.Vars(req)["action"], "port")
|
||||
if err != nil {
|
||||
writeHTTPError(res, err)
|
||||
return
|
||||
}
|
||||
|
||||
encodedOutput, _ := json.Marshal(map[string]interface{}{
|
||||
"port": port})
|
||||
res.Write(encodedOutput)
|
||||
}
|
||||
|
||||
func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
|
||||
|
||||
jailRouter.HandleFunc("/{jail}/bannedip", func(res http.ResponseWriter, req *http.Request) {
|
||||
|
@ -235,6 +247,10 @@ func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
|
|||
jailSetMaxRetryHandler(res, req, fail2goConn)
|
||||
}).Methods("POST")
|
||||
|
||||
jailRouter.HandleFunc("/{jail}/action/{action}", func(res http.ResponseWriter, req *http.Request) {
|
||||
jailActionHandler(res, req, fail2goConn)
|
||||
}).Methods("GET")
|
||||
|
||||
jailRouter.HandleFunc("/{jail}", func(res http.ResponseWriter, req *http.Request) {
|
||||
jailGetHandler(res, req, fail2goConn)
|
||||
}).Methods("GET")
|
||||
|
|
Loading…
Reference in a new issue