massrdns

- dynamic reverse dns lookup with rotating servers
git clone git://git.acid.vegas/massrdns.git
Log | Files | Refs | Archive | README | LICENSE

commit 451d626c80f2f34ca085ccc1fedecac2e79ae79a
parent d95e119aac4800d29eb956ec3b18f035617e0cce
Author: acidvegas <acid.vegas@acid.vegas>
Date: Thu, 21 Sep 2023 15:38:49 -0400

IP addresses were being looked up more than once

Diffstat:
Mmassrdns | 0
Mmassrdns.go | 11+++++++++--

2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/massrdns b/massrdns
Binary files differ.
diff --git 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))