

@auth
def _GET(self, *param, **params):
    host_id = self.chk_hostby1(param)
    if (host_id is None):
        return web.notfound()
    rule_id = param[1]
    if (not validates_param_id(self, rule_id)):
        return web.notfound(self.view.alert)
    kit = KaresansuiIpTables()
    kit.firewall_xml = kit.read_firewall_xml()
    rules = kit.get_rules()
    cnt = 1
    for rule in rules:
        if (cnt == int(rule_id)):
            self.view.rule = rule
            break
        cnt = (cnt + 1)
    if self.is_mode_input():
        self.view.targets = kit.basic_targets['filter']
        self.view.protocols = kit.chain_protos
        self.view.netinfo = get_ifconfig_info()
        devtype_regexs = {
            'phy': '^(lo|eth)',
            'vir': '^(xenbr|virbr|vif|veth)',
        }
        devtype_phy_regex = re.compile(('%s' % devtype_regexs['phy']))
        devtype_vir_regex = re.compile(('%s' % devtype_regexs['vir']))
        devs = {
            
        }
        devs['phy'] = []
        devs['vir'] = []
        devs['oth'] = []
        cidrs = []
        ips = []
        for (dev, dev_info) in get_ifconfig_info().iteritems():
            try:
                if devtype_phy_regex.match(dev):
                    devs['phy'].append(dev)
                elif devtype_vir_regex.match(dev):
                    devs['vir'].append(dev)
                else:
                    devs['oth'].append(dev)
                if (dev_info['ipaddr'] is not None):
                    if (not (dev_info['ipaddr'] in ips)):
                        ips.append(dev_info['ipaddr'])
                if (dev_info['cidr'] is not None):
                    if (not (dev_info['cidr'] in cidrs)):
                        cidrs.append(dev_info['cidr'])
            except:
                pass
        devs['phy'].sort()
        devs['vir'].sort()
        devs['oth'].sort()
        self.view.devs = [{
            'Physical': devs['phy'],
        }, {
            'Virtual': devs['vir'],
        }, {
            'Other': devs['oth'],
        }]
        self.view.cidrs = cidrs
        self.view.ips = ips
        return True
    else:
        return web.nomethod()

dataset/ETHPy150Open karesansui/karesansui/karesansui/gadget/hostby1firewallruleby1.py HostBy1FirewallRuleby1._GET/original