Exemple #1
0
 def get_dmz_settings(self):
     # DMZ not supported at all
     settings = DMZSettings()
     settings.set_supported_status(False)
     settings.set_enabled_status(False)
     settings.set_ip('0.0.0.0')
     return settings
Exemple #2
0
def _parse_dmz_settings(html):
    settings = DMZSettings()
    settings.set_supported_status(True)
    settings.set_reboot_requirement_status(False)

    match_obj = re.compile('var\sdef_DMZIP\s=\s"(.*)";').search(html)
    if match_obj is None:
        raise RouterParseError('Cannot determine DMZ IP address')
    settings.set_ip(match_obj.group(1))

    match_obj = re.compile('var\sdef_dmzen\s=\s"(.+?)";').search(html)
    if match_obj is None:
        raise RouterParseError('Cannot determine DMZ enabled status')
    settings.set_enabled_status(match_obj.group(1) == '1')
    return settings
Exemple #3
0
 def get_dmz_settings(self):
     # DMZ breaks remote management for this router..
     # so we're not enabling support for it at all
     settings = DMZSettings()
     settings.set_supported_status(False)
     settings.set_enabled_status(False)
     settings.set_ip('0.0.0.0')
     return settings
Exemple #4
0
 def get_dmz_settings(self):
     # DMZ not supported at all
     settings = DMZSettings()
     settings.set_supported_status(False)
     settings.set_enabled_status(False)
     settings.set_ip('0.0.0.0')
     return settings
Exemple #5
0
 def get_dmz_settings(self):
     # DMZ breaks remote management for this router..
     # so we're not enabling support for it at all
     settings = DMZSettings()
     settings.set_supported_status(False)
     settings.set_enabled_status(False)
     settings.set_ip('0.0.0.0')
     return settings
Exemple #6
0
def _parse_dmz_settings(html):
    settings = DMZSettings()
    settings.set_reboot_requirement_status(False)
    settings.set_supported_status(True)
    enabled = '<input type=checkbox name="enabled" value="ON" checked' in html
    settings.set_enabled_status(enabled)
    regex = re.compile('<input type=text name="ip" size=15'
                      ' maxlength=16 value="(.+?)"')
    match_object = regex.search(html)
    if match_object is None:
        raise RouterParseError('Cannot determine DMZ IP!')
    ip = match_object.group(1)
    if not validator.is_valid_ip_address(ip):
        if not enabled:
            ip = '192.168.1.1' # sane default value
        else:
            raise RouterParseError('Invalid IP address!')
    settings.set_ip(ip)
    return settings
Exemple #7
0
def _parse_dmz_settings(contents):
    array_name = 'DMZInf'

    result = _extract_js_array_data(contents, array_name)

    try:
        ip = result[1].strip(' ')
        if not validator.is_valid_ip_address(ip):
            raise RouterParseError('Invalid IP address: %s' % ip)

        obj = DMZSettings()
        obj.set_supported_status(True)
        obj.set_enabled_status(result[0] == 1)
        obj.set_ip(result[1])

        return obj
    except IndexError, e:
        raise RouterParseError(repr(e))
Exemple #8
0
def _parse_dmz_settings_WGR614v8(html):
    match_object = re.compile('var lanIpAddr = "(.+?)";').search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ IP')
    ip = match_object.group(1)
    if not validator.is_valid_ip_address(ip):
        raise RouterParseError('Invalid DMZ IP address: %s' % ip)

    match_object = re.compile("var dmzEnable = \"([0-1])\";").search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ Enabled Status')
    is_enabled = True if int(match_object.group(1)) == 1 else False

    settings = DMZSettings()
    settings.set_supported_status(True)
    settings.set_ip(ip)
    settings.set_enabled_status(is_enabled)

    return settings
Exemple #9
0
def _parse_dmz_settings(contents):
    array_name = 'DMZInf'

    result = _extract_js_array_data(contents, array_name)

    try:
        ip = result[1].strip(' ')
        if not validator.is_valid_ip_address(ip):
            raise RouterParseError('Invalid IP address: %s' % ip)

        obj = DMZSettings()
        obj.set_supported_status(True)
        obj.set_enabled_status(result[0] == 1)
        obj.set_ip(result[1])

        return obj
    except IndexError as e:
        raise RouterParseError(repr(e))
Exemple #10
0
def _parse_dmz_settings_WGR614v8(html):
    match_object = re.compile('var lanIpAddr = "(.+?)";').search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ IP')
    ip = match_object.group(1)
    if not validator.is_valid_ip_address(ip):
        raise RouterParseError('Invalid DMZ IP address: %s' % ip)


    match_object = re.compile("var dmzEnable = \"([0-1])\";").search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ Enabled Status')
    is_enabled = True if int(match_object.group(1)) == 1 else False


    settings = DMZSettings()
    settings.set_supported_status(True)
    settings.set_ip(ip)
    settings.set_enabled_status(is_enabled)

    return settings
Exemple #11
0
 def get_dmz_settings(self):
     settings = DMZSettings()
     settings.set_supported_status(False)
     settings.set_enabled_status(False)
     settings.set_ip("0.0.0.0")
     return settings
Exemple #12
0
def _parse_dmz_settings(html):
    regex = "//\s+nvram = \{(.+?)\};\n\nvar lipp = '(.+?)';"
    match_object = re.compile(regex, re.DOTALL).search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ settings')

    bad_json_settings, lipp = match_object.groups()
    nvram = _parse_data_structure(bad_json_settings)

    ip = nvram['dmz_ipaddr']
    if '.' not in ip:
        # it's the last part only.. it's shortened
        # and the rest is in lipp
        ip = lipp + ip

    obj = DMZSettings()
    obj.set_supported_status(True)
    obj.set_reboot_requirement_status(False)
    obj.set_enabled_status(nvram['dmz_enable'] == '1')
    obj.set_ip(ip)
    obj.ensure_valid()
    return obj
Exemple #13
0
def _parse_dmz_settings(html):
    regex = "//\s+nvram = \{(.+?)\};\n\nvar lipp = '(.+?)';"
    match_object = re.compile(regex, re.DOTALL).search(html)
    if match_object is None:
        raise RouterParseError('Cannot parse DMZ settings')

    bad_json_settings, lipp = match_object.groups()
    nvram = _parse_data_structure(bad_json_settings)

    ip = nvram['dmz_ipaddr']
    if '.' not in ip:
        # it's the last part only.. it's shortened
        # and the rest is in lipp
        ip = lipp + ip

    obj = DMZSettings()
    obj.set_supported_status(True)
    obj.set_reboot_requirement_status(False)
    obj.set_enabled_status(nvram['dmz_enable'] == '1')
    obj.set_ip(ip)
    obj.ensure_valid()
    return obj