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)
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!")
def flags_list(self, client): """ List all the flags in the database """ return generic_list(client, DBFlag, sort=DBFlag.id)
def triggers_list(self, client): """ List all the triggers in the database """ return generic_list(client, DBTrigger)
def teams_list(self, client): """ List all the teams in the database """ return generic_list(client, DBTeam, sort=DBTeam.id)
def scores_list(self, client): """ List all the scores in the database """ return generic_list(client, DBScore)