Grasscutters / Grasscutter

A server software reimplementation for a certain anime game.
https://grasscutter.io/
GNU Affero General Public License v3.0
16.28k stars 4.48k forks source link

Some questions #765

Closed HtnrxUNc closed 2 years ago

HtnrxUNc commented 2 years ago

Hello, contributors. I've encountered some very strange problems so far, some of which I've found answers to, and some of which I haven't found solutions to at the moment, so if you have solutions to these problems, you can reply to me here. First of all, the environment I am using

Operating Environment


Catalog Usage


config


proxy_config.py


USE_SSL = True
REMOTE_HOST = "127.0.0.1"
REMOTE_PORT = 444

proxy.py


from mitmproxy import http
from proxy_config import USE_SSL
from proxy_config import REMOTE_HOST
from proxy_config import REMOTE_PORT

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",
        "abtest-api-data-sg.hoyoverse.com",
        "log-upload-os.hoyoverse.com"
    ]

    def request(self, flow: http.HTTPFlow) -> None:
        if flow.request.host in self.LIST_DOMAINS:
            if USE_SSL:
                flow.request.scheme = "https"
            else:
                flow.request.scheme = "http"
            flow.request.host = REMOTE_HOST
            flow.request.port = REMOTE_PORT

addons = [
    MlgmXyysd_Genshin_Impact_Proxy()
]

I use Mitmproxy to hijack traffic

Some of the problems I have encountered


HtnrxUNc commented 2 years ago

Update I am currently unable to connect to my own server again, once I open the game it connects to the official server. I'm currently looking for the reason and it seems that Fiddler is not intercepting any traffic.

HtnrxUNc commented 2 years ago

I managed to connect to my server again, but this time I didn't get into the game. The game prompted me Server connection failed. I found the prompt on my server side.

[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 is trying to log in via token
[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 logged in via token as 10001
[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 succeed to exchange combo token
[13:45:18] [INFO] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 request: query_cur_region_os_usa
HtnrxUNc commented 2 years ago

I managed to connect to my server again, but this time I didn't get into the game. The game prompted me Server connection failed. I found the prompt on my server side.

[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 is trying to log in via token
[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 logged in via token as 10001
[13:45:17] [INFO] [Dispatch] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 succeed to exchange combo token
[13:45:18] [INFO] Client fe80:0:0:0:b050:45d6:f93c:262/[fe80:0:0:0:b050:45d6:f93c:262]:3381 request: query_cur_region_os_usa

I have found the reason for this problem. Because I changed my network environment, which caused the IP address of ubuntu and windows to change. And the GameServer.PublicIp in the config file was not updated, so the server refused to connect.