From 265b853337e6368afc2816a78a64a4d128f756e4 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Fri, 17 Aug 2018 02:12:29 +0200 Subject: [PATCH] Removed HDID ban due to it not working. --- server/aoprotocol.py | 5 +---- server/ban_manager.py | 33 +-------------------------------- server/commands.py | 32 +------------------------------- 3 files changed, 3 insertions(+), 67 deletions(-) diff --git a/server/aoprotocol.py b/server/aoprotocol.py index 11d2fbd..5bc94bb 100644 --- a/server/aoprotocol.py +++ b/server/aoprotocol.py @@ -65,7 +65,7 @@ class AOProtocol(asyncio.Protocol): buf = data - if not self.client.is_checked and (self.server.ban_manager.is_banned(self.client.ipid) or self.server.ban_manager.is_hdid_banned(self.client.hdid)): + if not self.client.is_checked and self.server.ban_manager.is_banned(self.client.ipid): self.client.transport.close() else: self.client.is_checked = True @@ -165,9 +165,6 @@ class AOProtocol(asyncio.Protocol): if not self.validate_net_cmd(args, self.ArgType.STR, needs_auth=False): return self.client.hdid = args[0] - if self.server.ban_manager.is_hdid_banned(self.client.hdid): - self.client.disconnect() - return if self.client.hdid not in self.client.server.hdid_list: self.client.server.hdid_list[self.client.hdid] = [] if self.client.ipid not in self.client.server.hdid_list[self.client.hdid]: diff --git a/server/ban_manager.py b/server/ban_manager.py index b4f97b7..20c186f 100644 --- a/server/ban_manager.py +++ b/server/ban_manager.py @@ -25,9 +25,6 @@ class BanManager: self.bans = [] self.load_banlist() - self.hdid_bans = [] - self.load_hdid_banlist() - def load_banlist(self): try: with open('storage/banlist.json', 'r') as banlist_file: @@ -54,32 +51,4 @@ class BanManager: self.write_banlist() def is_banned(self, ipid): - return (ipid in self.bans) - - def load_hdid_banlist(self): - try: - with open('storage/banlist_hdid.json', 'r') as banlist_file: - self.hdid_bans = json.load(banlist_file) - except FileNotFoundError: - return - - def write_hdid_banlist(self): - with open('storage/banlist_hdid.json', 'w') as banlist_file: - json.dump(self.hdid_bans, banlist_file) - - def add_hdid_ban(self, hdid): - if hdid not in self.hdid_bans: - self.hdid_bans.append(hdid) - else: - raise ServerError('This HDID is already banned.') - self.write_hdid_banlist() - - def remove_hdid_ban(self, hdid): - if hdid in self.hdid_bans: - self.hdid_bans.remove(hdid) - else: - raise ServerError('This HDID is not banned.') - self.write_hdid_banlist() - - def is_hdid_banned(self, hdid): - return (hdid in self.hdid_bans) \ No newline at end of file + return (ipid in self.bans) \ No newline at end of file diff --git a/server/commands.py b/server/commands.py index d1f145d..a3c3ce8 100644 --- a/server/commands.py +++ b/server/commands.py @@ -357,37 +357,7 @@ def ooc_cmd_unban(client, arg): raise ClientError('You must specify ipid') logger.log_server('Unbanned {}.'.format(arg), client) client.send_host_message('Unbanned {}'.format(arg)) - -def ooc_cmd_ban_hdid(client, arg): - if not client.is_mod: - raise ClientError('You must be authorized to do that.') - try: - hdid = int(arg.strip()) - except: - raise ClientError('You must specify hdid') - try: - client.server.ban_manager.add_hdid_ban(hdid) - except ServerError: - raise - if hdid != None: - targets = client.server.client_manager.get_targets(client, TargetType.HDID, hdid, False) - if targets: - for c in targets: - c.disconnect() - client.send_host_message('{} clients was kicked.'.format(len(targets))) - client.send_host_message('{} was banned.'.format(hdid)) - logger.log_server('Banned {}.'.format(hdid), client) - -def ooc_cmd_unban_hdid(client, arg): - if not client.is_mod: - raise ClientError('You must be authorized to do that.') - try: - client.server.ban_manager.remove_hdid_ban(int(arg.strip())) - except: - raise ClientError('You must specify hdid') - logger.log_server('Unbanned {}.'.format(arg), client) - client.send_host_message('Unbanned {}'.format(arg)) - + def ooc_cmd_play(client, arg): if not client.is_mod: raise ClientError('You must be authorized to do that.')