Exemplo n.º 1
0
    def new_client(self, transport):
        """
        Create a new client, add it to the list, and assign it a player ID.
        :param transport: asyncio transport
        """
        try:
            user_id = heappop(self.cur_id)
        except IndexError:
            transport.write(b'BD#This server is full.#%')
            raise ClientError

        peername = transport.get_extra_info('peername')[0]

        # hash IP into previous system's IPID system to maintain old banlist
        if 'server_number' in self.server.config:
            x = peername + str(self.server.config['server_number'])
            hash_object = hashlib.sha256(x.encode('utf-8'))
            peername = hash_object.hexdigest()[:12]

        c = self.Client(self.server, transport, user_id,
                        database.ipid(peername))
        self.clients.add(c)
        temp_ipid = c.ipid
        for client in self.server.client_manager.clients:
            if client.ipid == temp_ipid:
                client.clientscon += 1
        return c
Exemplo n.º 2
0
    def new_client(self, transport: asyncio.Transport) -> Client:
        """Create a new client, add it to the list, and assign it a player ID.

        Args:
            transport (asyncio.Transport): Transport to send data across

        Raises:
            ClientError: The server is full

        Returns:
            Client: The newly constructed client
        """
        try:
            user_id = heappop(self.cur_id)
        except IndexError:
            transport.write(b'BD#This server is full.#%')
            raise ClientError

        peername = transport.get_extra_info('peername')[0]

        c = self.Client(self.server, transport, user_id,
                        database.ipid(peername))
        self.clients.add(c)
        temp_ipid = c.ipid
        for client in self.server.client_manager.clients:
            if client.ipid == temp_ipid:
                client.clientscon += 1
        return c
Exemplo n.º 3
0
 def new_client(self, transport):
     """
     Create a new client, add it to the list, and assign it a player ID.
     :param transport: asyncio transport
     """
     c = self.Client(self.server, transport, heappop(self.cur_id),
                     database.ipid(transport.get_extra_info('peername')[0]))
     self.clients.add(c)
     return c
    def new_client(self, transport):
        """
        Create a new client, add it to the list, and assign it a player ID.
        :param transport: asyncio transport
        """
        try:
            user_id = heappop(self.cur_id)
        except IndexError:
            transport.write(b'BD#This server is full.#%')
            raise ClientError

        c = self.Client(self.server, transport, user_id,
                        database.ipid(transport.get_extra_info('peername')[0]))
        self.clients.add(c)
        temp_ipid = c.ipid
        for client in self.server.client_manager.clients:
            if client.ipid == temp_ipid:
                client.clientscon += 1
        return c