From 17115d97c62d7b3099da827f84ca4dfc6e7d111e Mon Sep 17 00:00:00 2001 From: Leonid Nikitin Date: Sun, 15 Mar 2026 20:27:58 +0500 Subject: [PATCH] Add StopForumSpam example for fetching and parsing IP blocklist data --- examples/stopforumspam.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/stopforumspam.go diff --git a/examples/stopforumspam.go b/examples/stopforumspam.go new file mode 100644 index 0000000..f5118e7 --- /dev/null +++ b/examples/stopforumspam.go @@ -0,0 +1,31 @@ +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://www.stopforumspam.com/downloads + */ + +func main() { + url := "https://www.stopforumspam.com/downloads/listed_ip_1.zip" + //url := "https://www.stopforumspam.com/downloads/listed_ip_1_ipv6.zip" + extract := parser.NewDefaultTextExtract(0, " ") + pars, err := parser.NewText(extract) + if err != nil { + panic(err) + } + // limit 0 - no limit + limit := uint(0) + config := blocklist.NewConfig(limit) + configZip := blocklist.NewConfigZip(config) + ips, err := blocklist.GetZip(url, pars, configZip) + if err != nil { + panic(err) + } + fmt.Println(ips) +}