"""Public IP address lookup via ifconfig.me.""" import logging import subprocess logger = logging.getLogger(__name__) def get_ipv4() -> str: """Fetch public IPv4 address from ifconfig.me.""" logger.debug("Executing: curl -4 ifconfig.me") result = subprocess.run(["curl", "-4", "ifconfig.me"], capture_output=True, text=True, check=False) ip = result.stdout.strip() logger.debug("IPv4 response: %s", ip) return ip def get_ipv6() -> str: """Fetch public IPv6 address from ifconfig.me.""" logger.debug("Executing: curl -6 ifconfig.me") result = subprocess.run(["curl", "-6", "ifconfig.me"], capture_output=True, text=True, check=False) ip = result.stdout.strip() logger.debug("IPv6 response: %s", ip) return ip