Removed HDID ban due to it not working.
This commit is contained in:
		
							parent
							
								
									eee682bf0d
								
							
						
					
					
						commit
						265b853337
					
				@ -65,7 +65,7 @@ class AOProtocol(asyncio.Protocol):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        buf = data
 | 
					        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()
 | 
					            self.client.transport.close()
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.client.is_checked = True
 | 
					            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):
 | 
					        if not self.validate_net_cmd(args, self.ArgType.STR, needs_auth=False):
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        self.client.hdid = args[0]
 | 
					        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:
 | 
					        if self.client.hdid not in self.client.server.hdid_list:
 | 
				
			||||||
            self.client.server.hdid_list[self.client.hdid] = []
 | 
					            self.client.server.hdid_list[self.client.hdid] = []
 | 
				
			||||||
        if self.client.ipid not in self.client.server.hdid_list[self.client.hdid]:
 | 
					        if self.client.ipid not in self.client.server.hdid_list[self.client.hdid]:
 | 
				
			||||||
 | 
				
			|||||||
@ -25,9 +25,6 @@ class BanManager:
 | 
				
			|||||||
        self.bans = []
 | 
					        self.bans = []
 | 
				
			||||||
        self.load_banlist()
 | 
					        self.load_banlist()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.hdid_bans = []
 | 
					 | 
				
			||||||
        self.load_hdid_banlist()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def load_banlist(self):
 | 
					    def load_banlist(self):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            with open('storage/banlist.json', 'r') as banlist_file:
 | 
					            with open('storage/banlist.json', 'r') as banlist_file:
 | 
				
			||||||
@ -55,31 +52,3 @@ class BanManager:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def is_banned(self, ipid):
 | 
					    def is_banned(self, ipid):
 | 
				
			||||||
        return (ipid in self.bans)
 | 
					        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)
 | 
					 | 
				
			||||||
@ -358,36 +358,6 @@ def ooc_cmd_unban(client, arg):
 | 
				
			|||||||
    logger.log_server('Unbanned {}.'.format(arg), client)
 | 
					    logger.log_server('Unbanned {}.'.format(arg), client)
 | 
				
			||||||
    client.send_host_message('Unbanned {}'.format(arg))
 | 
					    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):
 | 
					def ooc_cmd_play(client, arg):
 | 
				
			||||||
    if not client.is_mod:
 | 
					    if not client.is_mod:
 | 
				
			||||||
        raise ClientError('You must be authorized to do that.')
 | 
					        raise ClientError('You must be authorized to do that.')
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user