Beispiel #1
0
	def decode(self, stream):
		self.game_mode = stream.u32()
		self.session_id = stream.u32()
		self.attributes = stream.repeat(stream.u32, 6)
		self.num_participants = stream.u16()
		self.min_participants = stream.u16()
		self.max_participants = stream.u16()
		if stream.settings["pia.version"] < 50300:
			self.session_type = stream.u32()
		else:
			self.system_version = stream.u8()
			self.application_version = stream.u8()
			self.session_type = stream.u16()
		self.application_data = stream.read(0x180)
		self.application_data = self.application_data[:stream.u32()]
		self.is_opened = stream.bool()
		if stream.settings["pia.version"] < 51000:
			self.host_location = stream.extract(types.StationLocation)
		else:
			type = types.InetAddress.IPV4
			if stream.settings["pia.lan_version"] == 2:
				type = types.InetAddress.IPV6
			self.host_location = types.StationLocation()
			self.host_location.local = stream.extract(types.StationAddress, type)
			self.host_location.pid = stream.pid()
			self.host_location.cid = stream.u32()
			self.host_location.rvcid = stream.u32()
		self.players = stream.repeat(
			lambda: stream.extract(LanStationInfo), 16
		)
		self.session_param = stream.read(32)
def test_station_location():
	loc = types.StationLocation()
	assert isinstance(loc.public, types.StationAddress)
	assert isinstance(loc.local, types.StationAddress)
	assert isinstance(loc.relay, types.InetAddress)
	assert loc.pid == 0
	assert loc.cid == 0
	assert loc.rvcid == 0
	assert loc.scheme == 0
	assert loc.sid == 0
	assert loc.stream_type == 0
	assert loc.natm == 0
	assert loc.natf == 0
	assert loc.type == 3
	assert loc.probeinit == 0
	
	copy = loc.copy()
	
	loc.scheme = 3
	loc.pid = 100
	url = loc.get_station_url()
	assert url["PID"] == 100
	assert url.scheme() == "udp"
	
	assert copy.scheme == 0
	assert copy.pid == 0
	
	url = common.StationURL(natm=1, natf=2, type=5)
	loc.set_station_url(url)
	assert loc.scheme == 1
	assert loc.natm == 1
	assert loc.natf == 2
	assert loc.type == 5
def handler():
    host_address = types.StationLocation()

    host = lan.LanStationInfo()
    host.role = lan.LanStationInfo.HOST
    host.username = HOST_NAME
    host.id = HOST_ID

    session = lan.LanSessionInfo()
    session.game_mode = 0
    session.session_id = SESSION_ID
    session.attributes = [0, 0, 0, 0, 0, 0]
    session.num_participants = 1
    session.min_participants = 1
    session.max_participants = 10
    session.system_version = 5
    session.application_version = 66
    session.session_type = 0
    session.application_data = HOST_NAME.encode("utf-16le").ljust(74, b"\0")
    session.is_opened = True
    session.host_location = host_address
    session.stations[0] = host
    session.session_param = secrets.token_bytes(32)

    return [session]
Beispiel #4
0
	def __init__(self):
		self.game_mode = None
		self.session_id = None
		self.attributes = [0] * 6
		self.num_participants = 0
		self.min_participants = None
		self.max_participants = None
		self.system_version = None
		self.application_version = None
		self.session_type = None
		self.application_data = b""
		self.is_opened = None
		self.host_location = types.StationLocation()
		self.stations = [LanStationInfo() for i in range(16)]
		self.session_param = bytes(32)