Grasscutters / Cultivation

A custom launcher designed to make it as easy as possible to proxy anime game traffic to private servers.
Apache License 2.0
968 stars 160 forks source link

fix proxy uri (add query) #95

Closed pfyy closed 1 year ago

pfyy commented 1 year ago

request.uri().path() is simply wrong, and user cannot even login due to this mistake.

https://docs.rs/http/0.2.8/http/uri/struct.Uri.html#method.path

pfyy commented 1 year ago

It is a very fundamental problem and quite shocking to me. Have you guys ever used the proxy of Cultivation? It seems to me that no one actually had logged in the game using the proxy of Cultivation before (a definite error code 4206).

SpikeHD commented 1 year ago

Cultivation proxy is what I have used since it first existed, you are welcome to ask any of the other multitudes of people that use it why its working fine for them too.

I’ll review this when I have time to make sure its fully required :)

pfyy commented 1 year ago

Thanks for your reply. BTW, I tested the proxy using the unmodified GC on localhost (http mode, for self signed certificates can never be accepted by Cultivation), the unmodified game (3.0) and the unmodified Cultivation (1.0.10). You can hit the login button, and it seems to be logged in at first, but the resources can never be loaded and the game failed with error code 4206. The commit can resolve the problem above, so I post it here for reference.

pfyy commented 1 year ago

https://github.com/Grasscutters/Grasscutter/blob/development/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java#L106

    public GachaInfo toProto(Player player) {
        // TODO: use other Nonce/key insteadof session key to ensure the overall security for the player
        String sessionKey = player.getAccount().getSessionKey();

        String record = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://"
                        + lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":"
                        + lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort)
                        + "/gacha?s=" + sessionKey + "&gachaType=" + gachaType;
        String details = "http" + (HTTP_ENCRYPTION.useInRouting ? "s" : "") + "://"
                        + lr(HTTP_INFO.accessAddress, HTTP_INFO.bindAddress) + ":"
                        + lr(HTTP_INFO.accessPort, HTTP_INFO.bindPort)
                        + "/gacha/details?s=" + sessionKey + "&scheduleId=" + scheduleId;

An example showing why this is important.

pfyy commented 1 year ago

I figured out why I had encountered these problems. I am using a private server on my LAN, and I set "accessAddress": "the site of a certain company". In this case, the login will go through the proxy, causing a fail (because query is not inserted).