Skip to content

Commit

Permalink
Fix crash when login
Browse files Browse the repository at this point in the history
* Prevent email to be `null` to avoid crash in certain client setup.
  • Loading branch information
mingjun97 authored and Melledy committed May 1, 2022
1 parent 3169e87 commit 8b8777e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@ public void start() throws Exception {
responseData.data.account.uid = requestData.uid;
responseData.data.account.token = requestData.token;
responseData.data.account.email = account.getEmail();
if (responseData.data.account.email == null) { // null will trigger crash in some client
responseData.data.account.email = "";
}

Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in via token as %s",
req.ip(), responseData.data.account.uid));
Expand Down Expand Up @@ -437,7 +440,7 @@ public void start() throws Exception {
// hk4e-sdk-os.hoyoverse.com
httpServer.get("/hk4e_global/mdk/agreement/api/getAgreementInfos", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}"));
// hk4e-sdk-os.hoyoverse.com
httpServer.post("/hk4e_global/combo/granter/api/compareProtocolVersion", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"));
httpServer.get("/hk4e_global/combo/granter/api/compareProtocolVersion", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"modified\":true,\"protocol\":{\"id\":0,\"app_id\":4,\"language\":\"en\",\"user_proto\":\"\",\"priv_proto\":\"\",\"major\":7,\"minimum\":0,\"create_time\":\"0\",\"teenager_proto\":\"\",\"third_proto\":\"\"}}}"));

// Game data
// hk4e-api-os.hoyoverse.com
Expand Down Expand Up @@ -469,7 +472,7 @@ public void start() throws Exception {
// log-upload-os.mihoyo.com
httpServer.all("/log/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}"));
httpServer.all("/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}"));
httpServer.post("/sdk/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}"));
httpServer.post("/sdk/dataUpload", (req, res) -> res.send("Hello"));
// /perf/config/verify?device_id=xxx&platform=x&name=xxx
httpServer.all("/perf/config/verify", new DispatchHttpJsonHandler("{\"code\":0}"));

Expand All @@ -479,6 +482,9 @@ public void start() throws Exception {
// log-upload-os.mihoyo.com
httpServer.all("/crash/dataUpload", new ClientLogHandler());

// webstatic-sea.hoyoverse.com
httpServer.get("/admin/mi18n/plat_oversea/m202003048/m202003048-version.json", new DispatchHttpJsonHandler("{\"version\":51}"));

httpServer.get("/gacha", (req, res) -> res.send("<!doctype html><html lang=\"en\"><head><title>Gacha</title></head><body></body></html>"));

httpServer.listen(Grasscutter.getConfig().getDispatchOptions().Port);
Expand Down

0 comments on commit 8b8777e

Please sign in to comment.