diff --git a/.gitignore b/.gitignore index 643c7c1..00a266a 100644 --- a/.gitignore +++ b/.gitignore @@ -107,3 +107,5 @@ log/** cache/** dev + +settings.json \ No newline at end of file diff --git a/settings.sample.json b/settings.sample.json index f096550..4c29f8d 100755 --- a/settings.sample.json +++ b/settings.sample.json @@ -2,6 +2,8 @@ "client_secret": "nosenpaithisisoursecret", "client_hostname": "0.0.0.0", // "0.0.0.0" is the default and binds to everything "client_port": 443, // 443 is recommended if possible + "client_external_port": 0, //443 is recommended; This port will be send to mdah-backend. + //You need to forward this to the client_port in your router; This is optional "threads": 16, "graceful_shutdown_wait_seconds": 60, // Time from graceful shutdown start to force quit // This rounds down to 15-second increments diff --git a/src/main/kotlin/mdnet/base/ServerHandler.kt b/src/main/kotlin/mdnet/base/ServerHandler.kt index 7e132d0..a7f748e 100644 --- a/src/main/kotlin/mdnet/base/ServerHandler.kt +++ b/src/main/kotlin/mdnet/base/ServerHandler.kt @@ -60,7 +60,13 @@ class ServerHandler(private val settings: ClientSettings) { private fun getPingParams(tlsCreatedAt: String? = null): Map = mapOf( "secret" to settings.clientSecret, - "port" to settings.clientPort, + "port" to let { + if (settings.clientExternalPort != 0) { + settings.clientExternalPort + } else { + settings.clientPort + } + }, "disk_space" to settings.maxCacheSizeInMebibytes * 1024 * 1024, "network_speed" to settings.maxKilobitsPerSecond * 1000 / 8, "build_version" to Constants.CLIENT_BUILD @@ -107,5 +113,6 @@ class ServerHandler(private val settings: ClientSettings) { private val STRING_ANY_MAP_LENS = Body.auto>().toLens() private val SERVER_SETTINGS_LENS = Body.auto().toLens() private const val SERVER_ADDRESS = "https://api.mangadex.network/" + //private const val SERVER_ADDRESS = "https://mangadex-test.net/" } } diff --git a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt index 771dc6c..9fe9d11 100644 --- a/src/main/kotlin/mdnet/base/settings/ClientSettings.kt +++ b/src/main/kotlin/mdnet/base/settings/ClientSettings.kt @@ -30,6 +30,7 @@ data class ClientSettings( val maxKilobitsPerSecond: Long = 0, val clientHostname: String = "0.0.0.0", val clientPort: Int = 443, + val clientExternalPort: Int = 0, @field:Secret val clientSecret: String = "PASTE-YOUR-SECRET-HERE", val threads: Int = 4, val gracefulShutdownWaitSeconds: Int = 60,