feat: release v1.1.0 - clean YAML, wildcard DNS protection, and tag/group/source filtering
Build and Publish Release / Build Packages and Publish (push) Successful in 9s

This commit is contained in:
soda64 committed 2026-10-03 11:41:25 +02:00
1 parent 5fedc44c6b
commit 598e5d7397
18 files changed
+318 -22

No files matched your search

+58 -4
View File
@@ -20,7 +20,8 @@ class ProxmoxCollector(BaseCollector):
verify_ssl: bool = False,
timeout: int = 10,
default_user: str = "lain",
quiet: bool = False
quiet: bool = False,
resolve_dns: bool = True
) -> None:
# Normalize base URL (strip trailing slashes and /api2/json if included)
clean_url = url.rstrip("/")
@@ -32,6 +33,8 @@ class ProxmoxCollector(BaseCollector):
self.timeout = timeout
self.default_user = default_user
self.quiet = quiet
self.resolve_dns = resolve_dns
self.wildcard_ip: Optional[str] = self._detect_wildcard_dns() if self.resolve_dns else None
if not self.verify_ssl:
self.ssl_context = ssl._create_unverified_context()
@@ -62,12 +65,63 @@ class ProxmoxCollector(BaseCollector):
cleaned = re.sub(r"[,;]", " ", str(raw_tags))
return [t.strip() for t in cleaned.split() if t.strip()]
def _resolve_dns_ip(self, name: str) -> Optional[str]:
def _detect_wildcard_dns(self) -> Optional[str]:
"""Detect if local DNS environment resolves non-existent hostnames to a wildcard IP."""
try:
return socket.gethostbyname(name)
import uuid
test_host = f"nxdomain-probe-{uuid.uuid4().hex[:12]}"
ip = socket.gethostbyname(test_host)
if ip and not self.quiet:
sys.stderr.write(f"[INFO] Detected DNS wildcard catch-all resolving to '{ip}'. Collision protection active.\n")
return ip
except Exception:
return None
def _resolve_dns_ip(self, name: str) -> Optional[str]:
if not self.resolve_dns:
return None
try:
resolved = socket.gethostbyname(name)
if self.wildcard_ip and resolved == self.wildcard_ip:
# Wildcard catch-all detected; not a genuine host-specific resolution
return None
return resolved
except Exception:
return None
def _resolve_node_ip(self, node_name: str, node_info: Dict[str, Any]) -> str:
# 1. From node info if present
if node_info.get("ip"):
return str(node_info["ip"])
# 2. Query /nodes/{node}/network for active physical bridge (vmbr0) or IP
net_data = self._api_get(f"/nodes/{node_name}/network")
if isinstance(net_data, list):
# Prefer vmbr0 or interface with gateway
for iface in net_data:
addr = iface.get("address")
if addr and not str(addr).startswith("127."):
if iface.get("iface") == "vmbr0" or iface.get("gateway"):
return str(addr)
for iface in net_data:
addr = iface.get("address")
if addr and not str(addr).startswith("127."):
return str(addr)
# 3. Safe DNS fallback
dns_ip = self._resolve_dns_ip(node_name)
if dns_ip:
return dns_ip
# 4. Fallback if base_url contains IP
m = re.search(r"://([^:/]+)", self.base_url)
if m:
host_part = m.group(1)
if re.match(r"^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$", host_part):
return host_part
return ""
def _resolve_qemu_ip(self, node: str, vmid: int, vm_name: str) -> str:
# 1. Try QEMU Guest Agent
agent_data = self._api_get(f"/nodes/{node}/qemu/{vmid}/agent/network-get-interfaces")
@@ -128,7 +182,7 @@ class ProxmoxCollector(BaseCollector):
continue
# Hypervisor physical node
node_ip = node_info.get("ip") or self._resolve_dns_ip(node_name) or ""
node_ip = self._resolve_node_ip(node_name, node_info)
records.append(HostRecord(
name=node_name,
ansible_host=node_ip,