コード例 #1
0
ファイル: w268r.py プロジェクト: wblyy/roscraco
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
コード例 #2
0
ファイル: p330w.py プロジェクト: spantaleev/roscraco
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
コード例 #3
0
ファイル: v1_23.py プロジェクト: spantaleev/roscraco
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
コード例 #4
0
ファイル: v1_23.py プロジェクト: cyroxx/roscraco
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