mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 13:42:17 +01:00
A jail's actions are now return in its top level handler
This commit is contained in:
parent
9119ebb08e
commit
4d84eda7db
1 changed files with 12 additions and 9 deletions
21
jail.go
21
jail.go
|
@ -3,12 +3,13 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/Sean-Der/fail2go"
|
|
||||||
"github.com/gorilla/mux"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/Sean-Der/fail2go"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
||||||
|
@ -22,6 +23,7 @@ func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fai
|
||||||
findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"])
|
findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"])
|
||||||
useDNS, _ := fail2goConn.JailUseDNS(mux.Vars(req)["jail"])
|
useDNS, _ := fail2goConn.JailUseDNS(mux.Vars(req)["jail"])
|
||||||
maxRetry, _ := fail2goConn.JailMaxRetry(mux.Vars(req)["jail"])
|
maxRetry, _ := fail2goConn.JailMaxRetry(mux.Vars(req)["jail"])
|
||||||
|
actions, _ := fail2goConn.JailActions(mux.Vars(req)["jail"])
|
||||||
|
|
||||||
if IPList == nil {
|
if IPList == nil {
|
||||||
IPList = []string{}
|
IPList = []string{}
|
||||||
|
@ -40,7 +42,8 @@ func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fai
|
||||||
"failRegexes": failRegexes,
|
"failRegexes": failRegexes,
|
||||||
"findTime": findTime,
|
"findTime": findTime,
|
||||||
"useDNS": useDNS,
|
"useDNS": useDNS,
|
||||||
"maxRetry": maxRetry})
|
"maxRetry": maxRetry,
|
||||||
|
"actions": actions})
|
||||||
res.Write(encodedOutput)
|
res.Write(encodedOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +159,8 @@ func jailSetFindTimeHandler(res http.ResponseWriter, req *http.Request, fail2goC
|
||||||
|
|
||||||
output, err := fail2goConn.JailSetFindTime(mux.Vars(req)["jail"], input.FindTime)
|
output, err := fail2goConn.JailSetFindTime(mux.Vars(req)["jail"], input.FindTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeHTTPError(res, err)
|
writeHTTPError(res, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedOutput, _ := json.Marshal(map[string]interface{}{"FindTime": output})
|
encodedOutput, _ := json.Marshal(map[string]interface{}{"FindTime": output})
|
||||||
|
@ -174,8 +177,8 @@ func jailSetUseDNSHandler(res http.ResponseWriter, req *http.Request, fail2goCon
|
||||||
|
|
||||||
output, err := fail2goConn.JailSetUseDNS(mux.Vars(req)["jail"], input.UseDNS)
|
output, err := fail2goConn.JailSetUseDNS(mux.Vars(req)["jail"], input.UseDNS)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeHTTPError(res, err)
|
writeHTTPError(res, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedOutput, _ := json.Marshal(map[string]interface{}{"useDNS": output})
|
encodedOutput, _ := json.Marshal(map[string]interface{}{"useDNS": output})
|
||||||
|
@ -192,8 +195,8 @@ func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goC
|
||||||
|
|
||||||
output, err := fail2goConn.JailSetMaxRetry(mux.Vars(req)["jail"], input.MaxRetry)
|
output, err := fail2goConn.JailSetMaxRetry(mux.Vars(req)["jail"], input.MaxRetry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeHTTPError(res, err)
|
writeHTTPError(res, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
encodedOutput, _ := json.Marshal(map[string]interface{}{"maxRetry": output})
|
encodedOutput, _ := json.Marshal(map[string]interface{}{"maxRetry": output})
|
||||||
|
|
Loading…
Reference in a new issue