Gets ips from Redis Pub/Sub to be banned, so it doesnt need to scan redis in its entirety Returns: Returns a list of all IPs not relating to the name of this "server" from the passed config
(self)
| 67 | return self.redis_connection.hget(ip, self.name) |
| 68 | |
| 69 | def get_bans(self): |
| 70 | """ |
| 71 | Gets ips from Redis Pub/Sub to be banned, so it doesnt need to scan redis in its entirety |
| 72 | |
| 73 | Returns: |
| 74 | Returns a list of all IPs not relating to the name of this "server" from the passed config |
| 75 | """ |
| 76 | |
| 77 | bans = [] |
| 78 | |
| 79 | while True: |
| 80 | ban = self.pub_sub.get_message() |
| 81 | |
| 82 | if not ban: |
| 83 | return bans |
| 84 | |
| 85 | if ban["type"] != "message": |
| 86 | continue |
| 87 | |
| 88 | ban_data = ban["data"].split() |
| 89 | if len(ban_data) != 2: |
| 90 | ban_data[1] = " ".join(ban_data[1:]) |
| 91 | |
| 92 | if ban_data[1] == self.name: |
| 93 | continue |
| 94 | |
| 95 | server = self.redis_connection.hget(ban_data[0], "banned_server") |
| 96 | time_banned = self.redis_connection.hget(ban_data[0], server) |
| 97 | |
| 98 | self.redis_connection.hset(ban_data[0], self.name, time_banned) |
| 99 | |
| 100 | bans.append(ban_data[:2]) |
| 101 | |
| 102 | def scan(self): |
| 103 | """ |