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

Method ip_key

actions/scanning.py:635–645  ·  view source on GitHub ↗

Converts an IP address to a tuple of integers for sorting.

(self, ip)

Source from the content-addressed store, hash-verified

633 if self.blacklistcheck and (
634 mac in self.mac_scan_blacklist or h['ip'] in self.ip_scan_blacklist):
635 continue
636 try:
637 self.db.upsert_host(mac=mac, ip=h['ip'], vendor=h.get('vendor', ''))
638 self.db.update_ping_status(mac, success=True)
639 self.db.add_scan_history(mac, h['ip'], 'range_scan')
640 except Exception as exc: # noqa: BLE001
641 self.logger.debug(f"Could not persist range host {h['ip']}: {exc}")
642
643 def _ip_key(host):
644 try:
645 return tuple(int(o) for o in host['ip'].split('.'))
646 except (ValueError, AttributeError):
647 return (0, 0, 0, 0)
648 hosts.sort(key=_ip_key)

Callers 1

update_netkbMethod · 0.95

Calls 1

errorMethod · 0.80

Tested by

no test coverage detected