Add commented examples for excluding IPs/subnets in blocklist configurations across use cases

This commit is contained in:
2026-08-12 16:29:30 +05:00
parent 407c9d961f
commit e44264c21c
9 changed files with 135 additions and 0 deletions
+24
View File
@@ -24,6 +24,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
@@ -54,6 +66,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+12
View File
@@ -22,6 +22,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+12
View File
@@ -22,6 +22,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+26
View File
@@ -22,6 +22,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
@@ -51,6 +63,20 @@ func main() {
limit := uint(0)
config := blocklist.NewConfigWithValidator(limit, &parser.IPRangeValidator{})
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithValidator(limit, &parser.IPRangeValidator{
// ExclusionChecker: exclusionChecker,
//})
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+12
View File
@@ -22,6 +22,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+12
View File
@@ -46,6 +46,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+12
View File
@@ -33,6 +33,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {
+13
View File
@@ -22,6 +22,19 @@ func main() {
// limit 0 - no limit
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
configZip := blocklist.NewConfigZip(config)
// Get IPv4 and IPv6 addresses in one list
+12
View File
@@ -22,6 +22,18 @@ func main() {
limit := uint(0)
config := blocklist.NewConfig(limit)
// If you need to exclude an IP address or subnet
//excludeIPs := []string{
// "172.18.0.2",
// //"172.18.0.0/24",
// //"172.18.0.0-172.18.0.255",
//}
//exclusionChecker, err := parser.NewExclusionChecker(excludeIPs)
//if err != nil {
// panic(err)
//}
//config := blocklist.NewConfigWithExclusionChecker(limit, exclusionChecker)
// Get IPv4 and IPv6 addresses in one list
ips, err := blocklist.Get(url, pars, config)
if err != nil {