Merge branch 'master' into 'master'

Added configuration option for external port

See merge request mangadex-pub/mangadex_at_home!40
This commit is contained in:
carbotaniuman 2020-06-28 17:42:40 +00:00
commit c5d3208b9b
4 changed files with 13 additions and 1 deletions

2
.gitignore vendored
View file

@ -107,3 +107,5 @@ log/**
cache/**
dev
settings.json

View file

@ -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

View file

@ -60,7 +60,13 @@ class ServerHandler(private val settings: ClientSettings) {
private fun getPingParams(tlsCreatedAt: String? = null): Map<String, Any> =
mapOf<String, Any>(
"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<Map<String, Any>>().toLens()
private val SERVER_SETTINGS_LENS = Body.auto<ServerSettings>().toLens()
private const val SERVER_ADDRESS = "https://api.mangadex.network/"
//private const val SERVER_ADDRESS = "https://mangadex-test.net/"
}
}

View file

@ -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,