mondern slopify hand crafted code for the greater good.

(move from user specified blocklist download URLs to simply country codes with multiple providers available.)
This commit is contained in:
2026-05-01 17:18:50 -06:00
parent 746bb9c8b4
commit b1ed8f75ec
10 changed files with 576 additions and 105 deletions

27
provider.go Normal file
View File

@@ -0,0 +1,27 @@
package main
import "fmt"
// Provider defines the interface for GeoIP data sources.
// Each provider knows how to fetch IPv4 CIDR blocks for a given country.
type Provider interface {
// Name returns the human-readable name of this provider.
Name() string
// FetchCIDRs downloads and returns a slice of IPv4 CIDR strings
// for the given ISO 3166-1 alpha-2 country code (lowercase).
FetchCIDRs(countryCode string) ([]string, error)
}
// NewProvider creates a Provider by name.
// Supported providers: "ipverse", "ipdeny"
func NewProvider(name string) (Provider, error) {
switch name {
case "ipverse":
return &IPverseProvider{}, nil
case "ipdeny":
return &IPDenyProvider{}, nil
default:
return nil, fmt.Errorf("unknown provider %q (supported: ipverse, ipdeny)", name)
}
}