From bde8a2114083e3ff312ca09e8bd21d2c543d3ea3 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Wed, 20 Apr 2022 18:13:26 +0800 Subject: [PATCH] Optimize proxy scripts Signed-off-by: Jaida Wu --- proxy.py | 68 +++++++++++++++++++++++++------------------------ proxy_config.py | 2 ++ 2 files changed, 37 insertions(+), 33 deletions(-) create mode 100644 proxy_config.py diff --git a/proxy.py b/proxy.py index b352af3ac..2d2282af9 100644 --- a/proxy.py +++ b/proxy.py @@ -21,43 +21,45 @@ ## from mitmproxy import http +from proxy_config import REMOTE_HOST class MlgmXyysd_Genshin_Impact_Proxy: + 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", + "gameapi-account.mihoyo.com", + "minor-api.mihoyo.com", + "public-data-api.mihoyo.com", + "uspider.yuanshen.com", + "sdk-static.mihoyo.com" + ] + 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: + if flow.request.host in self.LIST_DOMAINS: flow.request.host = REMOTE_HOST addons = [ diff --git a/proxy_config.py b/proxy_config.py new file mode 100644 index 000000000..f048ef88c --- /dev/null +++ b/proxy_config.py @@ -0,0 +1,2 @@ +# This can also be replaced with another IP address. +REMOTE_HOST = "localhost" \ No newline at end of file