Exemplo n.º 1
0
    def set_fw_priority(self, req, **kwargs):
        content = req.body
        save_dict = {}
        save_dict['priority'] = 0
        save_dict['blocking_rule'] = {}

        if firewall_settings.save(save_dict):
            pp = pprint.PrettyPrinter(indent=2)
            pp.pprint(save_dict)
            return Response(status=202)
        else:
            return Response(status=400)
Exemplo n.º 2
0
    def set_fw_priority(self, req, **kwargs):
        content = req.body
        save_dict = {}
        save_dict['priority'] = 0
        save_dict['blocking_rule'] = {}

        if firewall_settings.save(save_dict):
            pp = pprint.PrettyPrinter(indent=2)
            pp.pprint(save_dict)
            return Response(status=202)
        else:
            return Response(status=400)
Exemplo n.º 3
0
    def _flow_stats_reply_handler(self, ev):
        settings = firewall_settings.load()
        settings['blocking_rule'] = []

        body = ev.msg.body
        for stat in body:
            flow = {}
            if (stat.instructions == []):
                flow.update({'srcIP': stat.match.get('ipv4_src')})
                flow.update({'dstIP': stat.match.get('ipv4_dst')})
                if (stat.match.get('ip_proto') == inet.IPPROTO_TCP):
                    flow.update({'tranPort': stat.match.get('tcp_dst')})
                    flow.update({'tranProtocol': 'TCP'})
                elif (stat.match.get('ip_proto') == inet.IPPROTO_UDP):
                    flow.update({'tranPort': stat.match.get('udp_dst')})
                    flow.update({'tranProtocol': 'UDP'})
                else:
                    flow.update({'tranPort': ''})
                    flow.update({'tranProtocol': ''})
                settings['blocking_rule'].append(flow)

        firewall_settings.save(settings)
Exemplo n.º 4
0
    def _flow_stats_reply_handler(self, ev):
        settings = firewall_settings.load()
        settings['blocking_rule'] = []

        body = ev.msg.body
        for stat in body:
            flow = {}
            if (stat.instructions == []):
                flow.update({'srcIP': stat.match.get('ipv4_src')})
                flow.update({'dstIP': stat.match.get('ipv4_dst')})
                if (stat.match.get('ip_proto') == inet.IPPROTO_TCP):
                    flow.update({'tranPort': stat.match.get('tcp_dst')})
                    flow.update({'tranProtocol': 'TCP'})
                elif (stat.match.get('ip_proto') == inet.IPPROTO_UDP):
                    flow.update({'tranPort': stat.match.get('udp_dst')})
                    flow.update({'tranProtocol': 'UDP'})
                else:
                    flow.update({'tranPort': ''})
                    flow.update({'tranProtocol': ''})
                settings['blocking_rule'].append(flow)

        firewall_settings.save(settings)