Ejemplo n.º 1
0
    def wrapped(*args, **kwargs):
        client = args[1]

        teamlist = generic_list(client, DBTeam,
                                ('id', 'subnets'),
                                DBTeam.id)

        for team in teamlist:
            subnets = team['subnets']
            if not subnets:
                continue

            if "," in subnets:
                subnets = [subnet.strip()
                           for subnet in team['subnets'].split(",")]
            else:
                subnets = [subnets]

            for subnet in subnets:
                if ipaddr.IPAddress(client['client_address']) \
                        in ipaddr.IPNetwork(subnet):
                    client['team'] = team['id']
                    break

            if 'team' in client:
                break

        return fn(*args, **kwargs)
Ejemplo n.º 2
0
    def wrapped(*args, **kwargs):
        client = args[1]

        teamlist = generic_list(client, DBTeam,
                                ('id', 'subnets'),
                                DBTeam.id)

        for team in teamlist:
            subnets = team['subnets']
            if not subnets:
                continue

            if "," in subnets:
                subnets = [subnet.strip()
                           for subnet in team['subnets'].split(",")]
            else:
                subnets = [subnets]

            for subnet in subnets:
                if ipaddr.IPAddress(client['client_address']) \
                        in ipaddr.IPNetwork(subnet):
                    client['team'] = team['id']
                    return fn(*args, **kwargs)

        logging.error("Team not found for '%s'" % client['client_address'])
        raise AskgodException("You are not a valid team!")
Ejemplo n.º 3
0
 def flags_list(self, client):
     """ List all the flags in the database """
     return generic_list(client, DBFlag, sort=DBFlag.id)
Ejemplo n.º 4
0
 def triggers_list(self, client):
     """ List all the triggers in the database """
     return generic_list(client, DBTrigger)
Ejemplo n.º 5
0
 def teams_list(self, client):
     """ List all the teams in the database """
     return generic_list(client, DBTeam, sort=DBTeam.id)
Ejemplo n.º 6
0
 def scores_list(self, client):
     """ List all the scores in the database """
     return generic_list(client, DBScore)