예제 #1
0
 def setUp(self):
     """Sets up test data."""
     self.type = Type.STAT
     self.session_id = random_session_id()
     self.ip_address = IPv4Address('127.0.0.1')
     self.basic_stats = BasicStats(
         self.type,
         self.session_id,
         'Message of the day',
         'survival',
         'world',
         1,
         20,
         25565,
         self.ip_address
     )
     self.json = {
         'type': int(self.type.value),
         'session_id': int(self.session_id),
         'motd': 'Message of the day',
         'game_type': 'survival',
         'map': 'world',
         'num_players': 1,
         'max_players': 20,
         'host_port': 25565,
         'host_ip': str(self.ip_address)
     }
예제 #2
0
 def setUp(self):
     """Sets up test data."""
     self.type = Type.STAT
     self.session_id = random_session_id()
     self.ip_address = IPv4Address('127.0.0.1')
     self.full_stats = FullStats(
         self.type,
         self.session_id,
         'My Server',
         'survival',
         'Message of the day',
         '1.16.4',
         {},
         'world',
         2,
         20,
         25565,
         self.ip_address,
         ['coNQP', 'foo']
     )
     self.json = {
         'type': int(self.type.value),
         'session_id': int(self.session_id),
         'host_name': 'My Server',
         'game_type': 'survival',
         'game_id': 'Message of the day',
         'version': '1.16.4',
         'map': 'world',
         'plugins': {},
         'num_players': 2,
         'max_players': 20,
         'host_port': 25565,
         'host_ip': str(self.ip_address),
         'players': ['coNQP', 'foo']
     }
예제 #3
0
    def create(cls, challenge_token, session_id=None):
        """Creates a new request with the specified challenge
        token and the specified or a random session ID.
        """
        if session_id is None:
            session_id = random_session_id()

        return cls(MAGIC, Type.STAT, session_id, challenge_token)
예제 #4
0
 def create(cls) -> Request:
     """Creates a handshake with a random session ID."""
     return cls(session_id=random_session_id())
예제 #5
0
    def create(cls, session_id=None):
        """Returns a handshake request packet with a random session ID."""
        if session_id is None:
            session_id = random_session_id()

        return cls(MAGIC, Type.HANDSHAKE, session_id)
예제 #6
0
 def create(cls, challenge_token: BigEndianSignedInt32) -> Request:
     """Creates a new request with the given challenge token."""
     return cls(session_id=random_session_id(),
                challenge_token=challenge_token)