diff --git a/gui/proxy-tool/src/main/kotlin/net/rsprox/gui/ProxyToolGui.kt b/gui/proxy-tool/src/main/kotlin/net/rsprox/gui/ProxyToolGui.kt index 0e23cefd..b20243ba 100644 --- a/gui/proxy-tool/src/main/kotlin/net/rsprox/gui/ProxyToolGui.kt +++ b/gui/proxy-tool/src/main/kotlin/net/rsprox/gui/ProxyToolGui.kt @@ -6,13 +6,26 @@ import javax.swing.SwingUtilities import javax.swing.UIManager public fun main(args: Array) { + val rspsJavConfigUrl = System.getenv("RSPS_JAVCONFIG_URL") + val rspsModulus = System.getenv("RSPS_RSA") + + when { + rspsModulus == null && rspsJavConfigUrl != null -> throw IllegalArgumentException( + "Missing ENV variable: RSPS_RSA", + ) + + rspsModulus != null && rspsJavConfigUrl == null -> throw IllegalArgumentException( + "Missing ENV variable: RSPS_JAVCONFIG_URL", + ) + } + if (args.isNotEmpty()) { System.setProperty("net.rsprox.gui.args", args.joinToString("|")) } Locale.setDefault(Locale.US) SplashScreen.init() SplashScreen.stage(0.0, "Preparing", "Setting up environment") - App.service.start { percentage, actionText, subActionText, progressText -> + App.service.start(rspsJavConfigUrl, rspsModulus) { percentage, actionText, subActionText, progressText -> SplashScreen.stage(percentage, actionText, subActionText, progressText) } SplashScreen.stop() diff --git a/proxy/src/main/kotlin/net/rsprox/proxy/ProxyService.kt b/proxy/src/main/kotlin/net/rsprox/proxy/ProxyService.kt index d6e6afcd..4123b4c8 100644 --- a/proxy/src/main/kotlin/net/rsprox/proxy/ProxyService.kt +++ b/proxy/src/main/kotlin/net/rsprox/proxy/ProxyService.kt @@ -92,8 +92,14 @@ public class ProxyService( private val connections: ProxyConnectionContainer = ProxyConnectionContainer() private lateinit var credentials: BinaryCredentialsStore private val gamePackProvider: GamePackProvider = GamePackProvider() + private var rspsModulus: String? = null - public fun start(progressCallback: ProgressCallback) { + public fun start( + rspsJavConfigUrl: String?, + rspsModulus: String?, + progressCallback: ProgressCallback, + ) { + this.rspsModulus = rspsModulus logger.info { "Starting proxy service" } progressCallback.update(0.05, "Proxy", "Creating directories") createConfigurationDirectories(CONFIGURATION_PATH) @@ -121,7 +127,7 @@ public class ProxyService( this.availablePort = properties.getProperty(PROXY_PORT_MIN) this.bootstrapFactory = BootstrapFactory(allocator, properties) progressCallback.update(0.35, "Proxy", "Loading jav config") - val javConfig = loadJavConfig() + val javConfig = loadJavConfig(rspsJavConfigUrl) progressCallback.update(0.40, "Proxy", "Loading world list") this.worldListProvider = loadWorldListProvider(javConfig.getWorldListUrl()) progressCallback.update(0.50, "Proxy", "Replacing codebase") @@ -466,7 +472,7 @@ public class ProxyService( ClientType.Native, os, port, - BigInteger(result.oldModulus, 16), + BigInteger(rspsModulus ?: result.oldModulus, 16), ), ) ClientTypeDictionary[port] = "Native (${os.shortName})" @@ -524,7 +530,7 @@ public class ProxyService( ClientType.RuneLite, operatingSystem, port, - BigInteger(oldModulus, 16), + BigInteger(rspsModulus ?: oldModulus, 16), ), ) socket.close() @@ -688,6 +694,15 @@ public class ProxyService( } } + private fun loadJavConfig(customUrl: String?): JavConfig { + val url = customUrl ?: "http://oldschool.runescape.com/jav_config.ws" + return runCatching("Failed to load jav_config.ws from $url") { + val config = JavConfig(URL(url)) + logger.debug { "Jav config loaded from $url" } + config + } + } + private fun loadWorldListProvider(url: String): WorldListProvider { return runCatching("Failed to instantiate world list provider") { val provider = @@ -790,15 +805,6 @@ public class ProxyService( private val logger = InlineLogger() private val PROPERTIES_FILE = CONFIGURATION_PATH.resolve("proxy.properties") - private fun loadJavConfig(): JavConfig { - val url = "http://oldschool.runescape.com/jav_config.ws" - return runCatching("Failed to load jav_config.ws from $url") { - val config = JavConfig(URL(url)) - logger.debug { "Jav config loaded from $url" } - config - } - } - private inline fun runCatching( errorMessage: String, block: () -> T, diff --git a/proxy/src/main/kotlin/net/rsprox/proxy/binary/BinaryBlob.kt b/proxy/src/main/kotlin/net/rsprox/proxy/binary/BinaryBlob.kt index 6bd4b1f2..a5c05022 100644 --- a/proxy/src/main/kotlin/net/rsprox/proxy/binary/BinaryBlob.kt +++ b/proxy/src/main/kotlin/net/rsprox/proxy/binary/BinaryBlob.kt @@ -188,10 +188,10 @@ public data class BinaryBlob( header.revision, header.js5MasterIndex, ) - val world = header.worldId + val info = LiveConnectionInfo( - "oldschool${world - 300}.runescape.com", + header.worldHost, PORT, header.revision, key,