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:
Sean DuBois 2014-07-06 13:31:25 +00:00
parent 17c57fa7f1
commit a49b9b67de
1 changed files with 3 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http"
"os"
"regexp"
"strings"
)
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) {
var input jailFailRegexBody
err := json.NewDecoder(req.Body).Decode(&input)
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 {
res.WriteHeader(400)