INNER CODE UNIT · Python

get_name_server

arnonym/ha-plugins · ha-sip/src/main.py:52

def get_name_server(raw_name_server: str):
    name_server = [ns.strip() for ns in raw_name_server.split(",")]
    name_server_without_empty = [ns for ns in name_server if ns]
    if name_server_without_empty:
        log(None, f'Setting name server: {name_server}')
    return name_server_without_empty


def log_hostname_resolution(label: str, url: str) -> None:
    if not url:
        return
    hostname = urlparse(url).hostname
    if not hostname:
        log(None, f'Error: could not extract hostname from {label}: {url}')
        return
    try:
        ip = socket.gethostbyname(hostname)
        log(None, f'{label} hostname {hostname} resolves to {ip}')

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…