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:
24
provider_ipdeny.go
Normal file
24
provider_ipdeny.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const ipdenyBaseURL = "https://www.ipdeny.com/ipblocks/data/aggregated"
|
||||
|
||||
// IPDenyProvider fetches GeoIP data from ipdeny.com.
|
||||
// IPDeny provides aggregated country-level IP blocks derived from RIR data.
|
||||
// Website: https://www.ipdeny.com/ipblocks/
|
||||
type IPDenyProvider struct{}
|
||||
|
||||
func (p *IPDenyProvider) Name() string {
|
||||
return "ipdeny"
|
||||
}
|
||||
|
||||
// FetchCIDRs downloads IPv4 CIDR blocks for a country from ipdeny.
|
||||
// URL format: https://www.ipdeny.com/ipblocks/data/aggregated/{cc}-aggregated.zone
|
||||
func (p *IPDenyProvider) FetchCIDRs(countryCode string) ([]string, error) {
|
||||
url := fmt.Sprintf("%s/%s-aggregated.zone", ipdenyBaseURL, strings.ToLower(countryCode))
|
||||
return downloadAndParseCIDRs(url)
|
||||
}
|
||||
Reference in New Issue
Block a user