Skip to content

Commit eda3f9d

Browse files
committed
Implement jailActionHandler at jail/{jail}/action/{action} this will be used to list properties for an jail action
1 parent 4d84eda commit eda3f9d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

jail.go

+16
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goC
203203
res.Write(encodedOutput)
204204
}
205205

206+
func jailActionHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
207+
port, err := fail2goConn.JailActionProperty(mux.Vars(req)["jail"], mux.Vars(req)["action"], "port")
208+
if err != nil {
209+
writeHTTPError(res, err)
210+
return
211+
}
212+
213+
encodedOutput, _ := json.Marshal(map[string]interface{}{
214+
"port": port})
215+
res.Write(encodedOutput)
216+
}
217+
206218
func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
207219

208220
jailRouter.HandleFunc("/{jail}/bannedip", func(res http.ResponseWriter, req *http.Request) {
@@ -235,6 +247,10 @@ func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) {
235247
jailSetMaxRetryHandler(res, req, fail2goConn)
236248
}).Methods("POST")
237249

250+
jailRouter.HandleFunc("/{jail}/action/{action}", func(res http.ResponseWriter, req *http.Request) {
251+
jailActionHandler(res, req, fail2goConn)
252+
}).Methods("GET")
253+
238254
jailRouter.HandleFunc("/{jail}", func(res http.ResponseWriter, req *http.Request) {
239255
jailGetHandler(res, req, fail2goConn)
240256
}).Methods("GET")

0 commit comments

Comments
 (0)