# 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/common/six.py
# def ipaddress(addr):
#     """Return an ipaddress.ip_address object from the given string IP."""
#     return _ipaddress.ip_address(addr)
# 
# Path: dyndnsc/common/constants.py
# REQUEST_HEADERS_DEFAULT = {
#     # dyndns2 standard requires that we set our own user agent:
#     "User-Agent": "python-dyndnsc/%s" % __version__,
# }


import logging
import re
import requests
    import json
from random import choice
from .base import IPDetector, AF_INET, AF_INET6, AF_UNSPEC
from ..common.six import ipaddress
from ..common import constants
    regex = re.compile(pattern)
    for line in text.splitlines():
        match_obj = regex.search(line)
        if match_obj is not None:
            return str(ipaddress(match_obj.group(1)))
    LOG.debug("Output '%s' could not be parsed", text)
    return None


def _parser_checkip_dns_he_net(text):
    return _parser_line_regex(text, pattern="Your IP address is : (.*?)(<.*){0,1}$")


def _parser_checkip(text):
    return _parser_line_regex(text, pattern="Current IP Address: (.*?)(<.*){0,1}$")


def _parser_freedns_afraid(text):
    return _parser_line_regex(text, pattern="Detected IP : (.*?)(<.*){0,1}$")


def _parser_jsonip(text):
    """Parse response text like the one returned by http://jsonip.com/."""
    try:
        return str(json.loads(text).get("ip"))
    except ValueError as exc:
        LOG.debug("Text '%s' could not be parsed", exc_info=exc)
        return 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/common/six.py
# def ipaddress(addr):
#     """Return an ipaddress.ip_address object from the given string IP."""
#     return _ipaddress.ip_address(addr)
# 
# Path: dyndnsc/common/constants.py
# REQUEST_HEADERS_DEFAULT = {
#     # dyndns2 standard requires that we set our own user agent:
#     "User-Agent": "python-dyndnsc/%s" % __version__,
# }


# Path: dyndnsc/detector/webcheck.py
import logging
import re
import requests
    import json
from random import choice
from .base import IPDetector, AF_INET, AF_INET6, AF_UNSPEC
from ..common.six import ipaddress
from ..common import constants

    regex = re.compile(pattern)
    for line in text.splitlines():
        match_obj = regex.search(line)
        if match_obj is not None:
            return str(ipaddress(match_obj.group(1)))
    LOG.debug("Output '%s' could not be parsed", text)
    return None


def _parser_checkip_dns_he_net(text):
    return _parser_line_regex(text, pattern="Your IP address is : (.*?)(<.*){0,1}$")


def _parser_checkip(text):
    return _parser_line_regex(text, pattern="Current IP Address: (.*?)(<.*){0,1}$")


def _parser_freedns_afraid(text):
    return _parser_line_regex(text, pattern="Detected IP : (.*?)(<.*){0,1}$")


def _parser_jsonip(text):
    """Parse response text like the one returned by http://jsonip.com/."""
    try:
        return str(json.loads(text).get("ip"))
    except ValueError as exc:
        LOG.debug("Text '%s' could not be parsed", exc_info=exc)
        return None



class IPDetectorWebCheckBase(IPDetector):