mirror of
https://github.com/Sean-Der/fail2rest.git
synced 2024-12-22 21:52:18 +01:00
fail2go pkg renamed Fail2goConn -> Conn so fully qualified name would just read fail2go.Conn
This commit is contained in:
parent
1f93c63ea1
commit
6ac04f33cf
3 changed files with 13 additions and 13 deletions
|
@ -18,7 +18,7 @@ type ErrorBody struct {
|
||||||
Error string
|
Error string
|
||||||
}
|
}
|
||||||
|
|
||||||
var fail2goConn *fail2go.Fail2goConn
|
var fail2goConn *fail2go.Conn
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
file, fileErr := os.Open("config.json")
|
file, fileErr := os.Open("config.json")
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net/http"
|
"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()
|
globalStatus, _ := fail2goConn.GlobalStatus()
|
||||||
|
|
||||||
encodedOutput, err := json.Marshal(globalStatus)
|
encodedOutput, err := json.Marshal(globalStatus)
|
||||||
|
@ -17,7 +17,7 @@ func globalStatusHandler(res http.ResponseWriter, req *http.Request, fail2goConn
|
||||||
res.Write(encodedOutput)
|
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()
|
globalPing, _ := fail2goConn.GlobalPing()
|
||||||
|
|
||||||
encodedOutput, err := json.Marshal(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) {
|
globalRouter.HandleFunc("/status", func(res http.ResponseWriter, req *http.Request) {
|
||||||
globalStatusHandler(res, req, fail2goConn)
|
globalStatusHandler(res, req, fail2goConn)
|
||||||
}).Methods("GET")
|
}).Methods("GET")
|
||||||
|
|
18
jail.go
18
jail.go
|
@ -7,7 +7,7 @@ import (
|
||||||
"net/http"
|
"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"])
|
currentlyFailed, totalFailed, fileList, currentlyBanned, totalBanned, IPList, _ := fail2goConn.JailStatus(mux.Vars(req)["jail"])
|
||||||
failRegexes, _ := fail2goConn.JailFailRegex(mux.Vars(req)["jail"])
|
failRegexes, _ := fail2goConn.JailFailRegex(mux.Vars(req)["jail"])
|
||||||
findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"])
|
findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"])
|
||||||
|
@ -36,7 +36,7 @@ type jailBanIPBody struct {
|
||||||
IP string
|
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
|
var input jailBanIPBody
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
err := json.NewDecoder(req.Body).Decode(&input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,7 +51,7 @@ func jailBanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *f
|
||||||
res.Write(encodedOutput)
|
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
|
var input jailBanIPBody
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
err := json.NewDecoder(req.Body).Decode(&input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -70,7 +70,7 @@ type jailFailRegexBody struct {
|
||||||
FailRegex string
|
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 input jailFailRegexBody
|
||||||
var encodedOutput []byte
|
var encodedOutput []byte
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ func jailAddFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2go
|
||||||
res.Write(encodedOutput)
|
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
|
var input jailFailRegexBody
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
err := json.NewDecoder(req.Body).Decode(&input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -112,7 +112,7 @@ type jailFindTimeBody struct {
|
||||||
FindTime int
|
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
|
var input jailFindTimeBody
|
||||||
|
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
err := json.NewDecoder(req.Body).Decode(&input)
|
||||||
|
@ -135,7 +135,7 @@ type jailUseDNSBody struct {
|
||||||
UseDNS string
|
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
|
var input jailUseDNSBody
|
||||||
|
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
err := json.NewDecoder(req.Body).Decode(&input)
|
||||||
|
@ -158,7 +158,7 @@ type jailMaxRetryBody struct {
|
||||||
MaxRetry int
|
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
|
var input jailMaxRetryBody
|
||||||
|
|
||||||
err := json.NewDecoder(req.Body).Decode(&input)
|
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) {
|
jailRouter.HandleFunc("/{jail}/bannedip", func(res http.ResponseWriter, req *http.Request) {
|
||||||
jailBanIPHandler(res, req, fail2goConn)
|
jailBanIPHandler(res, req, fail2goConn)
|
||||||
|
|
Loading…
Reference in a new issue