Files
ducoterra e360546de9
Build and Push Container / build-and-push (push) Successful in 19s
init
2026-08-01 19:07:05 -04:00

25 lines
762 B
Python

"""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