Report proper hostname
This commit is contained in:
parent
cfc942f674
commit
307b28e13c
|
@ -17,7 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- [2020-06-28] Added `pasued` field in ServerSettings [@carbotaniuman].
|
||||
- [2020-06-28] Hopefully fixed connection leaks [@carbotaniuman].
|
||||
- [2020-07-02] Minor fixes and changes to data handling in web interface [@RedMatriz].
|
||||
- [2020-07-02] Renamed loaclstorage keys in web interface [@RedMatriz].
|
||||
- [2020-07-02] Renamed localstorage keys in web interface [@RedMatriz].
|
||||
- [2020-06-28] Actually report custom `client_hostname` [@carbotaniuman].
|
||||
|
||||
### Deprecated
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ private val LOGGER = LoggerFactory.getLogger("Application")
|
|||
|
||||
fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSettings: ClientSettings, statistics: AtomicReference<Statistics>, isHandled: AtomicBoolean): Http4kServer {
|
||||
val database = Database.connect("jdbc:sqlite:cache/data.db", "org.sqlite.JDBC")
|
||||
val imageServer = ImageServer(cache, statistics, serverSettings, database, isHandled)
|
||||
val imageServer = ImageServer(cache, statistics, serverSettings, database, clientSettings.clientHostname, isHandled)
|
||||
|
||||
return timeRequest()
|
||||
.then(catchAllHideDetails())
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.io.BufferedInputStream
|
|||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.net.InetAddress
|
||||
import java.security.MessageDigest
|
||||
import java.time.Clock
|
||||
import java.time.OffsetDateTime
|
||||
|
@ -66,7 +67,7 @@ import org.slf4j.LoggerFactory
|
|||
|
||||
private const val THREADS_TO_ALLOCATE = 262144 // 2**18
|
||||
|
||||
class ImageServer(private val cache: DiskLruCache, private val statistics: AtomicReference<Statistics>, private val serverSettings: ServerSettings, private val database: Database, private val handled: AtomicBoolean) {
|
||||
class ImageServer(private val cache: DiskLruCache, private val statistics: AtomicReference<Statistics>, private val serverSettings: ServerSettings, private val database: Database, private val clientHostname: String, private val handled: AtomicBoolean) {
|
||||
init {
|
||||
transaction(database) {
|
||||
SchemaUtils.create(ImageData)
|
||||
|
@ -81,6 +82,13 @@ class ImageServer(private val cache: DiskLruCache, private val statistics: Atomi
|
|||
.setConnectTimeout(3000)
|
||||
.setSocketTimeout(3000)
|
||||
.setConnectionRequestTimeout(3000)
|
||||
.setLocalAddress(
|
||||
if (clientHostname != "0.0.0.0") {
|
||||
InetAddress.getByName(clientHostname)
|
||||
} else {
|
||||
InetAddress.getLocalHost()
|
||||
}
|
||||
)
|
||||
.build())
|
||||
.setMaxConnTotal(THREADS_TO_ALLOCATE)
|
||||
.setMaxConnPerRoute(THREADS_TO_ALLOCATE)
|
||||
|
|
Loading…
Reference in a new issue