Add PipeCreateErrorCallback to handle pipe creation errors (#290)

* Add PipeCreateErrorCallback to handle pipe creation errors

* Add test for FailtobanPipeCreateFail

* Fix missing newline at end of file in pluginbase.go
This commit is contained in:
Boshi Lian 2023-12-24 03:54:49 -08:00 committed by GitHub
parent 295262fe68
commit 9fee039d93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 499 additions and 117 deletions

View file

@ -64,7 +64,12 @@ func main() {
UpstreamAuthFailureCallback: func(conn libplugin.ConnMetadata, method string, err error, allowmethods []string) {
ip, _, _ := net.SplitHostPort(conn.RemoteAddr())
failed, _ := cache.IncrementInt(ip, 1)
log.Debugf("failtoban: %v auth failed %v times, max allowed %v", ip, failed, maxFailures)
log.Debugf("failtoban: %v auth failed. current status: fail %v times, max allowed %v", ip, failed, maxFailures)
},
PipeCreateErrorCallback: func(remoteAddr string, err error) {
ip, _, _ := net.SplitHostPort(remoteAddr)
failed, _ := cache.IncrementInt(ip, 1)
log.Debugf("failtoban: %v pipe create failed, reason %v. current status: fail %v times, max allowed %v", ip, err, failed, maxFailures)
},
}, nil
},