diff --git a/proxy_config.py b/proxy_config.py index 5025a974e..07bac1a3a 100644 --- a/proxy_config.py +++ b/proxy_config.py @@ -1,4 +1,17 @@ +import os + # This can also be replaced with another IP address. USE_SSL = True -REMOTE_HOST = "127.0.0.1" -REMOTE_PORT = 443 \ No newline at end of file +REMOTE_HOST = "localhost" +REMOTE_PORT = 443 + +if os.getenv('MITM_REMOTE_HOST') != None: + REMOTE_HOST = os.getenv('MITM_REMOTE_HOST') +if os.getenv('MITM_REMOTE_PORT') != None: + REMOTE_PORT = int(os.getenv('MITM_REMOTE_PORT')) +if os.getenv('MITM_USE_SSL') != None: + USE_SSL = bool(os.getenv('MITM_USE_SSL')) + +print('MITM Remote Host: ' + REMOTE_HOST) +print('MITM Remote Port: ' + str(REMOTE_PORT)) +print('MITM Use SSL ' + str(USE_SSL)) diff --git a/src/main/java/emu/grasscutter/Grasscutter.java b/src/main/java/emu/grasscutter/Grasscutter.java index d05939c05..823633c4f 100644 --- a/src/main/java/emu/grasscutter/Grasscutter.java +++ b/src/main/java/emu/grasscutter/Grasscutter.java @@ -51,7 +51,7 @@ public final class Grasscutter { private static PluginManager pluginManager; public static final Reflections reflector = new Reflections("emu.grasscutter"); - + static { // Declare logback configuration. System.setProperty("logback.configurationFile", "src/main/resources/logback.xml"); @@ -66,7 +66,7 @@ public final class Grasscutter { Utils.startupCheck(); } - public static void main(String[] args) throws Exception { + public static void main(String[] args) throws Exception { Crypto.loadKeys(); // Load keys from buffers. // Parse arguments. @@ -93,7 +93,7 @@ public final class Grasscutter { ResourceLoader.loadAll(); ScriptLoader.init(); - // Database + // Initialize database. DatabaseManager.initialize(); // Create server instances. @@ -127,7 +127,7 @@ public final class Grasscutter { // Open console. startConsole(); - } + } /** * Server shutdown event. diff --git a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java index 1695e0208..7e4b1655e 100644 --- a/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java +++ b/src/main/java/emu/grasscutter/server/dispatch/DispatchServer.java @@ -334,7 +334,7 @@ public final class DispatchServer { return; } LoginResultJson responseData = new LoginResultJson(); - Grasscutter.getLogger().info(translate("messages.dispatch.account.login_token_attempt")); + Grasscutter.getLogger().info(translate("messages.dispatch.account.login_token_attempt", req.ip())); // Login Account account = DatabaseHelper.getAccountById(requestData.uid); diff --git a/src/main/java/emu/grasscutter/utils/Language.java b/src/main/java/emu/grasscutter/utils/Language.java index ec56b41d9..8acb05cd4 100644 --- a/src/main/java/emu/grasscutter/utils/Language.java +++ b/src/main/java/emu/grasscutter/utils/Language.java @@ -29,7 +29,13 @@ public final class Language { * @return A translated value with arguments substituted. */ public static String translate(String key, Object... args) { - return Grasscutter.getLanguage().get(key).formatted(args); + String translated = Grasscutter.getLanguage().get(key); + try { + return translated.formatted(args); + } catch (Exception exception) { + Grasscutter.getLogger().error("Failed to format string: " + key, exception); + return translated; + } } /**