Add support for the special fail2ban form <HOST> all <HOST> instances are now replaced with (?:::f{4,6}:)?(?P<host>\S+)
This commit is contained in:
parent
17c57fa7f1
commit
a49b9b67de
4
jail.go
4
jail.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
||||||
|
@ -126,10 +127,11 @@ type RegexResult struct {
|
||||||
func jailTestFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
|
func jailTestFailRegexHandler(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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
regexp, err := regexp.Compile(input.FailRegex)
|
regexp, err := regexp.Compile(strings.Replace(input.FailRegex, "<HOST>", "(?:::f{4,6}:)?(?P<host>\\S+)", -1))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.WriteHeader(400)
|
res.WriteHeader(400)
|
||||||
|
|
Loading…
Reference in New Issue