mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-14 10:45:34 +01:00
hide some advanced settings in page, parse json on some packets, update deps
This commit is contained in:
parent
c4d12ae085
commit
2db33465a0
@ -84,7 +84,7 @@ dependencies {
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("org.slf4j:slf4j-api:$slf4jVer")
|
||||
|
||||
val ktorVersion = "2.0.3"
|
||||
val ktorVersion = "2.1.0"
|
||||
implementation("io.ktor:ktor-network-tls-certificates-jvm:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-websockets:$ktorVersion")
|
||||
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
|
||||
|
@ -1,28 +1,30 @@
|
||||
package com.viaversion.aas.codec.packet.common;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.viaversion.aas.codec.packet.Packet;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AbstractSingleMessage implements Packet {
|
||||
private String msg;
|
||||
public class AbstractSingleJson implements Packet {
|
||||
private JsonElement msg;
|
||||
|
||||
public String getMsg() {
|
||||
public JsonElement getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
public void setMsg(JsonElement msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
|
||||
msg = Type.STRING.read(byteBuf);
|
||||
msg = JsonParser.parseString(Type.STRING.read(byteBuf));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
|
||||
Type.STRING.write(byteBuf, msg);
|
||||
Type.STRING.write(byteBuf, msg.toString());
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package com.viaversion.aas.codec.packet.login;
|
||||
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleMessage;
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleJson;
|
||||
|
||||
public class LoginDisconnect extends AbstractSingleMessage {
|
||||
public class LoginDisconnect extends AbstractSingleJson {
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.viaversion.aas.codec.packet.play;
|
||||
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleMessage;
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleJson;
|
||||
|
||||
public class Kick extends AbstractSingleMessage {
|
||||
public class Kick extends AbstractSingleJson {
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.viaversion.aas.codec.packet.status;
|
||||
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleMessage;
|
||||
import com.viaversion.aas.codec.packet.common.AbstractSingleJson;
|
||||
|
||||
public class StatusResponse extends AbstractSingleMessage {
|
||||
public class StatusResponse extends AbstractSingleJson {
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.viaversion.aas.handler.autoprotocol
|
||||
|
||||
import com.google.gson.JsonParser
|
||||
import com.viaversion.aas.codec.packet.Packet
|
||||
import com.viaversion.aas.codec.packet.status.StatusResponse
|
||||
import com.viaversion.aas.handler.MinecraftHandler
|
||||
@ -20,7 +19,7 @@ class ProtocolDetectionState(val future: CompletableFuture<ProtocolVersion>) : C
|
||||
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
|
||||
handler.data.frontChannel.close()
|
||||
if (packet !is StatusResponse) throw StacklessException("Unexpected packet")
|
||||
val ver = JsonParser.parseString(packet.msg).asJsonObject
|
||||
val ver = packet.msg.asJsonObject
|
||||
.getAsJsonObject("version")["protocol"].asInt.parseProtocol()
|
||||
future.complete(ver)
|
||||
mcLogger.info("A.D.: {} {}", handler.endRemoteAddress, ver)
|
||||
|
@ -299,7 +299,7 @@ class LoginState : ConnectionState {
|
||||
super.disconnect(handler, msg)
|
||||
|
||||
val packet = LoginDisconnect()
|
||||
packet.msg = JsonPrimitive("[VIAaaS] §c$msg").toString()
|
||||
packet.msg = JsonPrimitive("[VIAaaS] §c$msg")
|
||||
writeFlushClose(handler.data.frontChannel, packet)
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ class PlayState : ConnectionState {
|
||||
super.disconnect(handler, msg)
|
||||
writeFlushClose(
|
||||
handler.data.frontChannel,
|
||||
Kick().also { it.msg = JsonPrimitive("[VIAaaS] §c$msg").toString() },
|
||||
Kick().also { it.msg = JsonPrimitive("[VIAaaS] §c$msg") },
|
||||
delay = is17(handler)
|
||||
)
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.viaversion.aas.handler.state
|
||||
import com.google.common.net.HostAndPort
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonParser
|
||||
import com.viaversion.aas.*
|
||||
import com.viaversion.aas.codec.packet.Packet
|
||||
import com.viaversion.aas.codec.packet.UnknownPacket
|
||||
@ -33,20 +32,16 @@ class StatusState : ConnectionState {
|
||||
|
||||
private fun modifyResponse(handler: MinecraftHandler, packet: StatusResponse) {
|
||||
if (VIAaaSConfig.showVersionPing) {
|
||||
val parsed = JsonParser.parseString(packet.msg).asJsonObject
|
||||
val parsed = packet.msg.asJsonObject
|
||||
val players = parsed.getAsJsonObject("players") ?: JsonObject().also { parsed.add("players", it) }
|
||||
val sample = players.getAsJsonArray("sample") ?: JsonArray().also { players.add("sample", it) }
|
||||
sample.add(JsonObject().also {
|
||||
it.addProperty("id", UUID.nameUUIDFromBytes("VIAaaS".toByteArray(Charsets.UTF_8)).toString())
|
||||
it.addProperty(
|
||||
"name",
|
||||
"§9VIAaaS§r C: §7${handler.data.frontVer?.parseProtocol()}§r S: §7${
|
||||
handler.data.backServerVer?.parseProtocol()
|
||||
}"
|
||||
"name", "§9VIAaaS§r C: §7%s§'r S: §7%s"
|
||||
.format(handler.data.frontVer?.parseProtocol(), handler.data.backServerVer?.parseProtocol())
|
||||
)
|
||||
})
|
||||
|
||||
packet.msg = parsed.toString()
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +65,7 @@ class StatusState : ConnectionState {
|
||||
VIAaaSConfig.faviconUrl?.let { favicon ->
|
||||
it.addProperty("favicon", favicon)
|
||||
}
|
||||
}.toString()
|
||||
}
|
||||
send(handler.data.frontChannel, packet, flush = true)
|
||||
handler.data.state = StatusKicked()
|
||||
handler.data.state.start(handler)
|
||||
|
@ -91,7 +91,6 @@ frame-src 'self' https://login.microsoftonline.com/ https://login.live.com/"
|
||||
<div class="container tab-content" id="content">
|
||||
<div aria-labelledby="home-tab" class="tab-pane fade show active" id="home">
|
||||
<p>WebSocket connection status: <span class="text-white bg-dark" id="connection_status">?</span></p>
|
||||
<p>CORS Proxy status: <span class="text-white bg-dark" id="cors_status">?</span></p>
|
||||
<hr>
|
||||
<div class="mb-3">
|
||||
<p>Listening to front-end logins from:</p>
|
||||
@ -114,27 +113,27 @@ frame-src 'self' https://login.microsoftonline.com/ https://login.live.com/"
|
||||
<p>Connecting to backend server:</p>
|
||||
<div id="connect">
|
||||
<form class="input-group mb-3 row g-3 justify-content-md-center">
|
||||
<div class="col-md-auto">
|
||||
<div class="col-md-4">
|
||||
<input id="connect_address" type="text" class="form-control" placeholder="Address:Port"
|
||||
aria-label="Address and Port" size="20">
|
||||
aria-label="Address and Port">
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<div class="col-md-2">
|
||||
<input id="connect_version" type="text" class="form-control col-auto" placeholder="Version"
|
||||
aria-label="Version" size="6">
|
||||
aria-label="Version">
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<select class="form-select" id="connect_online" aria-label="Online Mode" size="1">
|
||||
<option value="null" selected>Front Online Mode...</option>
|
||||
<option>AUTO</option>
|
||||
<option value="true">Force online</option>
|
||||
<option value="false">Force offline (recommended for Geyser)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-auto">
|
||||
<div class="col-md-2">
|
||||
<input id="connect_user" type="text" class="form-control" placeholder="Back Username"
|
||||
aria-label="Backend Username" list="backend_user_list" size="16" maxlength="16">
|
||||
aria-label="Backend Username" list="backend_user_list" maxlength="16">
|
||||
<datalist id="backend_user_list"></datalist>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-select" id="connect_online" aria-label="Online Mode">
|
||||
<option value="null" selected>Front Auth...</option>
|
||||
<option>AUTO</option>
|
||||
<option value="true">Online</option>
|
||||
<option value="false">Offline (recommended for Geyser)</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
<p>You can also use <a href="https://jo0001.github.io/ViaSetup/aspirin" id="viasetup_address">the address
|
||||
generator</a> to specify the server</p>
|
||||
@ -142,24 +141,31 @@ frame-src 'self' https://login.microsoftonline.com/ https://login.live.com/"
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="settings-tab" class="tab-pane fade" id="settings">
|
||||
<div class="mb-3">
|
||||
<p>See <a href="https://github.com/ViaVersion/VIAaaS/">README</a> for more details.</p>
|
||||
<form class="input-group" id="form_cors_proxy">
|
||||
<label class="input-group-text" for="cors-proxy">CORS Proxy</label>
|
||||
<input class="form-control" id="cors-proxy" placeholder="http://localhost:8080/" type="url">
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<form class="input-group" id="form_ws_url">
|
||||
<label class="input-group-text" for="ws-url">WebSocket</label>
|
||||
<input class="form-control" id="ws-url" placeholder="wss://viaaas.example.com/ws" type="url">
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button id="en_notifications" type="button" class="btn btn-primary">Enable browser notifications</button>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAdvConf"
|
||||
aria-expanded="false" aria-controls="collapseAdvConfig">Advanced
|
||||
</button>
|
||||
</div>
|
||||
<div class="collapse" id="collapseAdvConf">
|
||||
<div class="mb-3">
|
||||
<p>CORS Proxy status: <span class="text-white bg-dark" id="cors_status">?</span></p>
|
||||
<form class="input-group" id="form_cors_proxy">
|
||||
<label class="input-group-text" for="cors-proxy">CORS Proxy</label>
|
||||
<input class="form-control" id="cors-proxy" placeholder="http://localhost:8080/" type="url">
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<form class="input-group" id="form_ws_url">
|
||||
<label class="input-group-text" for="ws-url">WebSocket</label>
|
||||
<input class="form-control" id="ws-url" placeholder="wss://viaaas.example.com/ws" type="url">
|
||||
<button class="btn btn-primary" type="submit">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div aria-labelledby="accounts-tab" class="tab-pane fade" id="accounts">
|
||||
@ -234,13 +240,17 @@ frame-src 'self' https://login.microsoftonline.com/ https://login.live.com/"
|
||||
<ul>
|
||||
<li>access date and time</li>
|
||||
<li>backend Minecraft server IP</li>
|
||||
<li>IP address, port, approximate geolocation, ASN and reverse DNS lookup</li>
|
||||
<li>query string</li>
|
||||
<li>usernames</li>
|
||||
<li>client IP address, port, protocol version, approximate geolocation,
|
||||
ASN and reverse DNS lookup
|
||||
</li>
|
||||
<li>disconnection reason</li>
|
||||
<li>HTTP query string</li>
|
||||
<li>Minecraft usernames</li>
|
||||
</ul>
|
||||
<p>Why are these data collected?</p>
|
||||
<ul>
|
||||
<li>analytics</li>
|
||||
<li>improving our services</li>
|
||||
<li>troubleshooting</li>
|
||||
</ul>
|
||||
<p>When are data collected?</p>
|
||||
|
@ -310,7 +310,7 @@ $(() => {
|
||||
})
|
||||
|
||||
function handleSWMsg(event: MessageEvent) {
|
||||
console.log("sw msg: " + event);
|
||||
console.log("sw msg: ", event);
|
||||
let data = event.data;
|
||||
let callback = notificationCallbacks.get(data.tag as string);
|
||||
notificationCallbacks.delete(data.tag as string);
|
||||
@ -704,7 +704,12 @@ function onWsMsg(event: MessageEvent) {
|
||||
}
|
||||
|
||||
function handleParametersRequest(parsed: any) {
|
||||
let url = new URL("https://" + $("#connect_address").val());
|
||||
let url: URL = new URL("https://0.0.0.0");
|
||||
try {
|
||||
url = new URL("https://" + $("#connect_address").val());
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
socket.send(JSON.stringify({
|
||||
action: "parameters_response",
|
||||
callback: parsed["callback"],
|
||||
@ -733,6 +738,7 @@ function onWsError(e: any) {
|
||||
}
|
||||
|
||||
function onWsClose(evt: CloseEvent) {
|
||||
console.log(evt);
|
||||
setWsStatus("disconnected with close code " + evt.code + " and reason: " + evt.reason);
|
||||
resetHtml();
|
||||
setTimeout(connect, 5000);
|
||||
|
Loading…
Reference in New Issue
Block a user