Compare commits

..

No commits in common. "9bb840d611443a94d5e494c4a30f17f5bcadf775" and "c11523c0d58cb44361e1679143a3fa3fdbdd5655" have entirely different histories.

View File

@ -28,6 +28,7 @@ func main() {
}
blockListName := os.Args[1]
jsonListFile := os.Args[2]
fmt.Printf("generating blocklist %s\n", blockListName)
// Load blocklist config file
countries, err := readJsonListFile(jsonListFile)
@ -37,7 +38,6 @@ func main() {
// Download up to date geoip CIDR data
for i := range countries {
fmt.Println("downloading cidr list for country: ", countries[i].Name)
countries[i].v4Addresses, err = downloadAddressList(countries[i].Url)
if err != nil {
log.Fatalf("failed to download address list for county'%s': %v", countries[i].Name, err)
@ -45,12 +45,10 @@ func main() {
}
// Generate mikrotik block list
fmt.Printf("generating blocklist %s.rsc\n", blockListName)
err = generateOutput(countries, blockListName)
if err != nil {
log.Fatalf("failed to generate output file: %v", err)
}
fmt.Printf("\n\nCopy the file the router, then import the address list\n\n\t/import %s.rsc\n", blockListName)
}
func generateOutput(countries []Country, blockListName string) error {
@ -83,7 +81,7 @@ func downloadAddressList(url string) ([]string, error) {
line := scanner.Text()
_, ipnet, err := net.ParseCIDR(line)
if err != nil {
log.Printf("skipping line: failed to parse line '%s' to cidr: %v", line, err)
log.Printf("skippine line: failed to parse line '%s' to cidr: %v", line, err)
continue
}
v4Addresses = append(v4Addresses, ipnet.String())