mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
update check fixes
This commit is contained in:
parent
482d337fcb
commit
a04835fb1b
@ -19,7 +19,7 @@ import de.bixilon.kutil.string.StringUtil.formatPlaceholder
|
|||||||
import de.bixilon.kutil.url.URLUtil.toURL
|
import de.bixilon.kutil.url.URLUtil.toURL
|
||||||
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
import de.bixilon.minosoft.config.profile.profiles.other.OtherProfileManager
|
||||||
import de.bixilon.minosoft.properties.MinosoftProperties
|
import de.bixilon.minosoft.properties.MinosoftProperties
|
||||||
import de.bixilon.minosoft.util.http.HTTP2.getJson
|
import de.bixilon.minosoft.util.http.HTTP2.get
|
||||||
import de.bixilon.minosoft.util.http.exceptions.HTTPException
|
import de.bixilon.minosoft.util.http.exceptions.HTTPException
|
||||||
import de.bixilon.minosoft.util.json.Jackson
|
import de.bixilon.minosoft.util.json.Jackson
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
@ -40,12 +40,11 @@ object MinosoftUpdater {
|
|||||||
|
|
||||||
fun check(): MinosoftUpdate? {
|
fun check(): MinosoftUpdate? {
|
||||||
val profile = OtherProfileManager.selected.updater
|
val profile = OtherProfileManager.selected.updater
|
||||||
return check(profile.url.toURL(), profile.channel)
|
return check(profile.url, profile.channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun check(url: URL, channel: String): MinosoftUpdate? {
|
fun check(url: String, channel: String): MinosoftUpdate? {
|
||||||
validateURL(url)
|
|
||||||
|
|
||||||
val commit = MinosoftProperties.git?.commit ?: ""
|
val commit = MinosoftProperties.git?.commit ?: ""
|
||||||
val version = MinosoftProperties.general.name
|
val version = MinosoftProperties.general.name
|
||||||
@ -53,26 +52,28 @@ object MinosoftUpdater {
|
|||||||
val os = PlatformInfo.OS
|
val os = PlatformInfo.OS
|
||||||
val arch = PlatformInfo.ARCHITECTURE
|
val arch = PlatformInfo.ARCHITECTURE
|
||||||
|
|
||||||
val request = url.toString().formatPlaceholder(
|
val request = url.formatPlaceholder(
|
||||||
"\${COMMIT}" to commit,
|
"COMMIT" to commit,
|
||||||
"\${VERSION}" to version,
|
"VERSION" to version,
|
||||||
"\${STABLE}" to stable,
|
"STABLE" to stable,
|
||||||
"\${OS}" to os,
|
"OS" to os.name.lowercase(),
|
||||||
"\${ARCH}" to arch,
|
"ARCH" to arch.name.lowercase(),
|
||||||
"\${CHANNEL}" to channel,
|
"CHANNEL" to channel.lowercase(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
validateURL(request.toURL())
|
||||||
val update = request(request)
|
val update = request(request)
|
||||||
this.update = update
|
this.update = update
|
||||||
return update
|
return update
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun request(url: String): MinosoftUpdate? {
|
private fun request(url: String): MinosoftUpdate? {
|
||||||
val response = url.getJson()
|
val response = url.get({ it })
|
||||||
|
|
||||||
return when (response.statusCode) {
|
return when (response.statusCode) {
|
||||||
204 -> null
|
204 -> null
|
||||||
200 -> Jackson.MAPPER.convertValue(response.body, MinosoftUpdate::class.java)
|
200 -> Jackson.MAPPER.readValue(response.body, MinosoftUpdate::class.java)
|
||||||
else -> throw HTTPException(response.statusCode, response.body.toString())
|
else -> throw HTTPException(response.statusCode, response.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,4 +17,4 @@ import de.bixilon.minosoft.data.registries.identified.Namespaces.minosoft
|
|||||||
import de.bixilon.minosoft.util.signature.SignatureSigner
|
import de.bixilon.minosoft.util.signature.SignatureSigner
|
||||||
|
|
||||||
|
|
||||||
object UpdateKey : SignatureSigner(minosoft("updater/release.pub"), "SHA512withRSA")
|
object UpdateKey : SignatureSigner(minosoft("updater/release.der"), "SHA512withRSA")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
* Copyright (C) 2020-2023 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program 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.
|
* This program 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.
|
||||||
*
|
*
|
||||||
@ -74,13 +74,14 @@ object HTTP2 {
|
|||||||
|
|
||||||
fun <Response> String.get(bodyBuilder: (String) -> Response, headers: Map<String, Any> = emptyMap()): HTTPResponse<Response> {
|
fun <Response> String.get(bodyBuilder: (String) -> Response, headers: Map<String, Any> = emptyMap()): HTTPResponse<Response> {
|
||||||
val client = HttpClient.newHttpClient()
|
val client = HttpClient.newHttpClient()
|
||||||
val request = HttpRequest.newBuilder()
|
var request = HttpRequest.newBuilder()
|
||||||
.uri(URI.create(this))
|
.uri(URI.create(this))
|
||||||
.GET()
|
.GET()
|
||||||
.headers(*headers.headers())
|
if (headers.isNotEmpty()) {
|
||||||
.build()
|
request = request.headers(*headers.headers())
|
||||||
|
}
|
||||||
|
|
||||||
val response = client.send(request, HttpResponse.BodyHandlers.ofString())
|
val response = client.send(request.build(), HttpResponse.BodyHandlers.ofString())
|
||||||
return HTTPResponse(response.statusCode(), bodyBuilder(response.body()))
|
return HTTPResponse(response.statusCode(), bodyBuilder(response.body()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
src/main/resources/assets/minosoft/updater/release.der
Normal file
BIN
src/main/resources/assets/minosoft/updater/release.der
Normal file
Binary file not shown.
@ -1,14 +0,0 @@
|
|||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEApoG/cXO1wyfitUwf55fs
|
|
||||||
8ch8JxOmb7RW7YQWGVJ13StZZdsaBPmYNsHkQWwL9G45U4QIEwnlDLpDWPe90pB2
|
|
||||||
7sf41LHq81PygtxdnByR04fgnIwXYQA2G/A1e7+4CrlyenUCr14F9zjoyVqbUovz
|
|
||||||
Tf3ibHkJ3DLDSk612tEadJ6LJvc77W4di1GO6V0Kes1WvB1XIM2QhKV1Vyy5QsIf
|
|
||||||
wpY9RQ4eN3c93YdIhHXElkkdeSAT8csXYiD8ncnt0sDIdrlA5rqDn0wJbkM/tGNP
|
|
||||||
f7Zbr91RoWZjNCRDCgCDY1Nbs2ZgTL/z2syHoA5AXMzisRGzqCJt8iHSZ/pRlqP6
|
|
||||||
CWN6wQcSbTNUWpF43I0CkWakM9a1zUgcBkuLEG8yYL/zKFmYo2x3rdjaTyWCQyOO
|
|
||||||
SWkc4NBVgfwtlgNBrsB7zO+IdIEJwW+Jp5a7yR72AsFjcU5xcz/p9QmNhvWqAFCD
|
|
||||||
fXrTNHFtr11T91sKdgG2B6E2TbYlyEsKR4BmQfJn7qemlJrIFkX/H3k8wygbnHWg
|
|
||||||
cHPGcTVAMVxb9rk6M+BAkglG4nS8ldz/ZC/ScaWczwvNPsn0tbkgzql6BOi7jPc0
|
|
||||||
WO33JN/QxqO00xEg/O5NRXpzSIh3ehHnAQBV1KmxnP1U0bY277F+pwaYXRz5s/iR
|
|
||||||
KGX3gNbcTlQEfFJe3zKeEuUCAwEAAQ==
|
|
||||||
-----END PUBLIC KEY-----
|
|
Loading…
x
Reference in New Issue
Block a user