MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / run_initial_ping_sweep

Method run_initial_ping_sweep

actions/scanning.py:589–627  ·  view source on GitHub ↗

Run a lightweight ARP + ping discovery, typically after Wi-Fi connects.

(self, include_arp_scan=True, cidrs=None)

Source from the content-addressed store, hash-verified

587 return ping_discovered
588
589 def run_initial_ping_sweep(self, include_arp_scan=True, cidrs=None):
590 """Run a lightweight ARP + ping discovery, typically after Wi-Fi connects."""
591 try:
592 target_cidrs = list(cidrs) if cidrs else []
593 if not target_cidrs:
594 network = None
595 try:
596 network = self.get_network()
597 except Exception as network_error:
598 self.logger.warning(f"Unable to determine current network for ping sweep: {network_error}")
599 if network:
600 target_cidrs.append(str(network))
601 else:
602 self.logger.error(
603 "Initial ping sweep aborted: no target CIDR and "
604 "network detection failed")
605 return {}
606
607 self.logger.info(f"🚀 Initial ping sweep requested across {', '.join(target_cidrs)}")
608 arp_hosts = self.run_arp_scan(network=network) if include_arp_scan else {}
609 ping_results = self._ping_sweep_missing_hosts(
610 arp_hosts,
611 target_cidrs=target_cidrs
612 )
613
614 summary = {
615 'arp_hosts': len(arp_hosts),
616 'ping_hosts': len(ping_results),
617 'target_cidrs': target_cidrs
618 }
619 self.logger.info(
620 f"📡 Initial ping sweep complete: {summary['arp_hosts']} ARP hosts, "
621 f"{summary['ping_hosts']} ping-only hosts"
622 )
623 return summary
624 except Exception as exc:
625 self.logger.error(f"Initial ping sweep failed: {exc}")
626 self.logger.debug(f"Full traceback: {traceback.format_exc()}")
627 return None
628
629 def get_current_timestamp(self):
630 """

Callers 1

Calls 8

get_networkMethod · 0.95
run_arp_scanMethod · 0.95
warningMethod · 0.80
appendMethod · 0.80
errorMethod · 0.80
infoMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected