Add BruteforceBlocker example for fetching and parsing IP blocklist data
This commit is contained in:
29
examples/bruteforceblocker.go
Normal file
29
examples/bruteforceblocker.go
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.kor-elf.net/kor-elf-shield/blocklist"
|
||||||
|
"git.kor-elf.net/kor-elf-shield/blocklist/parser"
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An example of how to get a list of IP addresses from a service https://danger.rulez.sk/index.php/bruteforceblocker/
|
||||||
|
*/
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
url := "https://danger.rulez.sk/projects/bruteforceblocker/blist.php"
|
||||||
|
extract := parser.NewDefaultTextExtract(0, "\t")
|
||||||
|
pars, err := parser.NewText(extract)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
// limit 0 - no limit
|
||||||
|
limit := uint(0)
|
||||||
|
config := blocklist.NewConfig(limit)
|
||||||
|
ips, err := blocklist.Get(url, pars, config)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
fmt.Println(ips)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user