Files
rengine/shared/utils/net.py
T
Yogesh Ojha 69239333bc Refactor validation and DNS tools, implementation of onboarding wizard
- Added `clean_name` function to `validation.py` for name validation with max length.
- Simplified docstrings in `dnsx` client, parser, and service files for clarity.
- Enhanced error handling in `ViewDNSService` to prevent disabling keys on rate limits.
- Improved WHOIS service to handle concurrent inserts gracefully with integrity checks.
- Updated `Settings` class in worker config to inherit from `BaseAppSettings`.
- Added new dependencies in `pyproject.toml` for `apprise` and `cryptography`.
2026-06-21 21:56:20 +05:30

28 lines
855 B
Python

import ipaddress
import socket
from urllib.parse import urlsplit
def validate_public_https_url(raw: str, *, label: str = "URL") -> None:
parts = urlsplit(raw)
if parts.scheme != "https" or not parts.hostname:
msg = f"{label} must be an https:// URL."
raise ValueError(msg)
try:
infos = socket.getaddrinfo(parts.hostname, None)
except OSError as exc:
msg = f"Cannot resolve {label} host: {exc}"
raise ValueError(msg) from exc
for info in infos:
ip = ipaddress.ip_address(info[4][0])
if (
ip.is_private
or ip.is_loopback
or ip.is_link_local
or ip.is_reserved
or ip.is_multicast
or ip.is_unspecified
):
msg = f"{label} resolves to a disallowed address."
raise ValueError(msg)