From 22b0840f990625d51152bd5f29073c5fc93e40a6 Mon Sep 17 00:00:00 2001 From: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> Date: Thu, 2 Jul 2020 11:06:32 -0500 Subject: [PATCH] Update gradle and spotless --- CHANGELOG.md | 1 + build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- src/main/kotlin/mdnet/base/Main.kt | 6 ++-- src/main/kotlin/mdnet/base/MangaDexClient.kt | 18 +++++----- src/main/kotlin/mdnet/base/ServerHandler.kt | 3 +- .../mdnet/base/netty/ApplicationNetty.kt | 18 +++++----- src/main/kotlin/mdnet/base/netty/Keys.kt | 34 +++++++++---------- .../kotlin/mdnet/base/server/Application.kt | 8 ++--- .../kotlin/mdnet/base/server/ImageServer.kt | 28 +++++++-------- .../mdnet/base/settings/ServerSettings.kt | 4 +-- 11 files changed, 62 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ab6322..80c8e45 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [2020-06-28] Added `client_external_port` setting [@wedge1001]. - [2020-06-29] Added rudimentary support of Referer checking to mitigate hotlinking by [@lflare]. - [2020-06-30] Added read and write timeouts to protect against some attacks [@carbotaniuman]. +- [2020-06-30] Added `dev_settings` to allow for easier development [@wedge1001]. ### Changed - [2020-06-28] Added `pasued` field in ServerSettings [@carbotaniuman]. diff --git a/build.gradle b/build.gradle index 5854580..bd9a865 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { id "org.jetbrains.kotlin.jvm" version "1.3.72" id "application" id "com.github.johnrengelman.shadow" version "5.2.0" - id "com.diffplug.gradle.spotless" version "3.18.0" + id "com.diffplug.gradle.spotless" version "4.4.0" id "dev.afanasev.sekret" version "0.0.3" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 104cef8..7fb2880 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Wed May 27 21:24:59 CDT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/src/main/kotlin/mdnet/base/Main.kt b/src/main/kotlin/mdnet/base/Main.kt index 3dccf17..6d56fb8 100644 --- a/src/main/kotlin/mdnet/base/Main.kt +++ b/src/main/kotlin/mdnet/base/Main.kt @@ -22,14 +22,14 @@ import ch.qos.logback.classic.LoggerContext import com.fasterxml.jackson.core.JsonProcessingException import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException import com.fasterxml.jackson.module.kotlin.readValue -import mdnet.base.Constants.JACKSON -import mdnet.base.settings.ClientSettings -import org.slf4j.LoggerFactory import java.io.FileReader import java.io.FileWriter import java.io.IOException import java.util.regex.Pattern import kotlin.system.exitProcess +import mdnet.base.Constants.JACKSON +import mdnet.base.settings.ClientSettings +import org.slf4j.LoggerFactory object Main { private val LOGGER = LoggerFactory.getLogger(Main::class.java) diff --git a/src/main/kotlin/mdnet/base/MangaDexClient.kt b/src/main/kotlin/mdnet/base/MangaDexClient.kt index 1836cfd..79d7a37 100644 --- a/src/main/kotlin/mdnet/base/MangaDexClient.kt +++ b/src/main/kotlin/mdnet/base/MangaDexClient.kt @@ -21,6 +21,15 @@ package mdnet.base import ch.qos.logback.classic.LoggerContext import com.fasterxml.jackson.module.kotlin.readValue +import java.io.File +import java.io.IOException +import java.time.Instant +import java.util.* +import java.util.concurrent.CountDownLatch +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference import mdnet.base.Constants.JACKSON import mdnet.base.Main.dieWithError import mdnet.base.data.Statistics @@ -32,15 +41,6 @@ import mdnet.cache.DiskLruCache import mdnet.cache.HeaderMismatchException import org.http4k.server.Http4kServer import org.slf4j.LoggerFactory -import java.io.File -import java.io.IOException -import java.time.Instant -import java.util.* -import java.util.concurrent.CountDownLatch -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicReference sealed class State // server is not running diff --git a/src/main/kotlin/mdnet/base/ServerHandler.kt b/src/main/kotlin/mdnet/base/ServerHandler.kt index 7bf823a..d8e283d 100644 --- a/src/main/kotlin/mdnet/base/ServerHandler.kt +++ b/src/main/kotlin/mdnet/base/ServerHandler.kt @@ -20,6 +20,7 @@ package mdnet.base import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.module.kotlin.KotlinModule +import mdnet.base.ServerHandlerJackson.auto import mdnet.base.settings.ClientSettings import mdnet.base.settings.ServerSettings import org.http4k.client.ApacheClient @@ -30,8 +31,6 @@ import org.http4k.format.ConfigurableJackson import org.http4k.format.asConfigurable import org.http4k.format.withStandardMappings import org.slf4j.LoggerFactory - -import mdnet.base.ServerHandlerJackson.auto object ServerHandlerJackson : ConfigurableJackson( KotlinModule() .asConfigurable() diff --git a/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt b/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt index 9808e62..47bcf54 100644 --- a/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt +++ b/src/main/kotlin/mdnet/base/netty/ApplicationNetty.kt @@ -32,15 +32,6 @@ import io.netty.handler.timeout.ReadTimeoutHandler import io.netty.handler.timeout.WriteTimeoutHandler import io.netty.handler.traffic.GlobalTrafficShapingHandler import io.netty.handler.traffic.TrafficCounter -import mdnet.base.Constants -import mdnet.base.data.Statistics -import mdnet.base.settings.ClientSettings -import mdnet.base.settings.TlsCert -import org.http4k.core.HttpHandler -import org.http4k.server.Http4kChannelHandler -import org.http4k.server.Http4kServer -import org.http4k.server.ServerConfig -import org.slf4j.LoggerFactory import java.io.ByteArrayInputStream import java.io.IOException import java.io.InputStream @@ -52,6 +43,15 @@ import java.security.cert.X509Certificate import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicReference import javax.net.ssl.SSLException +import mdnet.base.Constants +import mdnet.base.data.Statistics +import mdnet.base.settings.ClientSettings +import mdnet.base.settings.TlsCert +import org.http4k.core.HttpHandler +import org.http4k.server.Http4kChannelHandler +import org.http4k.server.Http4kServer +import org.http4k.server.ServerConfig +import org.slf4j.LoggerFactory private val LOGGER = LoggerFactory.getLogger("Application") diff --git a/src/main/kotlin/mdnet/base/netty/Keys.kt b/src/main/kotlin/mdnet/base/netty/Keys.kt index 6c76604..59a04f5 100644 --- a/src/main/kotlin/mdnet/base/netty/Keys.kt +++ b/src/main/kotlin/mdnet/base/netty/Keys.kt @@ -1,24 +1,24 @@ -//The code below is adapted from from https://github.com/Mastercard/client-encryption-java/blob/master/src/main/java/com/mastercard/developer/utils/EncryptionUtils.java +// The code below is adapted from from https://github.com/Mastercard/client-encryption-java/blob/master/src/main/java/com/mastercard/developer/utils/EncryptionUtils.java // -//Copyright (c) 2019 Mastercard +// Copyright (c) 2019 Mastercard // -//Permission is hereby granted, free of charge, to any person obtaining a copy -//of this software and associated documentation files (the "Software"), to deal -//in the Software without restriction, including without limitation the rights -//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -//copies of the Software, and to permit persons to whom the Software is -//furnished to do so, subject to the following conditions: +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // -//The above copyright notice and this permission notice shall be included in all -//copies or substantial portions of the Software. +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -//SOFTWARE. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. package mdnet.base.netty import java.io.ByteArrayOutputStream diff --git a/src/main/kotlin/mdnet/base/server/Application.kt b/src/main/kotlin/mdnet/base/server/Application.kt index 7f15e53..f0a88a5 100644 --- a/src/main/kotlin/mdnet/base/server/Application.kt +++ b/src/main/kotlin/mdnet/base/server/Application.kt @@ -19,10 +19,12 @@ along with this MangaDex@Home. If not, see . /* ktlint-disable no-wildcard-imports */ package mdnet.base.server -import mdnet.base.netty.Netty -import mdnet.base.settings.ServerSettings +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference import mdnet.base.data.Statistics +import mdnet.base.netty.Netty import mdnet.base.settings.ClientSettings +import mdnet.base.settings.ServerSettings import mdnet.cache.DiskLruCache import org.http4k.core.* import org.http4k.filter.ServerFilters @@ -32,8 +34,6 @@ import org.http4k.server.Http4kServer import org.http4k.server.asServer import org.jetbrains.exposed.sql.Database import org.slf4j.LoggerFactory -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicReference private val LOGGER = LoggerFactory.getLogger("Application") diff --git a/src/main/kotlin/mdnet/base/server/ImageServer.kt b/src/main/kotlin/mdnet/base/server/ImageServer.kt index aace2cd..1240a50 100644 --- a/src/main/kotlin/mdnet/base/server/ImageServer.kt +++ b/src/main/kotlin/mdnet/base/server/ImageServer.kt @@ -19,10 +19,23 @@ along with this MangaDex@Home. If not, see . /* ktlint-disable no-wildcard-imports */ package mdnet.base.server +import java.io.BufferedInputStream +import java.io.BufferedOutputStream +import java.io.File +import java.io.InputStream +import java.security.MessageDigest +import java.time.Clock +import java.util.concurrent.Executors +import java.util.concurrent.atomic.AtomicBoolean +import java.util.concurrent.atomic.AtomicReference +import javax.crypto.Cipher +import javax.crypto.CipherInputStream +import javax.crypto.CipherOutputStream +import javax.crypto.spec.SecretKeySpec import mdnet.base.Constants -import mdnet.base.data.Statistics import mdnet.base.data.ImageData import mdnet.base.data.ImageDatum +import mdnet.base.data.Statistics import mdnet.cache.CachingInputStream import mdnet.cache.DiskLruCache import org.apache.http.client.config.CookieSpecs @@ -38,19 +51,6 @@ import org.jetbrains.exposed.sql.Database import org.jetbrains.exposed.sql.SchemaUtils import org.jetbrains.exposed.sql.transactions.transaction import org.slf4j.LoggerFactory -import java.io.BufferedInputStream -import java.io.BufferedOutputStream -import java.io.File -import java.io.InputStream -import java.security.MessageDigest -import java.time.Clock -import java.util.concurrent.Executors -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicReference -import javax.crypto.Cipher -import javax.crypto.CipherInputStream -import javax.crypto.CipherOutputStream -import javax.crypto.spec.SecretKeySpec private const val THREADS_TO_ALLOCATE = 262144 // 2**18 diff --git a/src/main/kotlin/mdnet/base/settings/ServerSettings.kt b/src/main/kotlin/mdnet/base/settings/ServerSettings.kt index 1e7a720..81057bf 100644 --- a/src/main/kotlin/mdnet/base/settings/ServerSettings.kt +++ b/src/main/kotlin/mdnet/base/settings/ServerSettings.kt @@ -23,7 +23,7 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming import dev.afanasev.sekret.Secret @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) -data class ServerSettings ( +data class ServerSettings( val imageServer: String, val latestBuild: Int, val url: String, @@ -33,7 +33,7 @@ data class ServerSettings ( ) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy::class) -data class TlsCert ( +data class TlsCert( val createdAt: String, @field:Secret val privateKey: String, @field:Secret val certificate: String