feat: release v1.1.2 - hardened IP sorting with ipaddress and config sort defaults
Build and Publish Release / Build Packages and Publish (push) Successful in 10s

This commit is contained in:
soda64 committed 2026-10-03 22:18:10 +02:00
1 parent 62710d8bb7
commit 1dbbb1ce56
12 files changed
+88 -21

No files matched your search

+12 -6
View File
@@ -1,3 +1,4 @@
import ipaddress
from dataclasses import dataclass, field
from typing import Dict, List, Optional, Any
@@ -63,14 +64,19 @@ class InventoryData:
def ip_sort_key(ip: str):
clean_ip = (ip or "").strip()
if not clean_ip:
return (1, ())
return (2, 0, "")
# Strip single port if present e.g. 192.168.1.1:22
if ":" in clean_ip and not clean_ip.startswith("[") and clean_ip.count(":") == 1:
clean_ip = clean_ip.split(":")[0]
# Strip CIDR prefix if present e.g. 192.168.1.1/24
if "/" in clean_ip:
clean_ip = clean_ip.split("/")[0]
try:
parts = tuple(int(p) for p in clean_ip.split("."))
if len(parts) == 4:
return (0, parts)
addr = ipaddress.ip_address(clean_ip)
return (0, addr.version, int(addr))
except Exception:
pass
return (2, clean_ip)
return (1, 0, clean_ip.lower())
def record_key(host: HostRecord):
if sort_by.lower() == "ip":