本文整理汇总了Golang中github.com/Sean-Der/fail2go.Conn类的典型用法代码示例。如果您正苦于以下问题:Golang Conn类的具体用法?Golang Conn怎么用?Golang Conn使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Conn类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: jailTestFailRegexHandler
func jailTestFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
var input jailFailRegexBody
json.NewDecoder(req.Body).Decode(&input)
regexp, err := regexp.Compile(strings.Replace(input.FailRegex, "<HOST>", "(?:::f{4,6}:)?(?P<host>\\S+)", -1))
if err != nil {
writeHTTPError(res, err)
return
}
_, _, fileList, _, _, _, err := fail2goConn.JailStatus(mux.Vars(req)["jail"])
if err != nil {
writeHTTPError(res, err)
return
}
output := make(map[string][]RegexResult)
for _, fileName := range fileList {
file, err := os.Open(fileName)
if err != nil {
writeHTTPError(res, err)
return
}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
output[fileName] = append(output[fileName], RegexResult{Match: regexp.MatchString(scanner.Text()), Line: scanner.Text()})
}
}
encodedOutput, _ := json.Marshal(output)
res.Write(encodedOutput)
}
开发者ID:Erreur32,项目名称:fail2rest,代码行数:33,代码来源:jail.go
示例2: jailUnbanIPHandler
func jailUnbanIPHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
var input jailBanIPBody
json.NewDecoder(req.Body).Decode(&input)
output, err := fail2goConn.JailUnbanIP(mux.Vars(req)["jail"], input.IP)
if err != nil {
writeHTTPError(res, err)
return
}
encodedOutput, _ := json.Marshal(map[string]interface{}{"unBannedIP": output})
res.Write(encodedOutput)
}
开发者ID:Erreur32,项目名称:fail2rest,代码行数:12,代码来源:jail.go
示例3: jailDeleteFailRegexHandler
func jailDeleteFailRegexHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
var input jailFailRegexBody
json.NewDecoder(req.Body).Decode(&input)
output, err := fail2goConn.JailDeleteFailRegex(mux.Vars(req)["jail"], input.FailRegex)
if err != nil {
writeHTTPError(res, err)
return
}
encodedOutput, _ := json.Marshal(map[string]interface{}{"FailRegex": output})
res.Write(encodedOutput)
}
开发者ID:Erreur32,项目名称:fail2rest,代码行数:13,代码来源:jail.go
示例4: jailSetMaxRetryHandler
func jailSetMaxRetryHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
var input jailMaxRetryBody
json.NewDecoder(req.Body).Decode(&input)
output, err := fail2goConn.JailSetMaxRetry(mux.Vars(req)["jail"], input.MaxRetry)
if err != nil {
writeHTTPError(res, err)
return
}
encodedOutput, _ := json.Marshal(map[string]interface{}{"maxRetry": output})
res.Write(encodedOutput)
}
开发者ID:Erreur32,项目名称:fail2rest,代码行数:13,代码来源:jail.go
示例5: jailGetHandler
func jailGetHandler(res http.ResponseWriter, req *http.Request, fail2goConn *fail2go.Conn) {
currentlyFailed, totalFailed, fileList, currentlyBanned, totalBanned, IPList, err := fail2goConn.JailStatus(mux.Vars(req)["jail"])
if err != nil {
writeHTTPError(res, err)
return
}
failRegexes, _ := fail2goConn.JailFailRegex(mux.Vars(req)["jail"])
findTime, _ := fail2goConn.JailFindTime(mux.Vars(req)["jail"])
useDNS, _ := fail2goConn.JailUseDNS(mux.Vars(req)["jail"])
maxRetry, _ := fail2goConn.JailMaxRetry(mux.Vars(req)["jail"])
if IPList == nil {
IPList = []string{}
}
if failRegexes == nil {
failRegexes = []string{}
}
encodedOutput, _ := json.Marshal(map[string]interface{}{
"currentlyFailed": currentlyFailed,
"totalFailed": totalFailed,
"fileList": fileList,
"currentlyBanned": currentlyBanned,
"totalBanned": totalBanned,
"IPList": IPList,
"failRegexes": failRegexes,
"findTime": findTime,
"useDNS": useDNS,
"maxRetry": maxRetry})
res.Write(encodedOutput)
}
开发者ID:Erreur32,项目名称:fail2rest,代码行数:32,代码来源:jail.go
注:本文中的github.com/Sean-Der/fail2go.Conn类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论