Spaces:
Sleeping
Sleeping
| import json | |
| from mitmproxy import http, ctx | |
| class MhwsRequest: | |
| def __init__(self) -> None: | |
| """ | |
| mitmproxy -s mitm_server.py | |
| system.json | |
| https://hjm.rebe.capcom.com/systems/EAR-B-WW/00001/system.json | |
| https://server.mhwee.com/systems/EAR-B-WW/00001/system.json | |
| https://evi0mo-hf-fastapi.hf.space/systems/EAR-B-WW/00001/system.json | |
| multiplayer | |
| https://40912.playfabapi.com/MultiplayerServer/ListParty/QosServers | |
| https://evi0mo-hf-fastapi.hf.space/MultiplayerServer/ListParty/QosServers | |
| """ | |
| # system.json | |
| self.original_rebe_host = "hjm.rebe.capcom.com" | |
| self.rebe_host = "evi0mo-hf-fastapi.hf.space" | |
| self.rebe_url = f"https://{self.rebe_host}/systems/EAR-B-WW/00001/system.json" | |
| self.rebe_data = { | |
| "json_ver": "1.0.2", | |
| "title": "EAR-B-WW", | |
| "revision": "00001", | |
| "api_timeout": 30000, | |
| "mtm": f"https://{self.rebe_host}", | |
| "mtms": "https://mtms.rebe.capcom.com", | |
| "mmr": "https://mmr.rebe.capcom.com", | |
| "tmr": f"https://{self.rebe_host}/v1/projects/earth-analysis-obt/topics/analysis-client-log:publish", | |
| "nkm": "https://nkm.rebe.capcom.com", | |
| "wlt": "https://wlt.rebe.capcom.com", | |
| "selector": "https://selector.gs.capcom.com", | |
| "working_state": "alive", | |
| "custom_property": "eyJvYnRfaW5mbyI6eyJlbnYiOjEsInN0YXJ0X3RpbWUiOjE3MzA0MjgyMDAsImVuZF90aW1lIjoxNzMwOTg5MjAwfSwicWEzIjp7ImFwaSI6IiIsIm5vdGlmeSI6IiJ9fQ==" | |
| } | |
| # multiplayer | |
| self.multiplayer_url = "https://40912.playfabapi.com/MultiplayerServer/ListParty/QosServers" | |
| def request(self, flow: http.HTTPFlow) -> None: | |
| if flow.request.pretty_url == self.rebe_url: | |
| ctx.log.alert(flow.request) | |
| flow.response = http.Response.make( | |
| status_code=200, | |
| content=json.dumps(self.rebe_data), | |
| headers={"Content-Type": "application/json; charset=utf-8"}, | |
| ) | |
| if flow.request.pretty_url == self.multiplayer_url: | |
| flow.response = http.Response.make( | |
| status_code=404, | |
| content="offline mode", | |
| headers={"Content-Type": "text/html"}, | |
| ) | |
| if flow.request.pretty_host == self.original_rebe_host: | |
| flow.request.host = self.rebe_host | |
| def response(self, flow: http.HTTPFlow) -> None: | |
| ctx.log.info(f"get response from: {flow.request.url}") | |
| addons = [ | |
| MhwsRequest() | |
| ] |