mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-01-23 21:52:35 +01:00
update deps
This commit is contained in:
parent
72f8f00a57
commit
df33750a40
@ -57,14 +57,14 @@ dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
implementation(kotlin("reflect"))
|
||||
|
||||
val vvVer = "4.3.0-22w14a-SNAPSHOT"
|
||||
val vbVer = "4.3.0-22w14a-SNAPSHOT"
|
||||
val vrVer = "ae62eba"
|
||||
val vvVer = "4.3.0-22w15a-SNAPSHOT"
|
||||
val vbVer = "4.3.0-22w15a-SNAPSHOT"
|
||||
val vrVer = "daa5e21"
|
||||
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
|
||||
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
|
||||
implementation("com.github.ViaVersion.ViaRewind:viarewind-all:$vrVer") { isTransitive = false }
|
||||
|
||||
implementation("io.netty:netty-all:4.1.75.Final")
|
||||
implementation("io.netty:netty-all:4.1.76.Final")
|
||||
implementation("io.netty:netty-tcnative-boringssl-static:2.0.51.Final")
|
||||
implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.13.Final:linux-x86_64")
|
||||
|
||||
@ -84,10 +84,10 @@ dependencies {
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("org.slf4j:slf4j-api:$slf4jVer")
|
||||
|
||||
val ktorVersion = "2.0.0-beta-1"
|
||||
implementation("io.ktor:ktor-network-tls-certificates:$ktorVersion")
|
||||
val ktorVersion = "2.0.0"
|
||||
implementation("io.ktor:ktor-network-tls-certificates-jvm:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-websockets:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-netty:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-caching-headers:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-call-logging:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-compression:$ktorVersion")
|
||||
@ -96,10 +96,10 @@ dependencies {
|
||||
implementation("io.ktor:ktor-server-forwarded-header:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-partial-content:$ktorVersion")
|
||||
implementation("io.ktor:ktor-serialization-gson:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-java:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-java-jvm:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
|
||||
implementation("io.ktor:ktor-client-logging-jvm:$ktorVersion")
|
||||
testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")
|
||||
testImplementation("io.ktor:ktor-server-test-host-jvm:$ktorVersion")
|
||||
|
||||
implementation("com.auth0:java-jwt:3.19.1")
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntLinkedOpenHashSet;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.IntSortedSet;
|
||||
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||
import de.gerrygames.viarewind.sponge.VersionInfo;
|
||||
import de.gerrygames.viarewind.velocity.VersionInfo;
|
||||
|
||||
public class AspirinInjector implements ViaInjector {
|
||||
@Override
|
||||
|
@ -13,9 +13,10 @@ import com.viaversion.viaversion.api.Via
|
||||
import com.viaversion.viaversion.api.protocol.packet.State
|
||||
import com.viaversion.viaversion.update.Version
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.engine.java.*
|
||||
import io.ktor.client.plugins.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.network.tls.certificates.*
|
||||
import io.ktor.serialization.gson.*
|
||||
|
@ -10,6 +10,7 @@ import com.viaversion.aas.util.StacklessException
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
|
||||
import com.viaversion.viaversion.api.type.Type
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.server.netty.*
|
||||
import io.netty.buffer.ByteBuf
|
||||
|
@ -1,19 +1,26 @@
|
||||
package com.viaversion.aas.web
|
||||
|
||||
import io.ktor.http.*
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.serialization.gson.*
|
||||
import io.ktor.server.http.content.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.*
|
||||
import io.ktor.server.plugins.cachingheaders.*
|
||||
import io.ktor.server.plugins.callloging.*
|
||||
import io.ktor.server.plugins.compression.*
|
||||
import io.ktor.server.plugins.conditionalheaders.*
|
||||
import io.ktor.server.plugins.defaultheaders.*
|
||||
import io.ktor.server.plugins.forwardedheaders.*
|
||||
import io.ktor.server.plugins.partialcontent.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
import io.ktor.server.websocket.*
|
||||
import io.ktor.util.*
|
||||
import io.ktor.websocket.*
|
||||
import kotlinx.coroutines.channels.ClosedReceiveChannelException
|
||||
import kotlinx.coroutines.channels.consumeEach
|
||||
import org.slf4j.event.Level
|
||||
import java.io.File
|
||||
import java.nio.channels.ClosedChannelException
|
||||
import java.nio.file.Path
|
||||
import java.time.Duration
|
||||
|
||||
@ -22,8 +29,8 @@ class ViaWebApp(val viaWebServer: WebServer) {
|
||||
install(DefaultHeaders)
|
||||
install(ConditionalHeaders)
|
||||
install(CachingHeaders) {
|
||||
options {
|
||||
CachingOptions(CacheControl.MaxAge(600, visibility = CacheControl.Visibility.Public))
|
||||
options { _, _ ->
|
||||
io.ktor.http.content.CachingOptions(CacheControl.MaxAge(600, visibility = CacheControl.Visibility.Public))
|
||||
}
|
||||
}
|
||||
install(CallLogging) {
|
||||
@ -37,9 +44,10 @@ class ViaWebApp(val viaWebServer: WebServer) {
|
||||
maxFrameSize = Short.MAX_VALUE.toLong()
|
||||
pingPeriod = Duration.ofSeconds(20)
|
||||
timeout = Duration.ofSeconds(15)
|
||||
contentConverter = GsonWebsocketContentConverter()
|
||||
}
|
||||
install(XForwardedHeaderSupport)
|
||||
install(ForwardedHeaderSupport)
|
||||
install(XForwardedHeaders)
|
||||
install(ForwardedHeaders)
|
||||
// i think we aren't vulnerable to breach, dynamic things are websockets
|
||||
// https://ktor.io/docs/compression.html#security
|
||||
install(Compression)
|
||||
@ -84,8 +92,8 @@ class ViaWebApp(val viaWebServer: WebServer) {
|
||||
viaWebServer.onMessage(this, frame.readText())
|
||||
}
|
||||
}
|
||||
} catch (ignored: ClosedChannelException) {
|
||||
} catch (e: Exception) {
|
||||
} catch (ignored: ClosedReceiveChannelException) {
|
||||
} catch (e: Throwable) {
|
||||
viaWebServer.onException(this, e)
|
||||
this.close(CloseReason(CloseReason.Codes.INTERNAL_ERROR, "INTERNAL ERROR"))
|
||||
} finally {
|
||||
|
@ -31,7 +31,6 @@ data class WebClient(
|
||||
listenedIds.add(uuid)
|
||||
return server.listeners.put(uuid, this)
|
||||
}
|
||||
|
||||
fun unlistenId(uuid: UUID): Boolean {
|
||||
server.listeners.remove(uuid, this)
|
||||
return listenedIds.remove(uuid)
|
||||
|
@ -10,7 +10,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.request.forms.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.websocket.*
|
||||
import io.ktor.server.websocket.*
|
||||
import kotlinx.coroutines.future.await
|
||||
import java.net.URLEncoder
|
||||
import java.time.Duration
|
||||
@ -19,16 +19,16 @@ import kotlin.math.absoluteValue
|
||||
|
||||
class WebLogin : WebState {
|
||||
override suspend fun start(webClient: WebClient) {
|
||||
webClient.ws.send(JsonObject().also {
|
||||
it.addProperty("action", "ad_minecraft_id_login")
|
||||
}.toString())
|
||||
webClient.ws.sendSerialized(JsonObject().also {
|
||||
it.addProperty("action", "ad_login_methods")
|
||||
})
|
||||
webClient.ws.flush()
|
||||
}
|
||||
|
||||
override suspend fun onMessage(webClient: WebClient, msg: String) {
|
||||
val obj = JsonParser.parseString(msg) as JsonObject
|
||||
|
||||
when (obj.getAsJsonPrimitive("action").asString) {
|
||||
when (obj["action"].asString) {
|
||||
"offline_login" -> handleOfflineLogin(webClient, msg, obj)
|
||||
"minecraft_id_login" -> handleMcIdLogin(webClient, obj)
|
||||
"listen_login_requests" -> handleListenLogins(webClient, obj)
|
||||
@ -45,7 +45,7 @@ class WebLogin : WebState {
|
||||
webClient.listenedIds.forEach { webClient.unlistenId(it) }
|
||||
}
|
||||
|
||||
override suspend fun onException(webClient: WebClient, exception: java.lang.Exception) {
|
||||
override suspend fun onException(webClient: WebClient, exception: Throwable) {
|
||||
}
|
||||
|
||||
private fun loginSuccessJson(username: String, uuid: UUID, token: String): JsonObject {
|
||||
@ -67,7 +67,7 @@ class WebLogin : WebState {
|
||||
|
||||
private suspend fun handleOfflineLogin(webClient: WebClient, msg: String, obj: JsonObject) {
|
||||
if (!sha512Hex(msg.toByteArray(Charsets.UTF_8)).startsWith("00000")) throw StacklessException("PoW failed")
|
||||
if ((obj.getAsJsonPrimitive("date").asLong - System.currentTimeMillis())
|
||||
if ((obj["date"].asLong - System.currentTimeMillis())
|
||||
.absoluteValue > Duration.ofSeconds(20).toMillis()
|
||||
) {
|
||||
throw StacklessException("Invalid PoW date")
|
||||
@ -76,7 +76,7 @@ class WebLogin : WebState {
|
||||
val uuid = generateOfflinePlayerUuid(username)
|
||||
|
||||
val token = webClient.server.generateToken(uuid, username)
|
||||
webClient.ws.send(loginSuccessJson(username, uuid, token).toString())
|
||||
webClient.ws.sendSerialized(loginSuccessJson(username, uuid, token))
|
||||
|
||||
webLogger.info("Token gen: ${webClient.id}: offline $username $uuid")
|
||||
}
|
||||
@ -90,24 +90,24 @@ class WebLogin : WebState {
|
||||
formParameters = parametersOf("code", code),
|
||||
).body<JsonObject>()
|
||||
|
||||
if (check.getAsJsonPrimitive("valid").asBoolean) {
|
||||
if (check["valid"].asBoolean) {
|
||||
val mcIdUser = check["username"].asString
|
||||
val uuid = check["uuid"]?.asString?.let { parseUndashedId(it.replace("-", "")) }
|
||||
?: webClient.server.usernameIdCache[mcIdUser].await()
|
||||
?: throw StacklessException("Failed to get UUID from minecraft.id")
|
||||
|
||||
val token = webClient.server.generateToken(uuid, mcIdUser)
|
||||
webClient.ws.send(loginSuccessJson(mcIdUser, uuid, token).toString())
|
||||
webClient.ws.sendSerialized(loginSuccessJson(mcIdUser, uuid, token))
|
||||
|
||||
webLogger.info("Token gen: ${webClient.id}: $mcIdUser $uuid")
|
||||
} else {
|
||||
webClient.ws.send(loginNotSuccess().toString())
|
||||
webClient.ws.sendSerialized(loginNotSuccess())
|
||||
webLogger.info("Token gen fail: ${webClient.id}: $username")
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun handleListenLogins(webClient: WebClient, obj: JsonObject) {
|
||||
val token = obj.getAsJsonPrimitive("token").asString
|
||||
val token = obj["token"].asString
|
||||
val user = webClient.server.parseToken(token)
|
||||
val response = JsonObject().also {
|
||||
it.addProperty("action", "listen_login_requests_result")
|
||||
@ -122,18 +122,18 @@ class WebLogin : WebState {
|
||||
response.addProperty("success", false)
|
||||
webLogger.info("Listen fail: ${webClient.id}")
|
||||
}
|
||||
webClient.ws.send(response.toString())
|
||||
webClient.ws.sendSerialized(response)
|
||||
}
|
||||
|
||||
private suspend fun handleUnlisten(webClient: WebClient, obj: JsonObject) {
|
||||
val uuid = UUID.fromString(obj.getAsJsonPrimitive("uuid").asString)
|
||||
val uuid = UUID.fromString(obj["uuid"].asString)
|
||||
webLogger.info("Unlisten: ${webClient.id}: $uuid")
|
||||
val response = JsonObject().also {
|
||||
it.addProperty("action", "unlisten_login_requests_result")
|
||||
it.addProperty("uuid", uuid.toString())
|
||||
it.addProperty("success", webClient.unlistenId(uuid))
|
||||
}
|
||||
webClient.ws.send(response.toString())
|
||||
webClient.ws.sendSerialized(response)
|
||||
}
|
||||
|
||||
private fun handleSessionResponse(webClient: WebClient, obj: JsonObject) {
|
||||
|
@ -12,7 +12,7 @@ import com.google.gson.JsonObject
|
||||
import com.viaversion.aas.*
|
||||
import com.viaversion.aas.config.VIAaaSConfig
|
||||
import com.viaversion.aas.util.StacklessException
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.server.netty.*
|
||||
import io.ktor.server.websocket.*
|
||||
@ -89,7 +89,12 @@ class WebServer {
|
||||
.expireAfterWrite(30, TimeUnit.SECONDS)
|
||||
.build<UUID, CompletableFuture<AddressInfo>>(CacheLoader.from { _ -> CompletableFuture() })
|
||||
|
||||
data class AddressInfo(val backVersion: Int, val backHostAndPort: HostAndPort, var frontOnline: Boolean? = null, var backName: String? = null)
|
||||
data class AddressInfo(
|
||||
val backVersion: Int,
|
||||
val backHostAndPort: HostAndPort,
|
||||
var frontOnline: Boolean? = null,
|
||||
var backName: String? = null
|
||||
)
|
||||
|
||||
suspend fun requestAddressInfo(frontName: String): CompletableFuture<AddressInfo> {
|
||||
var onlineId: UUID? = null
|
||||
@ -174,12 +179,12 @@ class WebServer {
|
||||
}"
|
||||
val msg = "Requester: $id $address ($ptr) ($ipString)\nBackend: $backAddress"
|
||||
listeners[id].forEach {
|
||||
it.ws.send(JsonObject().also {
|
||||
it.ws.sendSerialized(JsonObject().also {
|
||||
it.addProperty("action", "session_hash_request")
|
||||
it.addProperty("user", name)
|
||||
it.addProperty("session_hash", hash)
|
||||
it.addProperty("message", msg)
|
||||
}.toString())
|
||||
})
|
||||
it.ws.flush()
|
||||
}
|
||||
}
|
||||
@ -215,7 +220,7 @@ class WebServer {
|
||||
clients.remove(ws)
|
||||
}
|
||||
|
||||
suspend fun onException(ws: WebSocketServerSession, exception: Exception) {
|
||||
suspend fun onException(ws: WebSocketServerSession, exception: Throwable) {
|
||||
val client = clients[ws]!!
|
||||
webLogger.info("WS Error: ${client.id} $exception")
|
||||
webLogger.debug("Ws exception: ", exception)
|
||||
|
@ -4,5 +4,5 @@ interface WebState {
|
||||
suspend fun start(webClient: WebClient)
|
||||
suspend fun onMessage(webClient: WebClient, msg: String)
|
||||
suspend fun disconnected(webClient: WebClient)
|
||||
suspend fun onException(webClient: WebClient, exception: java.lang.Exception)
|
||||
suspend fun onException(webClient: WebClient, exception: Throwable)
|
||||
}
|
@ -78,10 +78,6 @@ function setWsStatus(txt) {
|
||||
connectionStatus.innerText = txt;
|
||||
}
|
||||
|
||||
function setListenVisible(visible) {
|
||||
listenVisible = visible;
|
||||
}
|
||||
|
||||
function refreshCorsStatus() {
|
||||
corsStatus.innerText = "...";
|
||||
icanhazip(true).then(ip => {
|
||||
@ -715,8 +711,8 @@ function handleJoinRequest(parsed) {
|
||||
|
||||
function onSocketMsg(event) {
|
||||
let parsed = JSON.parse(event.data);
|
||||
if (parsed.action === "ad_minecraft_id_login") {
|
||||
setListenVisible(true);
|
||||
if (parsed.action === "ad_login_methods") {
|
||||
listenVisible = true;
|
||||
renderActions();
|
||||
} else if (parsed.action === "login_result") {
|
||||
if (!parsed.success) {
|
||||
|
Loading…
Reference in New Issue
Block a user