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
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
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
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
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))
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
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))
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
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