diff --git a/massrdns b/massrdns index e5ce5e8..c2f3935 100755 Binary files a/massrdns and b/massrdns differ diff --git a/massrdns.go b/massrdns.go index 2697ce6..ccf76b6 100644 --- a/massrdns.go +++ b/massrdns.go @@ -17,6 +17,7 @@ import ( var dnsServers []string var failureCounts = make(map[string]int) var showErrors bool +var inProgressIPs sync.Map func loadDNSServersFromFile(filePath string) ([]string, error) { var servers []string @@ -145,6 +146,12 @@ func worker(cidr *net.IPNet, resultsChan chan string) { break } + _, alreadyProcessing := inProgressIPs.LoadOrStore(ip.String(), true) + if alreadyProcessing { + continue + } + defer inProgressIPs.Delete(ip.String()) + triedServers := make(map[string]bool) retries := 10 success := false @@ -216,14 +223,14 @@ func main() { rand.Seed(time.Now().UnixNano()) - subnets, err := splitCIDR(cidr, concurrency*10) // Create more subnets than workers + subnets, err := splitCIDR(cidr, concurrency*10) if err != nil { fmt.Printf("Error splitting CIDR: %s\n", err) os.Exit(1) } if len(subnets) < concurrency { - concurrency = len(subnets) // Limit concurrency to number of subnets + concurrency = len(subnets) } cidrChan := make(chan *net.IPNet, len(subnets))