2020-06-22 17:02:36 +00:00
|
|
|
/*
|
|
|
|
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/>.
|
2021-01-25 02:25:49 +00:00
|
|
|
*/
|
2021-01-24 04:55:11 +00:00
|
|
|
package mdnet.settings
|
2020-06-19 20:16:24 +00:00
|
|
|
|
2021-01-24 04:55:11 +00:00
|
|
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies
|
2020-06-19 20:16:24 +00:00
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonNaming
|
2021-07-06 17:12:37 +00:00
|
|
|
import net.afanasev.sekret.Secret
|
2021-01-24 04:55:11 +00:00
|
|
|
import org.http4k.core.Uri
|
2020-06-19 20:16:24 +00:00
|
|
|
|
2021-01-28 13:50:13 +00:00
|
|
|
sealed class PingResult
|
|
|
|
|
|
|
|
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
|
|
|
|
data class PingFailure(
|
|
|
|
val status: Int,
|
|
|
|
val error: String,
|
|
|
|
) : PingResult()
|
|
|
|
|
2021-01-24 04:55:11 +00:00
|
|
|
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
|
2020-08-11 16:47:04 +00:00
|
|
|
data class RemoteSettings(
|
2021-01-24 04:55:11 +00:00
|
|
|
val imageServer: Uri,
|
2020-06-19 20:16:24 +00:00
|
|
|
val latestBuild: Int,
|
2021-01-24 04:55:11 +00:00
|
|
|
val url: Uri,
|
2021-05-21 15:23:49 +00:00
|
|
|
val clientId: String,
|
2020-08-05 15:20:29 +00:00
|
|
|
@field:Secret val tokenKey: ByteArray,
|
2020-06-19 20:16:24 +00:00
|
|
|
val compromised: Boolean,
|
2020-06-30 19:10:59 +00:00
|
|
|
val paused: Boolean,
|
2021-01-31 22:47:39 +00:00
|
|
|
val disableTokens: Boolean = false,
|
2020-06-19 20:16:24 +00:00
|
|
|
val tls: TlsCert?
|
2021-01-28 13:50:13 +00:00
|
|
|
) : PingResult() {
|
2020-07-02 21:24:12 +00:00
|
|
|
override fun equals(other: Any?): Boolean {
|
|
|
|
if (this === other) return true
|
|
|
|
if (javaClass != other?.javaClass) return false
|
|
|
|
|
2020-08-11 16:47:04 +00:00
|
|
|
other as RemoteSettings
|
2020-07-02 21:24:12 +00:00
|
|
|
|
|
|
|
if (imageServer != other.imageServer) return false
|
|
|
|
if (latestBuild != other.latestBuild) return false
|
|
|
|
if (url != other.url) return false
|
2021-05-21 15:23:49 +00:00
|
|
|
if (clientId != other.clientId) return false
|
2020-07-02 21:50:50 +00:00
|
|
|
if (!tokenKey.contentEquals(other.tokenKey)) return false
|
2020-07-02 21:24:12 +00:00
|
|
|
if (compromised != other.compromised) return false
|
|
|
|
if (paused != other.paused) return false
|
2021-01-31 22:47:39 +00:00
|
|
|
if (disableTokens != other.disableTokens) return false
|
2020-07-02 21:24:12 +00:00
|
|
|
if (tls != other.tls) return false
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun hashCode(): Int {
|
|
|
|
var result = imageServer.hashCode()
|
|
|
|
result = 31 * result + latestBuild
|
|
|
|
result = 31 * result + url.hashCode()
|
2021-05-21 15:23:49 +00:00
|
|
|
result = 31 * result + clientId.hashCode()
|
2020-07-02 21:50:50 +00:00
|
|
|
result = 31 * result + tokenKey.contentHashCode()
|
2020-07-02 21:24:12 +00:00
|
|
|
result = 31 * result + compromised.hashCode()
|
|
|
|
result = 31 * result + paused.hashCode()
|
2021-01-31 22:47:39 +00:00
|
|
|
result = 31 * result + disableTokens.hashCode()
|
2020-07-02 21:24:12 +00:00
|
|
|
result = 31 * result + (tls?.hashCode() ?: 0)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
}
|
2020-06-19 20:16:24 +00:00
|
|
|
|
2021-01-24 04:55:11 +00:00
|
|
|
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy::class)
|
2020-07-02 16:06:32 +00:00
|
|
|
data class TlsCert(
|
2020-06-19 20:16:24 +00:00
|
|
|
val createdAt: String,
|
|
|
|
@field:Secret val privateKey: String,
|
|
|
|
@field:Secret val certificate: String
|
|
|
|
)
|