Converts an IP address to a tuple of integers for sorting.
(self, ip)
| 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) |