From f3dc5f81eae0dacd5e9c0c1a5cc6fe98c796b83a Mon Sep 17 00:00:00 2001 From: ayy lmao Date: Mon, 18 Apr 2022 12:10:12 +0300 Subject: [PATCH] Add support for specifying a Public IP --- src/main/java/emu/grasscutter/Config.java | 2 ++ src/main/java/emu/grasscutter/game/gacha/GachaBanner.java | 2 +- .../emu/grasscutter/server/dispatch/DispatchServer.java | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 945ff006b..b7a971122 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -2,12 +2,14 @@ package emu.grasscutter; public final class Config { public String DispatchServerIp = "127.0.0.1"; + public String DispatchServerPublicIp = ""; public int DispatchServerPort = 443; public String DispatchServerKeystorePath = "./keystore.p12"; public String DispatchServerKeystorePassword = ""; public String GameServerName = "Test"; public String GameServerIp = "127.0.0.1"; + public String GameServerPublicIp = ""; public int GameServerPort = 22102; public String DatabaseUrl = "mongodb://localhost:27017"; diff --git a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java index 43e9e120e..3e6bcdf7e 100644 --- a/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java +++ b/src/main/java/emu/grasscutter/game/gacha/GachaBanner.java @@ -92,7 +92,7 @@ public class GachaBanner { } public GachaInfo toProto() { - String record = "http://" + Grasscutter.getConfig().DispatchServerIp + "/gacha"; + String record = "http://" + (Grasscutter.getConfig().DispatchServerPublicIp.isEmpty() ? Grasscutter.getConfig().DispatchServerIp : Grasscutter.getConfig().DispatchServerPublicIp) + "/gacha"; GachaInfo.Builder info = GachaInfo.newBuilder() .setGachaType(this.getGachaType()) diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 84b520fa8..b014e904d 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -104,14 +104,14 @@ public final class DispatchServer { .setName("os_usa") .setTitle(Grasscutter.getConfig().GameServerName) .setType("DEV_PUBLIC") - .setDispatchUrl("https://" + Grasscutter.getConfig().DispatchServerIp + ":" + getAddress().getPort() + "/query_cur_region") + .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().DispatchServerIp + ":" + getAddress().getPort() + "/query_cur_region") + .setDispatchUrl("https://" + (Grasscutter.getConfig().DispatchServerPublicIp.isEmpty() ? Grasscutter.getConfig().DispatchServerIp : Grasscutter.getConfig().DispatchServerPublicIp) + ":" + getAddress().getPort() + "/query_cur_region") .build(); QueryRegionListHttpRsp regionList = QueryRegionListHttpRsp.newBuilder() @@ -123,7 +123,7 @@ public final class DispatchServer { .build(); RegionInfo currentRegion = regionQuery.getRegionInfo().toBuilder() - .setIp(Grasscutter.getConfig().GameServerIp) + .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();