diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d31087..7a696a5 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [2020-07-29] Fixed stupid libsodium bugs [@carbotaniuman]. - [2020-07-29] Fixed issues from the Great Cache Propagation [@carbotaniuman]. +- [2020-08-03] Fix `client_hostname` stuff [@carbotaniuman]. ### Security diff --git a/src/main/kotlin/mdnet/base/ServerHandler.kt b/src/main/kotlin/mdnet/base/ServerHandler.kt index ea540bf..13ac094 100644 --- a/src/main/kotlin/mdnet/base/ServerHandler.kt +++ b/src/main/kotlin/mdnet/base/ServerHandler.kt @@ -20,9 +20,12 @@ package mdnet.base import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.module.kotlin.KotlinModule +import java.net.InetAddress import mdnet.base.ServerHandlerJackson.auto import mdnet.base.settings.ClientSettings import mdnet.base.settings.ServerSettings +import org.apache.http.client.config.RequestConfig +import org.apache.http.impl.client.HttpClients import org.http4k.client.ApacheClient import org.http4k.core.Body import org.http4k.core.Method @@ -41,7 +44,16 @@ object ServerHandlerJackson : ConfigurableJackson( ) class ServerHandler(private var settings: ClientSettings) { - private val client = ApacheClient() + private val client = ApacheClient(client = HttpClients.custom() + .setDefaultRequestConfig( + RequestConfig.custom() + .apply { + if (settings.clientHostname != "0.0.0.0") { + setLocalAddress(InetAddress.getByName(settings.clientHostname)) + } + } + .build()) + .build()) fun logoutFromControl(): Boolean { LOGGER.info { "Disconnecting from the control server" } diff --git a/src/main/kotlin/mdnet/base/server/Application.kt b/src/main/kotlin/mdnet/base/server/Application.kt index 456128f..523aac7 100644 --- a/src/main/kotlin/mdnet/base/server/Application.kt +++ b/src/main/kotlin/mdnet/base/server/Application.kt @@ -19,7 +19,6 @@ along with this MangaDex@Home. If not, see . /* ktlint-disable no-wildcard-imports */ package mdnet.base.server -import java.net.InetAddress import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference import mdnet.base.data.Statistics @@ -53,11 +52,6 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting .setConnectTimeout(3000) .setSocketTimeout(3000) .setConnectionRequestTimeout(3000) - .apply { - if (clientSettings.clientHostname != "0.0.0.0") { - setLocalAddress(InetAddress.getByName(clientSettings.clientHostname)) - } - } .build()) .setMaxConnTotal(3000) .setMaxConnPerRoute(3000) diff --git a/src/main/kotlin/mdnet/base/server/ImageServer.kt b/src/main/kotlin/mdnet/base/server/ImageServer.kt index 236dea1..a2f7da0 100644 --- a/src/main/kotlin/mdnet/base/server/ImageServer.kt +++ b/src/main/kotlin/mdnet/base/server/ImageServer.kt @@ -69,8 +69,10 @@ class ImageServer( private val client: HttpHandler ) { init { - transaction(database) { - SchemaUtils.create(ImageData) + synchronized(database) { + transaction(database) { + SchemaUtils.create(ImageData) + } } } private val executor = Executors.newCachedThreadPool()