MCPcopy Create free account
hub / github.com/MorDavid/NetworkHound / test_connectivity_threaded

Method test_connectivity_threaded

core/dns_resolver.py:267–303  ·  view source on GitHub ↗

Test connectivity to multiple hosts using threading

(self, hostnames)

Source from the content-addressed store, hash-verified

265 return ip_records
266
267 def test_connectivity_threaded(self, hostnames):
268 """Test connectivity to multiple hosts using threading"""
269 if not hostnames:
270 return {}
271
272 logger.info(f"🏓 Starting threaded ping test for {len(hostnames)} hosts...")
273 logger.info(f"🧵 Using {self.max_threads} concurrent threads")
274
275 connectivity_results = {}
276
277 # Use ThreadPoolExecutor for concurrent ping tests
278 with ThreadPoolExecutor(max_workers=self.max_threads) as executor:
279 # Submit all ping tasks
280 future_to_hostname = {
281 executor.submit(self.test_connectivity, hostname): hostname
282 for hostname in hostnames
283 }
284
285 # Collect results as they complete
286 completed = 0
287 for future in as_completed(future_to_hostname):
288 hostname = future_to_hostname[future]
289 completed += 1
290
291 try:
292 is_online = future.result()
293 connectivity_results[hostname] = is_online
294 status = "Online" if is_online else "Offline"
295 logger.debug(f"[{completed}/{len(hostnames)}] {hostname}: {status}")
296 except Exception as e:
297 connectivity_results[hostname] = False
298 logger.debug(f"[{completed}/{len(hostnames)}] {hostname}: Error - {e}")
299
300 online_count = sum(1 for online in connectivity_results.values() if online)
301 logger.info(f"📊 Ping test complete: {online_count}/{len(hostnames)} hosts online")
302
303 return connectivity_results
304
305
306def match_ips_to_subnets(ad_subnets, ip_records):

Callers 2

mainFunction · 0.95
scan_ip_range_with_nameFunction · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected