示例#1
0
	async def mark_friend_requests_as_received(self, ids):
		logger.info("FriendsClientV2.mark_friend_requests_as_received()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.list(ids, stream.u64)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_MARK_FRIEND_REQUESTS_AS_RECEIVED, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.mark_friend_requests_as_received -> done")
示例#2
0
	def initiate_probe(self, station_to_probe):
		logger.info("NATTraversalClient.initiate_probe()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.stationurl(station_to_probe)
		data = self.client.send_request(self.PROTOCOL_ID, self.METHOD_INITIATE_PROBE, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("NATTraversalClient.initiate_probe -> done")
示例#3
0
	async def remove_black_list(self, pid):
		logger.info("FriendsClientV2.remove_black_list()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.pid(pid)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_REMOVE_BLACK_LIST, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.remove_black_list -> done")
示例#4
0
	async def update_status(self, status):
		logger.info("AccountClient.update_status()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.string(status)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_UPDATE_STATUS, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("AccountClient.update_status -> done")
示例#5
0
	async def delete_friend_request(self, id):
		logger.info("FriendsClientV2.delete_friend_request()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u64(id)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_DELETE_FRIEND_REQUEST, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.delete_friend_request -> done")
示例#6
0
	async def delete_account(self, pid):
		logger.info("AccountClient.delete_account()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.pid(pid)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_DELETE_ACCOUNT, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("AccountClient.delete_account -> done")
示例#7
0
	def request_probe_initiation(self, target_urls):
		logger.info("NATTraversalClient.request_probe_initiation()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.list(target_urls, stream.stationurl)
		data = self.client.send_request(self.PROTOCOL_ID, self.METHOD_REQUEST_PROBE_INITIATION, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("NATTraversalClient.request_probe_initiation -> done")
示例#8
0
    async def handle_request(self, request):
        input = streams.StreamIn(request.body, self.settings)
        output = streams.StreamOut(self.settings)

        result = common.Result()
        if request.protocol in self.servers:
            try:
                await self.servers[request.protocol
                                   ].handle(self, request.method, input,
                                            output)
            except common.RMCError as e:
                result = e.result()
            except Exception as e:
                logger.exception(
                    "Exception occurred while handling a method call")

                if isinstance(e, TypeError):
                    result = common.Result.error("PythonCore::TypeError")
                elif isinstance(e, IndexError):
                    result = common.Result.error("PythonCore::IndexError")
                elif isinstance(e, MemoryError):
                    result = common.Result.error("PythonCore::MemoryError")
                elif isinstance(e, KeyError):
                    result = common.Result.error("PythonCore::KeyError")
                else:
                    result = common.Result.error("PythonCore::Exception")
            except anyio.exceptions.ExceptionGroup as e:
                logger.exception(
                    "Multiple exceptions occurred while handling a method call"
                )

                filtered = []
                for exc in e.exceptions:
                    if not isinstance(exc, Exception):
                        raise

                result = common.Result.error("PythonCore::Exception")
        else:
            logger.warning(
                "Received RMC request with unimplemented protocol id: 0x%X",
                request.protocol)
            result = common.Result.error("Core::NotImplemented")

        if result.is_success():
            response = RMCMessage.response(self.settings, request.protocol,
                                           request.method, request.call_id,
                                           output.get())
        else:
            response = RMCMessage.error(self.settings, request.protocol,
                                        request.method, request.call_id,
                                        result.code())
        await self.client.send(response.encode())
示例#9
0
	async def disconnect_all_principals(self):
		logger.info("AccountClient.disconnect_all_principals()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_DISCONNECT_ALL_PRINCIPALS, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		result = stream.bool()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("AccountClient.disconnect_all_principals -> done")
		return result
示例#10
0
	async def reset_password(self):
		logger.info("AccountClient.reset_password()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_RESET_PASSWORD, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		result = stream.bool()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("AccountClient.reset_password -> done")
		return result
示例#11
0
	async def check_setting_status(self):
		logger.info("FriendsClientV2.check_setting_status()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_CHECK_SETTING_STATUS, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		unk = stream.u8()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.check_setting_status -> done")
		return unk
示例#12
0
	async def report_nat_traversal_result(self, cid, result):
		logger.info("NATTraversalClient.report_nat_traversal_result()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u32(cid)
		stream.bool(result)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_REPORT_NAT_TRAVERSAL_RESULT, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("NATTraversalClient.report_nat_traversal_result -> done")
示例#13
0
	async def put_common_data(self, data, unique_id):
		logger.info("Ranking2Client.put_common_data()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(data)
		stream.u64(unique_id)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_PUT_COMMON_DATA, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("Ranking2Client.put_common_data -> done")
示例#14
0
	async def replace_url(self, url, new):
		logger.info("SecureConnectionClient.replace_url()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.stationurl(url)
		stream.stationurl(new)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_REPLACE_URL, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("SecureConnectionClient.replace_url -> done")
示例#15
0
	async def delete_messages(self, recipient, message_ids):
		logger.info("MessagingClient.delete_messages()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(recipient)
		stream.list(message_ids, stream.u32)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_DELETE_MESSAGES, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("MessagingClient.delete_messages -> done")
示例#16
0
	async def send_report(self, report_id, data):
		logger.info("SecureConnectionClient.send_report()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u32(report_id)
		stream.qbuffer(data)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_SEND_REPORT, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("SecureConnectionClient.send_report -> done")
示例#17
0
async def get_course_record(param):
    #--- request ---
    stream = streams.StreamOut(datastore_smm_client.settings)
    stream.add(param)
    data = await datastore_smm_client.client.request(
        datastore_smm_client.PROTOCOL_ID, 72, stream.get())

    #--- response ---
    stream = streams.StreamIn(data, datastore_smm_client.settings)

    result = stream.extract(DataStoreGetCourseRecordResult)

    return result
示例#18
0
	def upload_score(self, score_data, unique_id):
		logger.info("RankingClient.upload_score()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(score_data)
		stream.u64(unique_id)
		data = self.client.send_request(self.PROTOCOL_ID, self.METHOD_UPLOAD_SCORE, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("RankingClient.upload_score -> done")
示例#19
0
	async def get_estimate_score_rank(self, input):
		logger.info("Ranking2Client.get_estimate_score_rank()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(input)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_ESTIMATE_SCORE_RANK, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		output = stream.extract(Ranking2EstimateScoreRankOutput)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("Ranking2Client.get_estimate_score_rank -> done")
		return output
示例#20
0
	async def get_ranking_charts(self, inputs):
		logger.info("Ranking2Client.get_ranking_charts()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.list(inputs, stream.add)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_RANKING_CHARTS, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		infos = stream.list(Ranking2ChartInfo)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("Ranking2Client.get_ranking_charts -> done")
		return infos
示例#21
0
	async def get_category_setting(self, category):
		logger.info("Ranking2Client.get_category_setting()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u32(category)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_CATEGORY_SETTING, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		setting = stream.extract(Ranking2CategorySetting)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("Ranking2Client.get_category_setting -> done")
		return setting
示例#22
0
	async def get_ranking(self, param):
		logger.info("Ranking2Client.get_ranking()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(param)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_RANKING, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		info = stream.extract(Ranking2Info)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("Ranking2Client.get_ranking -> done")
		return info
示例#23
0
	def handle_recv(self, data):
		if not data:
			logger.debug("Connection was closed")
			scheduler.remove(self.socket_event)
			return

		stream = streams.StreamIn(data, self.settings)
		length = stream.u32()
		protocol_id = stream.u8()

		if protocol_id & 0x80:
			self.handle_request(protocol_id & 0x7F, stream)
		else:
			self.handle_response(protocol_id, stream)
async def get_custom_ranking_by_data_id(param):
	#--- request ---
	stream = streams.StreamOut(datastore_smm_client.settings)
	stream.add(param)
	data = await datastore_smm_client.client.request(datastore_smm_client.PROTOCOL_ID, 50, stream.get())

	#--- response ---
	stream = streams.StreamIn(data, datastore_smm_client.settings)

	obj = rmc.RMCResponse()
	obj.ranking_result = stream.list(DataStoreCustomRankingResult)
	obj.results = stream.list(common.Result)

	return obj
示例#25
0
	async def get_number_of_messages(self, recipient):
		logger.info("MessagingClient.get_number_of_messages()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(recipient)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_NUMBER_OF_MESSAGES, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		number = stream.u32()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("MessagingClient.get_number_of_messages -> done")
		return number
示例#26
0
	async def report_nat_properties(self, natm, natf, rtt):
		logger.info("NATTraversalClient.report_nat_properties()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u32(natm)
		stream.u32(natf)
		stream.u32(rtt)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_REPORT_NAT_PROPERTIES, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("NATTraversalClient.report_nat_properties -> done")
示例#27
0
	async def get_basic_info(self, pids):
		logger.info("FriendsClientV2.get_basic_info()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.list(pids, stream.pid)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_BASIC_INFO, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		info = stream.list(PrincipalBasicInfo)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.get_basic_info -> done")
		return info
示例#28
0
	async def update_comment(self, comment):
		logger.info("FriendsClientV2.update_comment()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.add(comment)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_UPDATE_COMMENT, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		unk = stream.datetime()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.update_comment -> done")
		return unk
示例#29
0
	def get_common_data(self, unique_id):
		logger.info("RankingClient.get_common_data()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.u64(unique_id)
		data = self.client.send_request(self.PROTOCOL_ID, self.METHOD_GET_COMMON_DATA, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		data = stream.buffer()
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("RankingClient.get_common_data -> done")
		return data
示例#30
0
	async def get_request_block_settings(self, unk):
		logger.info("FriendsClientV2.get_request_block_settings()")
		#--- request ---
		stream = streams.StreamOut(self.settings)
		stream.list(unk, stream.u32)
		data = await self.client.request(self.PROTOCOL_ID, self.METHOD_GET_REQUEST_BLOCK_SETTINGS, stream.get())
		
		#--- response ---
		stream = streams.StreamIn(data, self.settings)
		settings = stream.list(PrincipalRequestBlockSetting)
		if not stream.eof():
			raise ValueError("Response is bigger than expected (got %i bytes, but only %i were read)" %(stream.size(), stream.tell()))
		logger.info("FriendsClientV2.get_request_block_settings -> done")
		return settings