Example #1
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)
Example #2
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)
Example #3
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)
Example #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)
Example #5
0
 def on_disconnect(self):
     if self.name is not None:
         print self.printable_name, 'disconnected!'
         self.protocol.irc_say('* %s disconnected' % self.name)
         self.protocol.player_memory.append((self.name, self.address[0]))
     else:
         print '%s disconnected' % self.address[0]
     ServerConnection.on_disconnect(self)
Example #6
0
 def on_disconnect(self):
     if self.name is not None:
         print self.printable_name, 'disconnected!'
         self.protocol.irc_say('* %s disconnected' % self.name)
         self.protocol.player_memory.append((self.name, self.address[0]))
     else:
         print '%s disconnected' % self.address[0]
     ServerConnection.on_disconnect(self)
Example #7
0
 def on_disconnect(self) -> None:
     if self.name is not None:
         log.info('{name} disconnected!', name=self.printable_name)
         self.protocol.irc_say('* %s (IP %s) disconnected' %
                               (self.name, self.address[0]))
         self.protocol.player_memory.append((self.name, self.address[0]))
     else:
         log.info('{ip} disconnected', ip=self.address[0])
     ServerConnection.on_disconnect(self)
Example #8
0
 def get_spawn_location(self):
     get_location = self.protocol.map_info.get_spawn_location
     if get_location is not None:
         result = get_location(self)
         if result is not None:
             return result
     return ServerConnection.get_spawn_location(self)
Example #9
0
 def get_spawn_location(self):
     get_location = self.protocol.map_info.get_spawn_location
     if get_location is not None:
         result = get_location(self)
         if result is not None:
             return result
     return ServerConnection.get_spawn_location(self)
Example #10
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)
Example #11
0
 def timed_out(self):
     if self.name is not None:
         print '%s timed out' % self.printable_name
     ServerConnection.timed_out(self)
Example #12
0
 def timed_out(self):
     if self.name is not None:
         print '%s timed out' % self.printable_name
     ServerConnection.timed_out(self)
Example #13
0
 def timed_out(self):
     if self.name is not None:
         log.info('%s timed out' % self.printable_name)
     ServerConnection.timed_out(self)