diff --git a/fail2rest.go b/fail2rest.go index 73f2ebd..4c98925 100644 --- a/fail2rest.go +++ b/fail2rest.go @@ -18,7 +18,7 @@ type ErrorBody struct { Error string } -var fail2goConn *fail2go.Fail2goConn +var fail2goConn *fail2go.Conn func main() { file, fileErr := os.Open("config.json") diff --git a/global.go b/global.go index 56c6756..b52f767 100644 --- a/global.go +++ b/global.go @@ -7,7 +7,7 @@ import ( "net/http" ) -func globalStatusHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func globalStatusHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { globalStatus, _ := fail2goConn.GlobalStatus() encodedOutput, err := json.Marshal(globalStatus) @@ -17,7 +17,7 @@ func globalStatusHandler(res http.ResponseWriter, req *http.Request, fail2goConn res.Write(encodedOutput) } -func globalPingHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func globalPingHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { globalPing, _ := fail2goConn.GlobalPing() encodedOutput, err := json.Marshal(globalPing) @@ -28,7 +28,7 @@ func globalPingHandler(res http.ResponseWriter, req *http.Request, fail2goConn * } -func globalHandler(globalRouter *mux.Router, fail2goConn *fail2go.Fail2goConn) { +func globalHandler(globalRouter *mux.Router, fail2goConn *fail2go.Conn) { globalRouter.HandleFunc("/status", func(res http.ResponseWriter, req *http.Request) { globalStatusHandler(res, req, fail2goConn) }).Methods("GET") diff --git a/jail.go b/jail.go index 679ea37..18e5a9a 100644 --- a/jail.go +++ b/jail.go @@ -7,7 +7,7 @@ import ( "net/http" ) -func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { currentlyFailed, totalFailed, fileList, currentlyBanned, totalBanned, IPList, _ := fail2goConn.JailStatus(mux.Vars(req)["jail"]) failRegexes, _ := fail2goConn.JailFailRegex(mux.Vars(req)["jail"]) findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"]) @@ -36,7 +36,7 @@ type jailBanIPBody struct { IP string } -func jailBanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailBanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailBanIPBody err := json.NewDecoder(req.Body).Decode(&input) if err != nil { @@ -51,7 +51,7 @@ func jailBanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *f res.Write(encodedOutput) } -func jailUnbanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailUnbanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailBanIPBody err := json.NewDecoder(req.Body).Decode(&input) if err != nil { @@ -70,7 +70,7 @@ type jailFailRegexBody struct { FailRegex string } -func jailAddFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailAddFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailFailRegexBody var encodedOutput []byte @@ -93,7 +93,7 @@ func jailAddFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2go res.Write(encodedOutput) } -func jailDeleteFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailDeleteFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailFailRegexBody err := json.NewDecoder(req.Body).Decode(&input) if err != nil { @@ -112,7 +112,7 @@ type jailFindTimeBody struct { FindTime int } -func jailSetFindTimeHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailSetFindTimeHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailFindTimeBody err := json.NewDecoder(req.Body).Decode(&input) @@ -135,7 +135,7 @@ type jailUseDNSBody struct { UseDNS string } -func jailSetUseDNSHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailSetUseDNSHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailUseDNSBody err := json.NewDecoder(req.Body).Decode(&input) @@ -158,7 +158,7 @@ type jailMaxRetryBody struct { MaxRetry int } -func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Fail2goConn) { +func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) { var input jailMaxRetryBody err := json.NewDecoder(req.Body).Decode(&input) @@ -178,7 +178,7 @@ func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goC } -func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Fail2goConn) { +func jailHandler(jailRouter *mux.Router, fail2goConn *fail2go.Conn) { jailRouter.HandleFunc("/{jail}/bannedip", func(res http.ResponseWriter, req *http.Request) { jailBanIPHandler(res, req, fail2goConn)