From e709e2cf5c7ee1f1f7ee4f90a2f8a1e81fdc3726 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Tue, 19 Apr 2022 19:15:17 -0700 Subject: [PATCH] begin private server handling --- .gitignore | 1 + private_server_launch.bat | 13 ++++++++ proxy/proxy.py | 65 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 private_server_launch.bat create mode 100644 proxy/proxy.py diff --git a/.gitignore b/.gitignore index 7a00eea..155e314 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules/ bin/ dist/ +ext/ resources/js/neutralino.js .storage/ diff --git a/private_server_launch.bat b/private_server_launch.bat new file mode 100644 index 0000000..97622f1 --- /dev/null +++ b/private_server_launch.bat @@ -0,0 +1,13 @@ +@echo off + +echo Starting Private Server + +SET ip=%1 +SET gamePath=%2 +SET gamePath=%gamePath:"=% + +start "Proxy Server" ./ext/mitmdump.exe -s "./proxy/proxy.py" + +echo Opening %gamePath%/Genshin Impact Game/GenshinImpact.exe + +start "" /b "%gamePath%/Genshin Impact Game/GenshinImpact.exe" \ No newline at end of file diff --git a/proxy/proxy.py b/proxy/proxy.py new file mode 100644 index 0000000..90bbcdc --- /dev/null +++ b/proxy/proxy.py @@ -0,0 +1,65 @@ +## +# +# Copyright (C) 2002-2022 MlgmXyysd All Rights Reserved. +# +## + +## +# +# Genshin Impact script for mitmproxy +# +# https://github.com/MlgmXyysd/ +# +# *Original fiddler script from https://github.lunatic.moe/fiddlerscript +# +# Environment requirement: +# - mitmdump from mitmproxy +# +# @author MlgmXyysd +# @version 1.0 +# +## + +from mitmproxy import http + +class MlgmXyysd_Genshin_Impact_Proxy: + + def request(self, flow: http.HTTPFlow) -> None: + + # This can also be replaced with another IP address. + REMOTE_HOST = "localhost" + + LIST_DOMAINS = [ + "api-os-takumi.mihoyo.com", + "hk4e-api-os-static.mihoyo.com", + "hk4e-sdk-os.mihoyo.com", + "dispatchosglobal.yuanshen.com", + "osusadispatch.yuanshen.com", + "account.mihoyo.com", + "log-upload-os.mihoyo.com", + "dispatchcntest.yuanshen.com", + "devlog-upload.mihoyo.com", + "webstatic.mihoyo.com", + "log-upload.mihoyo.com", + "hk4e-sdk.mihoyo.com", + "api-beta-sdk.mihoyo.com", + "api-beta-sdk-os.mihoyo.com", + "cnbeta01dispatch.yuanshen.com", + "dispatchcnglobal.yuanshen.com", + "cnbeta02dispatch.yuanshen.com", + "sdk-os-static.mihoyo.com", + "webstatic-sea.mihoyo.com", + "webstatic-sea.hoyoverse.com", + "hk4e-sdk-os-static.hoyoverse.com", + "sdk-os-static.hoyoverse.com", + "api-account-os.hoyoverse.com", + "hk4e-sdk-os.hoyoverse.com", + "overseauspider.yuanshen.com" + ] + + if flow.request.host in LIST_DOMAINS: + flow.request.host = REMOTE_HOST + +addons = [ + MlgmXyysd_Genshin_Impact_Proxy() +] \ No newline at end of file