mirror of
https://gitlab.com/mangadex-pub/mangadex_at_home.git
synced 2024-01-19 02:48:37 +00:00
MR Feedback
This commit is contained in:
parent
d2949c6be2
commit
85db7f81c2
|
@ -30,8 +30,8 @@ dependencies {
|
|||
implementation group: "org.apache.commons", name: "commons-compress", version: "1.20"
|
||||
implementation group: "ch.qos.logback", name: "logback-classic", version: "1.3.0-alpha4"
|
||||
|
||||
compile 'io.micrometer:micrometer-registry-prometheus:1.6.2'
|
||||
compile 'com.maxmind.geoip2:geoip2:2.15.0'
|
||||
implementation group: "io.micrometer", name: "micrometer-registry-prometheus", version: "1.6.2"
|
||||
implementation group: "com.maxmind.geoip2", name: "geoip2", version: "2.15.0"
|
||||
|
||||
implementation group: "org.http4k", name: "http4k-core", version: "$http_4k_version"
|
||||
implementation group: "org.http4k", name: "http4k-format-jackson", version: "$http_4k_version"
|
||||
|
|
|
@ -30,7 +30,6 @@ import mdnet.cache.ImageStorage
|
|||
import mdnet.logging.info
|
||||
import mdnet.logging.warn
|
||||
import mdnet.settings.ClientSettings
|
||||
import org.http4k.server.Http4kServer
|
||||
import org.ktorm.database.Database
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
|
@ -168,7 +167,8 @@ class MangaDexClient(private val settingsFile: File, databaseFile: File, cacheFo
|
|||
storage.maxSize = (newSettings.maxCacheSizeInMebibytes * 1024 * 1024 * 0.8).toLong()
|
||||
|
||||
val restartServer = newSettings.serverSettings != settings.serverSettings ||
|
||||
newSettings.devSettings != settings.devSettings
|
||||
newSettings.devSettings != settings.devSettings ||
|
||||
newSettings.metricsSettings != settings.metricsSettings
|
||||
|
||||
if (restartServer) {
|
||||
stopImageServer()
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
Mangadex@Home
|
||||
Copyright (c) 2020, MangaDex Network
|
||||
This file is part of MangaDex@Home.
|
||||
|
||||
MangaDex@Home is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MangaDex@Home is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* ktlint-disable no-wildcard-imports */
|
||||
package mdnet.metrics
|
||||
|
||||
import com.maxmind.db.CHMCache
|
||||
|
@ -6,6 +25,7 @@ import io.micrometer.prometheus.PrometheusMeterRegistry
|
|||
import mdnet.logging.info
|
||||
import mdnet.logging.trace
|
||||
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.http4k.core.*
|
||||
import org.http4k.filter.gunzippedStream
|
||||
import org.slf4j.Logger
|
||||
|
@ -20,6 +40,11 @@ class GeoIpMetricsFilter(
|
|||
private val client: HttpHandler
|
||||
) : Filter {
|
||||
|
||||
companion object {
|
||||
const val GEOIP2_COUNTRY_URI_FORMAT: String =
|
||||
"https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=%s&suffix=tar.gz"
|
||||
}
|
||||
|
||||
private val LOGGER: Logger = LoggerFactory.getLogger(GeoIpMetricsFilter::class.java)
|
||||
|
||||
private lateinit var dbr: DatabaseReader
|
||||
|
@ -71,10 +96,10 @@ class GeoIpMetricsFilter(
|
|||
val databaseFileDir = Files.createTempDirectory("mangadex-geoip")
|
||||
val databaseFile = Files.createTempFile(databaseFileDir, "geoip2_country", ".mmdb")
|
||||
|
||||
val geoIpDatabaseUri = "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&license_key=%s&suffix=tar.gz".format(license)
|
||||
val geoIpDatabaseUri = GEOIP2_COUNTRY_URI_FORMAT.format(license)
|
||||
val response = client(Request(Method.GET, geoIpDatabaseUri))
|
||||
if (response.status != Status.OK) {
|
||||
throw IllegalStateException("Couldn't download GeoIP 2 databse (status code from upstream: ${response.status})")
|
||||
throw IllegalStateException("Couldn't download GeoIP 2 database (http status: ${response.status})")
|
||||
}
|
||||
|
||||
response.use {
|
||||
|
@ -86,7 +111,7 @@ class GeoIpMetricsFilter(
|
|||
}
|
||||
|
||||
// reads only the current entry to its end
|
||||
val dbBytes = archiveStream.readAllBytes()
|
||||
val dbBytes = IOUtils.toByteArray(archiveStream)
|
||||
Files.write(databaseFile, dbBytes)
|
||||
}
|
||||
|
||||
|
@ -95,5 +120,4 @@ class GeoIpMetricsFilter(
|
|||
.withCache(CHMCache())
|
||||
.build()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/*
|
||||
Mangadex@Home
|
||||
Copyright (c) 2020, MangaDex Network
|
||||
This file is part of MangaDex@Home.
|
||||
|
||||
MangaDex@Home is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MangaDex@Home is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this MangaDex@Home. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* ktlint-disable no-wildcard-imports */
|
||||
package mdnet.metrics
|
||||
|
||||
import org.http4k.core.HttpTransaction
|
||||
|
@ -15,5 +34,4 @@ class PostTransactionLabeler : HttpTransactionLabeler {
|
|||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -240,7 +240,6 @@ class ImageServer(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun String.isImageMimetype() = this.toLowerCase().startsWith("image/")
|
||||
|
|
|
@ -261,7 +261,6 @@ class TokenVerifierTest : FreeSpec() {
|
|||
}
|
||||
|
||||
"token" - {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue