Ejemplo n.º 1
0
 def on_connect(self):
     protocol = self.protocol
     client_ip = self.address[0]
     try:
         name, reason, timestamp, now = self.protocol.bans[client_ip]
         if timestamp is not None and reactor.seconds() >= timestamp:
             protocol.remove_ban(client_ip)
             protocol.save_bans()
         else:
             print 'banned user %s (%s) attempted to join' % (name,
                                                              client_ip)
             self.disconnect(ERROR_BANNED)
             return
     except KeyError:
         pass
     manager = self.protocol.ban_manager
     if manager is not None:
         reason = manager.get_ban(client_ip)
         if reason is not None:
             print(
                 'federated banned user (%s) attempted to join, '
                 'banned for %r') % (client_ip, reason)
             self.disconnect(ERROR_BANNED)
             return
     ServerConnection.on_connect(self)
Ejemplo n.º 2
0
    def on_connect(self):
        protocol = self.protocol
        client_ip = self.address[0]
        whitelisted = False

        if self.protocol.whitelist is not None:
            users = self.protocol.whitelist.get('users', [])
            for user in users:
                if client_ip == user.get('ip', '127.0.0.1'):
                    whitelisted = True

        if not whitelisted:
            try:
                name, reason, timestamp = self.protocol.bans[client_ip]
                if timestamp is not None and reactor.seconds() >= timestamp:
                    protocol.remove_ban(client_ip)
                    protocol.save_bans()
                else:
                    print 'banned user %s (%s) attempted to join' % (name,
                                                                     client_ip)
                    self.disconnect(ERROR_BANNED)
                    return
            except KeyError:
                pass
            manager = self.protocol.ban_manager
            if manager is not None:
                reason = manager.get_ban(client_ip)
                if reason is not None:
                    print(
                        'federated banned user (%s) attempted to join, '
                        'banned for %r') % (client_ip, reason)
                    self.disconnect(ERROR_BANNED)
                    return
        ServerConnection.on_connect(self)
Ejemplo n.º 3
0
    def on_connect(self) -> None:
        protocol = self.protocol
        client_ip = self.address[0]

        if client_ip in self.protocol.bans:
            name, reason, timestamp = self.protocol.bans[client_ip]

            if timestamp is not None and reactor.seconds() >= timestamp:
                protocol.remove_ban(client_ip)
                protocol.save_bans()
            else:
                log.info('banned user {} ({}) attempted to join'.format(
                    name, client_ip))
                self.disconnect(ERROR_BANNED)
                return

        manager = self.protocol.ban_manager

        if manager is not None:
            reason = manager.get_ban(client_ip)
            if reason is not None:
                log.info(('federated banned user (%s) attempted to join, '
                          'banned for %r') % (client_ip, reason))
                self.disconnect(ERROR_BANNED)
                return

        ServerConnection.on_connect(self)
Ejemplo n.º 4
0
 def on_connect(self):
     protocol = self.protocol
     client_ip = self.address[0]
     whitelisted = False
     
     if self.protocol.whitelist is not None:
         users = self.protocol.whitelist.get('users', [])
         for user in users:
             if client_ip == user.get('ip', '127.0.0.1'):
                 whitelisted = True
     
     if not whitelisted:
         try:
             name, reason, timestamp = self.protocol.bans[client_ip]
             if timestamp is not None and reactor.seconds() >= timestamp:
                 protocol.remove_ban(client_ip)
                 protocol.save_bans()
             else:
                 print 'banned user %s (%s) attempted to join' % (name, 
                     client_ip)
                 self.disconnect(ERROR_BANNED)
                 return
         except KeyError:
             pass
         manager = self.protocol.ban_manager
         if manager is not None:
             reason = manager.get_ban(client_ip)
             if reason is not None:
                 print ('federated banned user (%s) attempted to join, '
                     'banned for %r') % (client_ip, reason)
                 self.disconnect(ERROR_BANNED)
                 return
     ServerConnection.on_connect(self)
Ejemplo n.º 5
0
 def on_connect(self):
     protocol = self.protocol
     client_ip = self.address[0]
     try:
         name, reason, timestamp = self.protocol.bans[client_ip]
         if timestamp is not None and reactor.seconds() >= timestamp:
             protocol.remove_ban(client_ip)
             protocol.save_bans()
         else:
             print 'banned user %s (%s) attempted to join' % (name, 
                 client_ip)
             self.disconnect(ERROR_BANNED)
             return
     except KeyError:
         pass
     manager = self.protocol.ban_manager
     if manager is not None:
         reason = manager.get_ban(client_ip)
         if reason is not None:
             print ('federated banned user (%s) attempted to join, '
                 'banned for %r') % (client_ip, reason)
             self.disconnect(ERROR_BANNED)
             return
     ServerConnection.on_connect(self)