# Path: dyndnsc/detector/base.py
# LOG = logging.getLogger(__name__)
# class IPDetector(Subject, DynamicCliMixin):
#     def __init__(self, *args, **kwargs):
#     def can_detect_offline(self):
#     def af(self):
#     def get_old_value(self):
#     def set_old_value(self, value):
#     def get_current_value(self, default=None):
#     def set_current_value(self, value):
#     def has_changed(self):
#     def configuration_key_prefix():


import logging
import dns.resolver
from .base import IPDetector, AF_INET, AF_INET6

    dnswanipprovider = dnswanipproviders[provider]  # only option as of now

    resolver = dns.resolver.Resolver()
    # first, get the IPs of the DNS servers:
    nameservers = []
    for dnsservername in dnswanipprovider[family]["@"]:
        _answers = resolver.query(qname=dnsservername, rdtype=dnswanipprovider[family]["rdtype"])
        nameservers.extend([rdata.address for rdata in _answers])
    # specify the nameservers to be used:
    resolver.nameservers = nameservers
    # finally, attempt to discover our WAN IP by querying the DNS:
    answers = resolver.query(qname=dnswanipprovider[family]["qname"], rdtype=dnswanipprovider[family]["rdtype"])
    for rdata in answers:
        return rdata.address
    return None


class IPDetector_DnsWanIp(IPDetector):
    """Detect the internet visible IP address using publicly available DNS infrastructure."""

    configuration_key = "dnswanip"

    def __init__(self, family=None, *args, **kwargs):
        """
        Initialize.

        :param family: IP address family (default: '' (ANY), also possible: 'INET', 'INET6')
        """
        if family is None:

# Path: dyndnsc/detector/base.py
# LOG = logging.getLogger(__name__)
# class IPDetector(Subject, DynamicCliMixin):
#     def __init__(self, *args, **kwargs):
#     def can_detect_offline(self):
#     def af(self):
#     def get_old_value(self):
#     def set_old_value(self, value):
#     def get_current_value(self, default=None):
#     def set_current_value(self, value):
#     def has_changed(self):
#     def configuration_key_prefix():


# Path: dyndnsc/detector/dnswanip.py
import logging
import dns.resolver
from .base import IPDetector, AF_INET, AF_INET6


    dnswanipprovider = dnswanipproviders[provider]  # only option as of now

    resolver = dns.resolver.Resolver()
    # first, get the IPs of the DNS servers:
    nameservers = []
    for dnsservername in dnswanipprovider[family]["@"]:
        _answers = resolver.query(qname=dnsservername, rdtype=dnswanipprovider[family]["rdtype"])
        nameservers.extend([rdata.address for rdata in _answers])
    # specify the nameservers to be used:
    resolver.nameservers = nameservers
    # finally, attempt to discover our WAN IP by querying the DNS:
    answers = resolver.query(qname=dnswanipprovider[family]["qname"], rdtype=dnswanipprovider[family]["rdtype"])
    for rdata in answers:
        return rdata.address
    return None


class IPDetector_DnsWanIp(IPDetector):
    """Detect the internet visible IP address using publicly available DNS infrastructure."""

    configuration_key = "dnswanip"

    def __init__(self, family=None, *args, **kwargs):
        """
        Initialize.

        :param family: IP address family (default: '' (ANY), also possible: 'INET', 'INET6')
        """
        if family is None:

            family = AF_INET