diff --git a/build.gradle b/build.gradle index c7cba4b..5733c71 100644 --- a/build.gradle +++ b/build.gradle @@ -30,8 +30,6 @@ configurations { dependencies { implementation "org.jetbrains.kotlin:kotlin-reflect" - compileOnly group: "net.afanasev", name: "sekret-annotation", version: "0.1.1-RC3" - implementation group: "commons-io", name: "commons-io", version: "2.11.0" implementation group: "org.apache.commons", name: "commons-compress", version: "1.22" implementation group: "ch.qos.logback", name: "logback-classic", version: "1.3.6" diff --git a/src/main/kotlin/mdnet/cache/ImageStorage.kt b/src/main/kotlin/mdnet/cache/ImageStorage.kt index 3abab0c..51823aa 100644 --- a/src/main/kotlin/mdnet/cache/ImageStorage.kt +++ b/src/main/kotlin/mdnet/cache/ImageStorage.kt @@ -95,9 +95,14 @@ class ImageStorage( try { val toUpdate = HashSet() queue.drainTo(toUpdate) - val now = Instant.now() - LOGGER.info { "Updating LRU times for ${toUpdate.size} entries" } + if (toUpdate.isEmpty()) { + LOGGER.info { "Updating LRU times for ${toUpdate.size} entries" } + } else { + LOGGER.info { "Skipping empty LRU update" } + } + + val now = Instant.now() if (databaseLock.tryLock(500, TimeUnit.MILLISECONDS)) { try { diff --git a/src/main/kotlin/mdnet/settings/ClientSettings.kt b/src/main/kotlin/mdnet/settings/ClientSettings.kt index 34d162e..7d13860 100644 --- a/src/main/kotlin/mdnet/settings/ClientSettings.kt +++ b/src/main/kotlin/mdnet/settings/ClientSettings.kt @@ -20,7 +20,6 @@ package mdnet.settings import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming -import net.afanasev.sekret.Secret @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class ClientSettings( @@ -33,7 +32,7 @@ data class ClientSettings( @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class ServerSettings( - @field:Secret val secret: String, + val secret: String, val externalPort: Int = 0, val gracefulShutdownWaitSeconds: Int = 60, val hostname: String = "0.0.0.0", @@ -44,7 +43,11 @@ data class ServerSettings( val port: Int = 443, val threads: Int = 0, val enableProxyProtocol: Boolean = false, -) +) { + override fun toString(): String { + return "ServerSettings(secret=, externalPort=$externalPort, gracefulShutdownWaitSeconds=$gracefulShutdownWaitSeconds, hostname='$hostname', maxKilobitsPerSecond=$maxKilobitsPerSecond, externalMaxKilobitsPerSecond=$externalMaxKilobitsPerSecond, maxMebibytesPerHour=$maxMebibytesPerHour, externalIp=$externalIp, port=$port, threads=$threads, enableProxyProtocol=$enableProxyProtocol)" + } +} @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class DevSettings( @@ -57,5 +60,9 @@ data class DevSettings( @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class MetricsSettings( val enableGeoip: Boolean = false, - @field:Secret val geoipLicenseKey: String = "none" -) + val geoipLicenseKey: String = "none" +) { + override fun toString(): String { + return "MetricsSettings(enableGeoip=$enableGeoip, geoipLicenseKey=)" + } +} diff --git a/src/main/kotlin/mdnet/settings/PingResult.kt b/src/main/kotlin/mdnet/settings/PingResult.kt index 1ccd86f..eb5409d 100644 --- a/src/main/kotlin/mdnet/settings/PingResult.kt +++ b/src/main/kotlin/mdnet/settings/PingResult.kt @@ -20,7 +20,6 @@ package mdnet.settings import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming -import net.afanasev.sekret.Secret import org.http4k.core.Uri sealed class PingResult @@ -37,12 +36,13 @@ data class RemoteSettings( val latestBuild: Int, val url: Uri, val clientId: String, - @field:Secret val tokenKey: ByteArray, + val tokenKey: ByteArray, val compromised: Boolean, val paused: Boolean, val disableTokens: Boolean = false, val tls: TlsCert? ) : PingResult() { + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false @@ -74,11 +74,19 @@ data class RemoteSettings( result = 31 * result + (tls?.hashCode() ?: 0) return result } + + override fun toString(): String { + return "RemoteSettings(imageServer=$imageServer, latestBuild=$latestBuild, url=$url, clientId='$clientId', tokenKey=, compromised=$compromised, paused=$paused, disableTokens=$disableTokens, tls=$tls)" + } } @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class TlsCert( val createdAt: String, - @field:Secret val privateKey: String, - @field:Secret val certificate: String -) + val privateKey: String, + val certificate: String +) { + override fun toString(): String { + return "TlsCert(createdAt='$createdAt', privateKey=, certificate=)" + } +} diff --git a/src/main/kotlin/mdnet/settings/SettingsRequest.kt b/src/main/kotlin/mdnet/settings/SettingsRequest.kt index 974ec28..22a09e2 100644 --- a/src/main/kotlin/mdnet/settings/SettingsRequest.kt +++ b/src/main/kotlin/mdnet/settings/SettingsRequest.kt @@ -20,20 +20,27 @@ package mdnet.settings import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming -import net.afanasev.sekret.Secret @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class SettingsRequest( - @field:Secret val secret: String, + val secret: String, val ipAddress: String?, val port: Int, val diskSpace: Long, val networkSpeed: Long, val buildVersion: Int, val tlsCreatedAt: String?, -) +) { + override fun toString(): String { + return "SettingsRequest(secret=, ipAddress=$ipAddress, port=$port, diskSpace=$diskSpace, networkSpeed=$networkSpeed, buildVersion=$buildVersion, tlsCreatedAt=$tlsCreatedAt)" + } +} @JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class) data class LogoutRequest( - @field:Secret val secret: String, -) + val secret: String, +) { + override fun toString(): String { + return "LogoutRequest(secret=)" + } +}