From 6fb0b5494f6eacf7c8f5b6cba05b29bbd5379846 Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Sat, 30 Apr 2022 20:38:18 -0400 Subject: [PATCH] Implement a handler for logging routes --- .../server/dispatch/ClientLogHandler.java | 19 +++++++++++++++++++ .../server/dispatch/DispatchServer.java | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/main/java/emu/grasscutter/server/dispatch/ClientLogHandler.java diff --git a/src/main/java/emu/grasscutter/server/dispatch/ClientLogHandler.java b/src/main/java/emu/grasscutter/server/dispatch/ClientLogHandler.java new file mode 100644 index 000000000..4b57826ea --- /dev/null +++ b/src/main/java/emu/grasscutter/server/dispatch/ClientLogHandler.java @@ -0,0 +1,19 @@ +package emu.grasscutter.server.dispatch; + +import express.http.HttpContextHandler; +import express.http.Request; +import express.http.Response; + +import java.io.IOException; + +/** + * Used for processing crash dumps & logs generated by the game. + * Logs are in JSON, and are sent to the server for logging. + */ +public final class ClientLogHandler implements HttpContextHandler { + @Override + public void handle(Request request, Response response) throws IOException { + // TODO: Figure out how to dump request body and log to file. + response.send("{\"code\":0}"); + } +} diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index bc43ad5c8..bf236bd88 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -35,11 +35,11 @@ public final class DispatchServer { private final String defaultServerName = "os_usa"; public String regionListBase64; - public HashMap regions; + public Map regions; private Express httpServer; public DispatchServer() { - this.regions = new HashMap(); + this.regions = new HashMap<>(); this.gson = new GsonBuilder().create(); this.loadQueries(); @@ -475,9 +475,9 @@ public final class DispatchServer { // Logging servers // overseauspider.yuanshen.com - httpServer.all("/log", new DispatchHttpJsonHandler("{\"code\":0}")); + httpServer.all("/log", new ClientLogHandler()); // log-upload-os.mihoyo.com - httpServer.all("/crash/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}")); + httpServer.all("/crash/dataUpload", new ClientLogHandler()); httpServer.get("/gacha", (req, res) -> res.send("Gacha"));