From b38d5b19bb54c4c98344c844ef9cf2d9007a5070 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 21:41:07 +0800 Subject: [PATCH 1/7] Add port & SSL options to proxy script Signed-off-by: Jaida Wu --- proxy.py | 9 ++++++++- proxy_config.py | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/proxy.py b/proxy.py index 2d2282af9..86145cde6 100644 --- a/proxy.py +++ b/proxy.py @@ -16,12 +16,14 @@ # - mitmdump from mitmproxy # # @author MlgmXyysd -# @version 1.0 +# @version 1.1 # ## 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: @@ -60,7 +62,12 @@ class MlgmXyysd_Genshin_Impact_Proxy: 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() diff --git a/proxy_config.py b/proxy_config.py index f048ef88c..5025a974e 100644 --- a/proxy_config.py +++ b/proxy_config.py @@ -1,2 +1,4 @@ # This can also be replaced with another IP address. -REMOTE_HOST = "localhost" \ No newline at end of file +USE_SSL = True +REMOTE_HOST = "127.0.0.1" +REMOTE_PORT = 443 \ No newline at end of file From e242e72b2d9a09b22abc1f9769235a00e84f4f94 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 21:41:30 +0800 Subject: [PATCH 2/7] Drop independent log server Signed-off-by: Jaida Wu --- src/main/java/emu/grasscutter/Config.java | 3 --- .../server/dispatch/DispatchServer.java | 18 ++++++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 4d4cf4a38..65ada3969 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -13,9 +13,6 @@ public final class Config { public String GameServerPublicIp = ""; public int GameServerPort = 22102; - public int OverseaLogPort = 8888; - public int UploadLogPort = 80; - public String DatabaseUrl = "mongodb://localhost:27017"; public String DatabaseCollection = "grasscutter"; diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 6b4336858..e59f9d251 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -405,25 +405,18 @@ public final class DispatchServer { "/perf/config/verify", new DispatchHttpJsonHandler("{\"code\":0}") ); - // Start server - server.start(); - Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); // Logging servers - HttpServer overseaLogServer = HttpServer.create(new InetSocketAddress(Grasscutter.getConfig().DispatchServerIp, Grasscutter.getConfig().OverseaLogPort), 0); - overseaLogServer.createContext( // overseauspider.yuanshen.com + server.createContext( // overseauspider.yuanshen.com "/log", new DispatchHttpJsonHandler("{\"code\":0}") ); - overseaLogServer.start(); - Grasscutter.getLogger().info("Log server (overseauspider) started on port " + 8888); - HttpServer uploadLogServer = HttpServer.create(new InetSocketAddress(Grasscutter.getConfig().DispatchServerIp, Grasscutter.getConfig().UploadLogPort), 0); - uploadLogServer.createContext( // log-upload-os.mihoyo.com + server.createContext( // log-upload-os.mihoyo.com "/crash/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}") ); - uploadLogServer.createContext("/gacha", t -> { + server.createContext("/gacha", t -> { //Create a response form the request query parameters String response = "Gacha"; //Set the response header status and length @@ -434,8 +427,9 @@ public final class DispatchServer { os.write(response.getBytes()); os.close(); }); - uploadLogServer.start(); - Grasscutter.getLogger().info("Log server (log-upload-os) started on port " + Grasscutter.getConfig().UploadLogPort); + // Start server + server.start(); + Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); } private Map parseQueryString(String qs) { From 23226ad4649f1d1f30473737c41d388fcb55e18a Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 22:06:25 +0800 Subject: [PATCH 3/7] Refact code Signed-off-by: Jaida Wu --- src/main/java/emu/grasscutter/Config.java | 12 +- .../server/dispatch/DispatchServer.java | 283 ++++++++---------- .../dispatch/json/ComboTokenReqJson.java | 2 +- .../dispatch/json/ComboTokenResJson.java | 2 +- .../server/dispatch/json/LoginResultJson.java | 4 +- 5 files changed, 141 insertions(+), 162 deletions(-) diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 65ada3969..f51e5cd59 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -12,10 +12,10 @@ public final class Config { public String GameServerIp = "127.0.0.1"; public String GameServerPublicIp = ""; public int GameServerPort = 22102; - + public String DatabaseUrl = "mongodb://localhost:27017"; public String DatabaseCollection = "grasscutter"; - + public String RESOURCE_FOLDER = "./resources/"; public String DATA_FOLDER = "./data/"; public String PACKETS_FOLDER = "./packets/"; @@ -25,21 +25,21 @@ public final class Config { public GameRates Game = new GameRates(); public ServerOptions ServerOptions = new ServerOptions(); - + public GameRates getGameRates() { return Game; } - + public ServerOptions getServerOptions() { return ServerOptions; } - + public static class GameRates { public float ADVENTURE_EXP_RATE = 1.0f; public float MORA_RATE = 1.0f; public float DOMAIN_DROP_RATE = 1.0f; } - + public static class ServerOptions { public int InventoryLimitWeapon = 2000; public int InventoryLimitRelic = 2000; diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index e59f9d251..b4d4993d8 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -1,10 +1,27 @@ package emu.grasscutter.server.dispatch; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.protobuf.ByteString; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsServer; +import emu.grasscutter.Grasscutter; +import emu.grasscutter.database.DatabaseHelper; +import emu.grasscutter.game.Account; +import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp; +import emu.grasscutter.net.proto.QueryRegionListHttpRspOuterClass.QueryRegionListHttpRsp; +import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo; +import emu.grasscutter.net.proto.RegionSimpleInfoOuterClass.RegionSimpleInfo; +import emu.grasscutter.server.dispatch.json.*; +import emu.grasscutter.server.dispatch.json.ComboTokenReqJson.LoginTokenData; +import emu.grasscutter.utils.FileUtils; +import emu.grasscutter.utils.Utils; + +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; +import java.io.*; import java.net.InetSocketAddress; import java.net.URI; import java.net.URLDecoder; @@ -14,58 +31,27 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.protobuf.ByteString; -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpsConfigurator; -import com.sun.net.httpserver.HttpsServer; - -import emu.grasscutter.Grasscutter; -import emu.grasscutter.database.DatabaseHelper; -import emu.grasscutter.game.Account; -import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp; -import emu.grasscutter.net.proto.QueryRegionListHttpRspOuterClass.QueryRegionListHttpRsp; -import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo; -import emu.grasscutter.net.proto.RegionSimpleInfoOuterClass.RegionSimpleInfo; -import emu.grasscutter.server.dispatch.json.ComboTokenReqJson; -import emu.grasscutter.server.dispatch.json.ComboTokenResJson; -import emu.grasscutter.server.dispatch.json.LoginAccountRequestJson; -import emu.grasscutter.server.dispatch.json.LoginResultJson; -import emu.grasscutter.server.dispatch.json.LoginTokenRequestJson; -import emu.grasscutter.server.dispatch.json.ComboTokenReqJson.LoginTokenData; -import emu.grasscutter.utils.FileUtils; -import emu.grasscutter.utils.Utils; - -import com.sun.net.httpserver.HttpServer; - public final class DispatchServer { - private final InetSocketAddress address; - private final Gson gson; - private QueryCurrRegionHttpRsp currRegion; - - public String regionListBase64; - public String regionCurrentBase64; - public static String query_region_list = ""; public static String query_cur_region = ""; - + private final InetSocketAddress address; + private final Gson gson; + public String regionListBase64; + public String regionCurrentBase64; + private QueryCurrRegionHttpRsp currRegion; + public DispatchServer() { this.address = new InetSocketAddress(Grasscutter.getConfig().DispatchServerIp, Grasscutter.getConfig().DispatchServerPort); this.gson = new GsonBuilder().create(); - + this.loadQueries(); this.initRegion(); } - + public InetSocketAddress getAddress() { return address; } - + public Gson getGsonFactory() { return gson; } @@ -73,17 +59,17 @@ public final class DispatchServer { public QueryCurrRegionHttpRsp getCurrRegion() { return currRegion; } - + public void loadQueries() { File file; - + file = new File(Grasscutter.getConfig().DATA_FOLDER + "query_region_list.txt"); if (file.exists()) { query_region_list = new String(FileUtils.read(file)); } else { Grasscutter.getLogger().warn("query_region_list not found! Using default region list."); } - + file = new File(Grasscutter.getConfig().DATA_FOLDER + "query_cur_region.txt"); if (file.exists()) { query_cur_region = new String(FileUtils.read(file)); @@ -96,38 +82,38 @@ public final class DispatchServer { try { byte[] decoded = Base64.getDecoder().decode(query_region_list); QueryRegionListHttpRsp rl = QueryRegionListHttpRsp.parseFrom(decoded); - + byte[] decoded2 = Base64.getDecoder().decode(query_cur_region); QueryCurrRegionHttpRsp regionQuery = QueryCurrRegionHttpRsp.parseFrom(decoded2); - + RegionSimpleInfo server = RegionSimpleInfo.newBuilder() .setName("os_usa") .setTitle(Grasscutter.getConfig().GameServerName) .setType("DEV_PUBLIC") .setDispatchUrl("https://" + (Grasscutter.getConfig().DispatchServerPublicIp.isEmpty() ? Grasscutter.getConfig().DispatchServerIp : Grasscutter.getConfig().DispatchServerPublicIp) + ":" + getAddress().getPort() + "/query_cur_region") .build(); - + RegionSimpleInfo serverTest2 = RegionSimpleInfo.newBuilder() .setName("os_euro") .setTitle("Grasscutter") .setType("DEV_PUBLIC") .setDispatchUrl("https://" + (Grasscutter.getConfig().DispatchServerPublicIp.isEmpty() ? Grasscutter.getConfig().DispatchServerIp : Grasscutter.getConfig().DispatchServerPublicIp) + ":" + getAddress().getPort() + "/query_cur_region") .build(); - + QueryRegionListHttpRsp regionList = QueryRegionListHttpRsp.newBuilder() - .addServers(server) - .addServers(serverTest2) - .setClientSecretKey(rl.getClientSecretKey()) - .setClientCustomConfigEncrypted(rl.getClientCustomConfigEncrypted()) - .setEnableLoginPc(true) - .build(); - + .addServers(server) + .addServers(serverTest2) + .setClientSecretKey(rl.getClientSecretKey()) + .setClientCustomConfigEncrypted(rl.getClientCustomConfigEncrypted()) + .setEnableLoginPc(true) + .build(); + RegionInfo currentRegion = regionQuery.getRegionInfo().toBuilder() .setIp((Grasscutter.getConfig().GameServerPublicIp.isEmpty() ? Grasscutter.getConfig().GameServerIp : Grasscutter.getConfig().GameServerPublicIp)) .setPort(Grasscutter.getConfig().GameServerPort) .setSecretKey(ByteString.copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin"))) .build(); - + QueryCurrRegionHttpRsp parsedRegionQuery = regionQuery.toBuilder().setRegionInfo(currentRegion).build(); this.regionListBase64 = Base64.getEncoder().encodeToString(regionList.toByteString().toByteArray()); @@ -140,7 +126,7 @@ public final class DispatchServer { public void start() throws Exception { HttpServer server; - if(Grasscutter.getConfig().UseSSL) { + if (Grasscutter.getConfig().UseSSL) { HttpsServer httpsServer; httpsServer = HttpsServer.create(getAddress(), 0); SSLContext sslContext = SSLContext.getInstance("TLS"); @@ -150,9 +136,9 @@ public final class DispatchServer { ks.load(fis, keystorePassword); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, keystorePassword); - + sslContext.init(kmf.getKeyManagers(), null, null); - + httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); server = httpsServer; } catch (Exception e) { @@ -162,7 +148,7 @@ public final class DispatchServer { } else { server = HttpServer.create(getAddress(), 0); } - + server.createContext("/", t -> { //Create a response form the request query parameters String response = "Hello"; @@ -174,7 +160,7 @@ public final class DispatchServer { os.write(response.getBytes()); os.close(); }); - + // Dispatch server.createContext("/query_region_list", t -> { // Log @@ -213,33 +199,38 @@ public final class DispatchServer { try { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, LoginAccountRequestJson.class); - } catch (Exception e) { - + } catch (Exception ignored) { + } // Create response json if (requestData == null) { return; } LoginResultJson responseData = new LoginResultJson(); - + // Login Account account = DatabaseHelper.getAccountByName(requestData.account); - + // Check if account exists, else create a new one. if (account == null) { // Account doesnt exist, so we can either auto create it if the config value is set if (Grasscutter.getConfig().ServerOptions.AutomaticallyCreateAccounts) { // This account has been created AUTOMATICALLY. There will be no permissions added. account = DatabaseHelper.createAccountWithId(requestData.account, 0); - - responseData.message = "OK"; - responseData.data.account.uid = account.getId(); - responseData.data.account.token = account.generateSessionKey(); - responseData.data.account.email = account.getEmail(); + + if (account != null) { + responseData.message = "OK"; + responseData.data.account.uid = account.getId(); + responseData.data.account.token = account.generateSessionKey(); + responseData.data.account.email = account.getEmail(); + } else { + responseData.retcode = -201; + responseData.message = "Username not found, create failed."; + } } else { responseData.retcode = -201; responseData.message = "Username not found."; - } + } } else { // Account was found, log the player in responseData.message = "OK"; @@ -247,16 +238,8 @@ public final class DispatchServer { responseData.data.account.token = account.generateSessionKey(); responseData.data.account.email = account.getEmail(); } - - // Create a response - String response = getGsonFactory().toJson(responseData); - // Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("application/json")); - t.sendResponseHeaders(200, response.getBytes().length); - // Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); + + responseJson(t, responseData); }); // Login via token server.createContext("/hk4e_global/mdk/shield/api/verify", t -> { @@ -265,8 +248,8 @@ public final class DispatchServer { try { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, LoginTokenRequestJson.class); - } catch (Exception e) { - + } catch (Exception ignored) { + } // Create response json if (requestData == null) { @@ -276,7 +259,7 @@ public final class DispatchServer { // Login Account account = DatabaseHelper.getAccountById(requestData.uid); - + // Test if (account == null || !account.getSessionKey().equals(requestData.token)) { responseData.retcode = -111; @@ -287,16 +270,8 @@ public final class DispatchServer { responseData.data.account.token = requestData.token; responseData.data.account.email = account.getEmail(); } - - // Create a response - String response = getGsonFactory().toJson(responseData); - // Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("application/json")); - t.sendResponseHeaders(200, response.getBytes().length); - // Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); + + responseJson(t, responseData); }); // Exchange for combo token server.createContext("/hk4e_global/combo/granter/login/v2/login", t -> { @@ -305,8 +280,8 @@ public final class DispatchServer { try { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, ComboTokenReqJson.class); - } catch (Exception e) { - + } catch (Exception ignored) { + } // Create response json if (requestData == null || requestData.data == null) { @@ -317,7 +292,7 @@ public final class DispatchServer { // Login Account account = DatabaseHelper.getAccountById(loginData.uid); - + // Test if (account == null || !account.getSessionKey().equals(loginData.token)) { responseData.retcode = -201; @@ -328,29 +303,21 @@ public final class DispatchServer { responseData.data.combo_id = "157795300"; responseData.data.combo_token = account.generateLoginToken(); } - - // Create a response - String response = getGsonFactory().toJson(responseData); - // Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("application/json")); - t.sendResponseHeaders(200, response.getBytes().length); - // Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); + + responseJson(t, responseData); }); // Agreement and Protocol server.createContext( // hk4e-sdk-os.hoyoverse.com - "/hk4e_global/mdk/agreement/api/getAgreementInfos", + "/hk4e_global/mdk/agreement/api/getAgreementInfos", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"marketing_agreements\":[]}}") ); server.createContext( // hk4e-sdk-os.hoyoverse.com - "/hk4e_global/combo/granter/api/compareProtocolVersion", + "/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 server.createContext( // hk4e-api-os.hoyoverse.com - "/common/hk4e_global/announcement/api/getAlertPic", + "/common/hk4e_global/announcement/api/getAlertPic", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"total\":0,\"list\":[]}}") ); server.createContext( // hk4e-api-os.hoyoverse.com @@ -358,62 +325,62 @@ public final class DispatchServer { new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"alert\":false,\"alert_id\":0,\"remind\":true}}") ); server.createContext( // hk4e-api-os.hoyoverse.com - "/common/hk4e_global/announcement/api/getAnnList", + "/common/hk4e_global/announcement/api/getAnnList", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"list\":[],\"total\":0,\"type_list\":[],\"alert\":false,\"alert_id\":0,\"timezone\":0,\"t\":\"" + System.currentTimeMillis() + "\"}}") ); server.createContext( // hk4e-api-os-static.hoyoverse.com - "/common/hk4e_global/announcement/api/getAnnContent", + "/common/hk4e_global/announcement/api/getAnnContent", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"list\":[],\"total\":0}}") ); server.createContext( // hk4e-sdk-os.hoyoverse.com - "/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier", + "/hk4e_global/mdk/shopwindow/shopwindow/listPriceTier", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"suggest_currency\":\"USD\",\"tiers\":[]}}") ); // Captcha server.createContext( // api-account-os.hoyoverse.com - "/account/risky/api/check", + "/account/risky/api/check", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":\"c8820f246a5241ab9973f71df3ddd791\",\"action\":\"\",\"geetest\":{\"challenge\":\"\",\"gt\":\"\",\"new_captcha\":0,\"success\":1}}}") ); // Config server.createContext( // sdk-os-static.hoyoverse.com - "/combo/box/api/config/sdk/combo", + "/combo/box/api/config/sdk/combo", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"vals\":{\"disable_email_bind_skip\":\"false\",\"email_bind_remind_interval\":\"7\",\"email_bind_remind\":\"true\"}}}") ); server.createContext( // hk4e-sdk-os-static.hoyoverse.com - "/hk4e_global/combo/granter/api/getConfig", + "/hk4e_global/combo/granter/api/getConfig", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"protocol\":true,\"qr_enabled\":false,\"log_level\":\"INFO\",\"announce_url\":\"https://webstatic-sea.hoyoverse.com/hk4e/announcement/index.html?sdk_presentation_style=fullscreen\\u0026sdk_screen_transparent=true\\u0026game_biz=hk4e_global\\u0026auth_appid=announcement\\u0026game=hk4e#/\",\"push_alias_type\":2,\"disable_ysdk_guard\":false,\"enable_announce_pic_popup\":true}}") ); server.createContext( // hk4e-sdk-os-static.hoyoverse.com - "/hk4e_global/mdk/shield/api/loadConfig", + "/hk4e_global/mdk/shield/api/loadConfig", new DispatchHttpJsonHandler("{\"retcode\":0,\"message\":\"OK\",\"data\":{\"id\":6,\"game_key\":\"hk4e_global\",\"client\":\"PC\",\"identity\":\"I_IDENTITY\",\"guest\":false,\"ignore_versions\":\"\",\"scene\":\"S_NORMAL\",\"name\":\"原神海外\",\"disable_regist\":false,\"enable_email_captcha\":false,\"thirdparty\":[\"fb\",\"tw\"],\"disable_mmt\":false,\"server_guest\":false,\"thirdparty_ignore\":{\"tw\":\"\",\"fb\":\"\"},\"enable_ps_bind_account\":false,\"thirdparty_login_configs\":{\"tw\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800},\"fb\":{\"token_type\":\"TK_GAME_TOKEN\",\"game_token_expires_in\":604800}}}}") ); // Test api? server.createContext( // abtest-api-data-sg.hoyoverse.com - "/data_abtest_api/config/experiment/list", + "/data_abtest_api/config/experiment/list", new DispatchHttpJsonHandler("{\"retcode\":0,\"success\":true,\"message\":\"\",\"data\":[{\"code\":1000,\"type\":2,\"config_id\":\"14\",\"period_id\":\"6036_99\",\"version\":\"1\",\"configs\":{\"cardType\":\"old\"}}]}") ); // Log Server server.createContext( // log-upload-os.mihoyo.com - "/log/sdk/upload", + "/log/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}") ); server.createContext( // log-upload-os.mihoyo.com - "/sdk/upload", + "/sdk/upload", new DispatchHttpJsonHandler("{\"code\":0}") ); server.createContext( // /perf/config/verify?device_id=xxx&platform=x&name=xxx - "/perf/config/verify", + "/perf/config/verify", new DispatchHttpJsonHandler("{\"code\":0}") ); - + // Logging servers server.createContext( // overseauspider.yuanshen.com - "/log", + "/log", new DispatchHttpJsonHandler("{\"code\":0}") ); - + server.createContext( // log-upload-os.mihoyo.com - "/crash/dataUpload", + "/crash/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}") ); server.createContext("/gacha", t -> { @@ -431,31 +398,43 @@ public final class DispatchServer { server.start(); Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); } - + + private void responseJson(HttpExchange t, Object data) throws IOException { + // Create a response + String response = getGsonFactory().toJson(data); + // Set the response header status and length + t.getResponseHeaders().put("Content-Type", Collections.singletonList("application/json")); + t.sendResponseHeaders(200, response.getBytes().length); + // Write the response string + OutputStream os = t.getResponseBody(); + os.write(response.getBytes()); + os.close(); + } + private Map parseQueryString(String qs) { - Map result = new HashMap<>(); - if (qs == null) - return result; + Map result = new HashMap<>(); + if (qs == null) + return result; - int last = 0, next, l = qs.length(); - while (last < l) { - next = qs.indexOf('&', last); - if (next == -1) - next = l; + int last = 0, next, l = qs.length(); + while (last < l) { + next = qs.indexOf('&', last); + if (next == -1) + next = l; - if (next > last) { - int eqPos = qs.indexOf('=', last); - try { - if (eqPos < 0 || eqPos > next) - result.put(URLDecoder.decode(qs.substring(last, next), "utf-8"), ""); - else - result.put(URLDecoder.decode(qs.substring(last, eqPos), "utf-8"), URLDecoder.decode(qs.substring(eqPos + 1, next), "utf-8")); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); // will never happen, utf-8 support is mandatory for java - } - } - last = next + 1; - } - return result; + if (next > last) { + int eqPos = qs.indexOf('=', last); + try { + if (eqPos < 0 || eqPos > next) + result.put(URLDecoder.decode(qs.substring(last, next), "utf-8"), ""); + else + result.put(URLDecoder.decode(qs.substring(last, eqPos), "utf-8"), URLDecoder.decode(qs.substring(eqPos + 1, next), "utf-8")); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); // will never happen, utf-8 support is mandatory for java + } + } + last = next + 1; + } + return result; } } diff --git a/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenReqJson.java b/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenReqJson.java index dac26cfa4..b3497f8d4 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenReqJson.java +++ b/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenReqJson.java @@ -7,7 +7,7 @@ public class ComboTokenReqJson { public String device; public String sign; - public class LoginTokenData { + public static class LoginTokenData { public String uid; public String token; public boolean guest; diff --git a/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenResJson.java b/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenResJson.java index 731d50853..7c49d1278 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenResJson.java +++ b/src/main/java/emu/grasscutter/server/dispatch/json/ComboTokenResJson.java @@ -5,7 +5,7 @@ public class ComboTokenResJson { public int retcode; public LoginData data = new LoginData(); - public class LoginData { + public static class LoginData { public int account_type = 1; public boolean heartbeat; public String combo_id; diff --git a/src/main/java/emu/grasscutter/server/dispatch/json/LoginResultJson.java b/src/main/java/emu/grasscutter/server/dispatch/json/LoginResultJson.java index 5988752d8..88e142d4f 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/json/LoginResultJson.java +++ b/src/main/java/emu/grasscutter/server/dispatch/json/LoginResultJson.java @@ -5,7 +5,7 @@ public class LoginResultJson { public int retcode; public VerifyData data = new VerifyData(); - public class VerifyData { + public static class VerifyData { public VerifyAccountData account = new VerifyAccountData(); public boolean device_grant_required = false; public String realname_operation = "NONE"; @@ -13,7 +13,7 @@ public class LoginResultJson { public boolean safe_mobile_required = false; } - public class VerifyAccountData { + public static class VerifyAccountData { public String uid; public String name = ""; public String email; From 12674f6cec64259d930c5eb8680f46c8e00e5335 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 22:21:28 +0800 Subject: [PATCH 4/7] Fallback to HTTP if no SSL cert Signed-off-by: Jaida Wu --- .../java/emu/grasscutter/server/dispatch/DispatchServer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index b4d4993d8..392609a07 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -142,8 +142,9 @@ public final class DispatchServer { httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); server = httpsServer; } catch (Exception e) { - Grasscutter.getLogger().error("No SSL cert found!"); - return; + Grasscutter.getLogger().error("No SSL cert found! Falling back to HTTP server."); + Grasscutter.getConfig().UseSSL = false; + server = HttpServer.create(getAddress(), 0); } } else { server = HttpServer.create(getAddress(), 0); From 1143886b091a3ee88708da9f2176315b1f1239d3 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 22:22:40 +0800 Subject: [PATCH 5/7] Add some log to dispatch server Signed-off-by: Jaida Wu --- .../server/dispatch/DispatchServer.java | 100 +++++++++--------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 392609a07..0e2283652 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -150,48 +150,26 @@ public final class DispatchServer { server = HttpServer.create(getAddress(), 0); } - server.createContext("/", t -> { - //Create a response form the request query parameters - String response = "Hello"; - //Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("text/html; charset=UTF-8")); - t.sendResponseHeaders(200, response.getBytes().length); - //Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); - }); + server.createContext("/", t -> responseHTML(t, "Hello")); // Dispatch server.createContext("/query_region_list", t -> { // Log - Grasscutter.getLogger().info("Client request: query_region_list"); - // Create a response form the request query parameters - String response = regionListBase64; - // Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("text/html; charset=UTF-8")); - t.sendResponseHeaders(200, response.getBytes().length); - // Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); + Grasscutter.getLogger().info(String.format("Client %s request: query_region_list", t.getRemoteAddress())); + + responseHTML(t, regionListBase64); }); server.createContext("/query_cur_region", t -> { // Log - Grasscutter.getLogger().info("Client request: query_cur_region"); + Grasscutter.getLogger().info(String.format("Client %s request: query_cur_region", t.getRemoteAddress())); // Create a response form the request query parameters URI uri = t.getRequestURI(); String response = "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="; if (uri.getQuery() != null && uri.getQuery().length() > 0) { response = regionCurrentBase64; } - // Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("text/html; charset=UTF-8")); - t.sendResponseHeaders(200, response.getBytes().length); - // Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); + + responseHTML(t, response); }); // Login via account server.createContext("/hk4e_global/mdk/shield/api/login", t -> { @@ -201,7 +179,6 @@ public final class DispatchServer { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, LoginAccountRequestJson.class); } catch (Exception ignored) { - } // Create response json if (requestData == null) { @@ -209,6 +186,8 @@ public final class DispatchServer { } LoginResultJson responseData = new LoginResultJson(); + Grasscutter.getLogger().info(String.format("Client %s is trying to log in", t.getRemoteAddress())); + // Login Account account = DatabaseHelper.getAccountByName(requestData.account); @@ -224,13 +203,19 @@ public final class DispatchServer { responseData.data.account.uid = account.getId(); responseData.data.account.token = account.generateSessionKey(); responseData.data.account.email = account.getEmail(); + + Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account %s created", t.getRemoteAddress(), responseData.data.account.uid)); } else { responseData.retcode = -201; responseData.message = "Username not found, create failed."; + + Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account create failed", t.getRemoteAddress())); } } else { responseData.retcode = -201; responseData.message = "Username not found."; + + Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account no found", t.getRemoteAddress())); } } else { // Account was found, log the player in @@ -238,10 +223,13 @@ public final class DispatchServer { responseData.data.account.uid = account.getId(); responseData.data.account.token = account.generateSessionKey(); responseData.data.account.email = account.getEmail(); + + Grasscutter.getLogger().info(String.format("Client %s logged in as %s", t.getRemoteAddress(), responseData.data.account.uid)); } - responseJson(t, responseData); + responseJSON(t, responseData); }); + // Login via token server.createContext("/hk4e_global/mdk/shield/api/verify", t -> { // Get post data @@ -250,13 +238,13 @@ public final class DispatchServer { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, LoginTokenRequestJson.class); } catch (Exception ignored) { - } // Create response json if (requestData == null) { return; } LoginResultJson responseData = new LoginResultJson(); + Grasscutter.getLogger().info(String.format("Client %s is trying to log in via token", t.getRemoteAddress())); // Login Account account = DatabaseHelper.getAccountById(requestData.uid); @@ -265,14 +253,18 @@ public final class DispatchServer { if (account == null || !account.getSessionKey().equals(requestData.token)) { responseData.retcode = -111; responseData.message = "Game account cache information error"; + + Grasscutter.getLogger().info(String.format("Client %s failed to log in via token", t.getRemoteAddress())); } else { responseData.message = "OK"; responseData.data.account.uid = requestData.uid; responseData.data.account.token = requestData.token; responseData.data.account.email = account.getEmail(); + + Grasscutter.getLogger().info(String.format("Client %s logged in via token as %s", t.getRemoteAddress(), responseData.data.account.uid)); } - responseJson(t, responseData); + responseJSON(t, responseData); }); // Exchange for combo token server.createContext("/hk4e_global/combo/granter/login/v2/login", t -> { @@ -282,7 +274,6 @@ public final class DispatchServer { String body = Utils.toString(t.getRequestBody()); requestData = getGsonFactory().fromJson(body, ComboTokenReqJson.class); } catch (Exception ignored) { - } // Create response json if (requestData == null || requestData.data == null) { @@ -298,14 +289,18 @@ public final class DispatchServer { if (account == null || !account.getSessionKey().equals(loginData.token)) { responseData.retcode = -201; responseData.message = "Wrong session key."; + + Grasscutter.getLogger().info(String.format("Client %s failed to exchange combo token", t.getRemoteAddress())); } else { responseData.message = "OK"; responseData.data.open_id = loginData.uid; responseData.data.combo_id = "157795300"; responseData.data.combo_token = account.generateLoginToken(); + + Grasscutter.getLogger().info(String.format("Client %s succeed to exchange combo token", t.getRemoteAddress())); } - responseJson(t, responseData); + responseJSON(t, responseData); }); // Agreement and Protocol server.createContext( // hk4e-sdk-os.hoyoverse.com @@ -384,23 +379,13 @@ public final class DispatchServer { "/crash/dataUpload", new DispatchHttpJsonHandler("{\"code\":0}") ); - server.createContext("/gacha", t -> { - //Create a response form the request query parameters - String response = "Gacha"; - //Set the response header status and length - t.getResponseHeaders().put("Content-Type", Collections.singletonList("text/html; charset=UTF-8")); - t.sendResponseHeaders(200, response.getBytes().length); - //Write the response string - OutputStream os = t.getResponseBody(); - os.write(response.getBytes()); - os.close(); - }); + server.createContext("/gacha", t -> responseHTML(t, "Gacha")); // Start server server.start(); Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); } - private void responseJson(HttpExchange t, Object data) throws IOException { + private void responseJSON(HttpExchange t, Object data) throws IOException { // Create a response String response = getGsonFactory().toJson(data); // Set the response header status and length @@ -412,24 +397,37 @@ public final class DispatchServer { os.close(); } + private void responseHTML(HttpExchange t, String response) throws IOException { + // Set the response header status and length + t.getResponseHeaders().put("Content-Type", Collections.singletonList("text/html; charset=UTF-8")); + t.sendResponseHeaders(200, response.getBytes().length); + //Write the response string + OutputStream os = t.getResponseBody(); + os.write(response.getBytes()); + os.close(); + } + private Map parseQueryString(String qs) { Map result = new HashMap<>(); - if (qs == null) + if (qs == null) { return result; + } int last = 0, next, l = qs.length(); while (last < l) { next = qs.indexOf('&', last); - if (next == -1) + if (next == -1) { next = l; + } if (next > last) { int eqPos = qs.indexOf('=', last); try { - if (eqPos < 0 || eqPos > next) + if (eqPos < 0 || eqPos > next) { result.put(URLDecoder.decode(qs.substring(last, next), "utf-8"), ""); - else + } else { result.put(URLDecoder.decode(qs.substring(last, eqPos), "utf-8"), URLDecoder.decode(qs.substring(eqPos + 1, next), "utf-8")); + } } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); // will never happen, utf-8 support is mandatory for java } From d11413c0170ef6b2d4fa258ca7e7714f560320d1 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 22:26:28 +0800 Subject: [PATCH 6/7] Add dispatch server log prefix Signed-off-by: Jaida Wu --- .../server/dispatch/DispatchServer.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 0e2283652..5b46f9def 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -67,14 +67,14 @@ public final class DispatchServer { if (file.exists()) { query_region_list = new String(FileUtils.read(file)); } else { - Grasscutter.getLogger().warn("query_region_list not found! Using default region list."); + Grasscutter.getLogger().warn("[Dispatch] query_region_list not found! Using default region list."); } file = new File(Grasscutter.getConfig().DATA_FOLDER + "query_cur_region.txt"); if (file.exists()) { query_cur_region = new String(FileUtils.read(file)); } else { - Grasscutter.getLogger().warn("query_cur_region not found! Using default current region."); + Grasscutter.getLogger().warn("[Dispatch] query_cur_region not found! Using default current region."); } } @@ -120,7 +120,7 @@ public final class DispatchServer { this.regionCurrentBase64 = Base64.getEncoder().encodeToString(parsedRegionQuery.toByteString().toByteArray()); this.currRegion = parsedRegionQuery; } catch (Exception e) { - Grasscutter.getLogger().error("Error while initializing region info!", e); + Grasscutter.getLogger().error("[Dispatch] Error while initializing region info!", e); } } @@ -142,7 +142,7 @@ public final class DispatchServer { httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); server = httpsServer; } catch (Exception e) { - Grasscutter.getLogger().error("No SSL cert found! Falling back to HTTP server."); + Grasscutter.getLogger().warn("[Dispatch] No SSL cert found! Falling back to HTTP server."); Grasscutter.getConfig().UseSSL = false; server = HttpServer.create(getAddress(), 0); } @@ -155,13 +155,13 @@ public final class DispatchServer { // Dispatch server.createContext("/query_region_list", t -> { // Log - Grasscutter.getLogger().info(String.format("Client %s request: query_region_list", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s request: query_region_list", t.getRemoteAddress())); responseHTML(t, regionListBase64); }); server.createContext("/query_cur_region", t -> { // Log - Grasscutter.getLogger().info(String.format("Client %s request: query_cur_region", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s request: query_cur_region", t.getRemoteAddress())); // Create a response form the request query parameters URI uri = t.getRequestURI(); String response = "CAESGE5vdCBGb3VuZCB2ZXJzaW9uIGNvbmZpZw=="; @@ -186,7 +186,7 @@ public final class DispatchServer { } LoginResultJson responseData = new LoginResultJson(); - Grasscutter.getLogger().info(String.format("Client %s is trying to log in", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s is trying to log in", t.getRemoteAddress())); // Login Account account = DatabaseHelper.getAccountByName(requestData.account); @@ -204,18 +204,18 @@ public final class DispatchServer { responseData.data.account.token = account.generateSessionKey(); responseData.data.account.email = account.getEmail(); - Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account %s created", t.getRemoteAddress(), responseData.data.account.uid)); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s failed to log in: Account %s created", t.getRemoteAddress(), responseData.data.account.uid)); } else { responseData.retcode = -201; responseData.message = "Username not found, create failed."; - Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account create failed", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s failed to log in: Account create failed", t.getRemoteAddress())); } } else { responseData.retcode = -201; responseData.message = "Username not found."; - Grasscutter.getLogger().info(String.format("Client %s failed to log in: Account no found", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s failed to log in: Account no found", t.getRemoteAddress())); } } else { // Account was found, log the player in @@ -224,7 +224,7 @@ public final class DispatchServer { responseData.data.account.token = account.generateSessionKey(); responseData.data.account.email = account.getEmail(); - Grasscutter.getLogger().info(String.format("Client %s logged in as %s", t.getRemoteAddress(), responseData.data.account.uid)); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in as %s", t.getRemoteAddress(), responseData.data.account.uid)); } responseJSON(t, responseData); @@ -244,7 +244,7 @@ public final class DispatchServer { return; } LoginResultJson responseData = new LoginResultJson(); - Grasscutter.getLogger().info(String.format("Client %s is trying to log in via token", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s is trying to log in via token", t.getRemoteAddress())); // Login Account account = DatabaseHelper.getAccountById(requestData.uid); @@ -254,14 +254,14 @@ public final class DispatchServer { responseData.retcode = -111; responseData.message = "Game account cache information error"; - Grasscutter.getLogger().info(String.format("Client %s failed to log in via token", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s failed to log in via token", t.getRemoteAddress())); } else { responseData.message = "OK"; responseData.data.account.uid = requestData.uid; responseData.data.account.token = requestData.token; responseData.data.account.email = account.getEmail(); - Grasscutter.getLogger().info(String.format("Client %s logged in via token as %s", t.getRemoteAddress(), responseData.data.account.uid)); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s logged in via token as %s", t.getRemoteAddress(), responseData.data.account.uid)); } responseJSON(t, responseData); @@ -290,14 +290,14 @@ public final class DispatchServer { responseData.retcode = -201; responseData.message = "Wrong session key."; - Grasscutter.getLogger().info(String.format("Client %s failed to exchange combo token", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s failed to exchange combo token", t.getRemoteAddress())); } else { responseData.message = "OK"; responseData.data.open_id = loginData.uid; responseData.data.combo_id = "157795300"; responseData.data.combo_token = account.generateLoginToken(); - Grasscutter.getLogger().info(String.format("Client %s succeed to exchange combo token", t.getRemoteAddress())); + Grasscutter.getLogger().info(String.format("[Dispatch] Client %s succeed to exchange combo token", t.getRemoteAddress())); } responseJSON(t, responseData); @@ -382,7 +382,7 @@ public final class DispatchServer { server.createContext("/gacha", t -> responseHTML(t, "Gacha")); // Start server server.start(); - Grasscutter.getLogger().info("Dispatch server started on port " + getAddress().getPort()); + Grasscutter.getLogger().info("[Dispatch] Dispatch server started on port " + getAddress().getPort()); } private void responseJSON(HttpExchange t, Object data) throws IOException { From 54856147ef4750ef76277663f3c84555809ff6d9 Mon Sep 17 00:00:00 2001 From: Jaida Wu Date: Thu, 21 Apr 2022 22:27:26 +0800 Subject: [PATCH 7/7] Listens to all addresses by default Signed-off-by: Jaida Wu --- src/main/java/emu/grasscutter/Config.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index f51e5cd59..0b011e576 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -1,16 +1,16 @@ package emu.grasscutter; public final class Config { - public String DispatchServerIp = "127.0.0.1"; - public String DispatchServerPublicIp = ""; + public String DispatchServerIp = "0.0.0.0"; + public String DispatchServerPublicIp = "127.0.0.1"; public int DispatchServerPort = 443; public String DispatchServerKeystorePath = "./keystore.p12"; public String DispatchServerKeystorePassword = ""; public Boolean UseSSL = true; public String GameServerName = "Test"; - public String GameServerIp = "127.0.0.1"; - public String GameServerPublicIp = ""; + public String GameServerIp = "0.0.0.0"; + public String GameServerPublicIp = "127.0.0.1"; public int GameServerPort = 22102; public String DatabaseUrl = "mongodb://localhost:27017";