cleanup, clean PacketRegistry

This commit is contained in:
creeper123123321 2021-05-04 17:15:06 -03:00
parent ccfed4f20c
commit 60a63ec9f1
61 changed files with 447 additions and 353 deletions

8
.github/FUNDING.yml vendored
View File

@ -1,5 +1,5 @@
custom:
- 'https://viaversion.com/donate'
- 'https://viaversion.com/backwards'
- 'https://viaversion.com/rewind'
- 'https://creeper123123321.github.io/#donate'
- 'https://viaversion.com/donate'
- 'https://viaversion.com/backwards'
- 'https://viaversion.com/rewind'
- 'https://creeper123123321.github.io/#donate'

View File

@ -1,18 +1,18 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: Java CI with Gradle
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 16
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v2
with:
name: artifact
path: build/libs/
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 16
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v2
with:
name: artifact
path: build/libs/

View File

@ -10,53 +10,71 @@ Discord: https://viaversion.com/discord
Supported versions: https://viaversion.com/
## How does it work?
- [ViaVersion](https://viaversion.com), [ViaBackwards](https://viaversion.com/backwards) and [ViaRewind](https://viaversion.com/rewind) translates the connections to backend server.
- VIAaaS auth page stores account credentials in the player's browser local storage. Check for XSS vulnerabilities on your domain.
- Due to technical/security reasons, it requires a CORS Proxy for calling Mojang APIs, which may make Mojang see that
as suspicious and reset/block your account password if the IP address seems suspect.
- [ViaVersion](https://viaversion.com), [ViaBackwards](https://viaversion.com/backwards)
and [ViaRewind](https://viaversion.com/rewind) translates the connections to backend server.
- VIAaaS auth page stores account credentials in the player's browser local storage. Check for XSS vulnerabilities on
your domain.
- Due to technical/security reasons, it requires a CORS Proxy for calling Mojang APIs, which may make Mojang see that as
suspicious and reset/block your account password if the IP address seems suspect.
- Account credentials aren't sent to VIAaaS instance, though it's intermediated by CORS Proxy.
- VIAaaS receives a the session hash from instance and then the browser validates it to Mojang.
## Setting up server instance
Download: [GitHub Actions](https://github.com/ViaVersion/VIAaaS/actions) (needs to be logged into GitHub) or [JitPack](https://jitpack.io/com/github/viaversion/viaaas/master-SNAPSHOT/viaaas-master-SNAPSHOT-all.jar)
Download: [GitHub Actions](https://github.com/ViaVersion/VIAaaS/actions) (needs to be logged into GitHub)
or [JitPack](https://jitpack.io/com/github/viaversion/viaaas/master-SNAPSHOT/viaaas-master-SNAPSHOT-all.jar)
How to start VIAaaS server:
```sh
java -jar VIAaaS-all.jar
```
- Requires Java 11
- Default Minecraft: ```via.localhost``` with port 25565
- Default HTTPS: ```https://localhost:25543/```
- Default WS URL: ```wss://localhost:25543/ws```
### How to create a public server
- You need a domain wildcarding to VIAaaS instance, like ``*.example.com -> 192.168.123.123``. You can use [DuckDNS](https://duckdns.org/) DDNS service.
- You need a domain wildcarding to VIAaaS instance, like ``*.example.com -> 192.168.123.123``. You can
use [DuckDNS](https://duckdns.org/) DDNS service.
- Configure the hostname in the config
- Open the Minecraft port (25565)
- The HTTPS page needs a certificate, you can use [Apache](https://httpd.apache.org/) (with a [Let's Encrypt](https://letsencrypt.org/) certificate) as a proxy. See apache_copypasta.txt file.
- The HTTPS page needs a certificate, you can use [Apache](https://httpd.apache.org/) (with
a [Let's Encrypt](https://letsencrypt.org/) certificate) as a proxy. See apache_copypasta.txt file.
## CORS Proxy
- For less chance of Mojang seeing the login as suspect, you (the player) should set up a CORS proxy on your machine.
- Note the ending slash in cors-anywhere address
- You can use my public instance at https://crp123-cors.herokuapp.com/ ([source](https://github.com/creeper123123321/cors-anywhere/)) too,
but proxies have a bit more chance of being seen as suspect.
- You can use my public instance
at https://crp123-cors.herokuapp.com/ ([source](https://github.com/creeper123123321/cors-anywhere/)) too, but proxies
have a bit more chance of being seen as suspect.
Setting up [cors-anywhere](https://www.npmjs.com/package/cors-anywhere) on local machine:
```sh
git clone https://github.com/Rob--W/cors-anywhere
cd cors-anywhere
npm install
node server.js
```
- It will be available at ```http://localhost:8080/```
## Usage for players
Usage for offline mode:
- Connect to ```mc.example.net.via.localhost```
Usage for online mode:
- You can use two accounts (avoids Bad Login error), the same account for front-end and back-end connections, or use ```_of```
(offline mode in frontend. May be useful if you have a client which is incompatible with online mode).
- You can use two accounts (avoids Bad Login error), the same account for front-end and back-end connections, or
use ```_of```
(offline mode in frontend. May be useful if you have a client which is incompatible with online mode).
- Go to VIAaaS auth webpage (default is https://localhost:25543/)
- Configure CORS proxy, see above in "CORS Proxy" section
- Listen to the username A you'll use to connect to the proxy.
@ -65,62 +83,83 @@ Usage for online mode:
- Connect to ```mc.example.com._u(B).via.localhost``` (```_u``` can be removed if you are using the same username)
- Approve the login in the webpage
- If you use the same online mode account, your client may show Bad Login. You can use a mod like
[Auth Me](https://www.curseforge.com/minecraft/mc-mods/auth-me) or [ReAuth](https://www.curseforge.com/minecraft/mc-mods/reauth).
[Auth Me](https://www.curseforge.com/minecraft/mc-mods/auth-me)
or [ReAuth](https://www.curseforge.com/minecraft/mc-mods/reauth).
### Address options
Example address:
- ```server.example.net._p25565._v1_12_2._of._uBACKUSERNAME.via.example.com```
- ```server.example.net.v_1_8.via.example.com```
- It's inspired by [Tor2web](https://www.tor2web.org/) proxies.
Address parts:
- You can use ``(option)_(value)`` too, like ``p_25565``.
- ```server.example.net```: backend server address
- ```_p```: backend port
- ```_v```: backend version ([protocol id](https://wiki.vg/Protocol_version_numbers) or name with underline instead of dots). ```AUTO``` is default and ``-1`` is fallback if it fails.
- ```_o```: ```t``` to force online mode in frontend, ```f``` to disable online mode in frontend. If not set, it will be based on backend online mode.
- ```_v```: backend version ([protocol id](https://wiki.vg/Protocol_version_numbers) or name with underline instead of
dots). ```AUTO``` is default and ``-1`` is fallback if it fails.
- ```_o```: ```t``` to force online mode in frontend, ```f``` to disable online mode in frontend. If not set, it will be
based on backend online mode.
- ```_u```: username to use in backend connection
- ```via.example.com```: instance address (defined in config)
## WARNING
- VIAaaS may trigger anti-cheats, due to block, item, movement and other differences between versions. USE AT OWN RISK
- Take care of browser local storage. Check for XSS vulnerabilities on your domain.
- Check the security of CORS proxy, it will intermediate Mojang API calls.
- Mojang may lock your account when API is called from a suspect IP address
## FAQ
### Accounts
My Microsoft account <18 years old is not able to log in, it's giving XSTS error:
- Add your account to a family (see https://wiki.vg/Microsoft_Authentication_Scheme#Authenticate_with_XSTS)
Why a online webpage for online mode?:
- It's easier to maintain in that way, because providing login via chat requires encoding and decoding more packets which change through versions.
- It's easier to maintain in that way, because providing login via chat requires encoding and decoding more packets
which change through versions.
- It allows your account password and token to be kept with you.
How to use Microsoft Account?:
- If you are using a public VIAaaS instance, use this page https://viaversion.github.io/VIAaaS/ and configure the WebSocket address.
- If you are using a public VIAaaS instance, use this page https://viaversion.github.io/VIAaaS/ and configure the
WebSocket address.
### Connection
How to use IPv6?:
- When listening to 0.0.0.0, it should listen on IPv6 too.
- To use IPv6 in backend address, you need to use a instance with IPv6 connectivity. The hostname parser currently doesn't support
direct IPv6, but you can use a DNS name with https://sslip.io/
- To use IPv6 in backend address, you need to use a instance with IPv6 connectivity. The hostname parser currently
doesn't support direct IPv6, but you can use a DNS name with https://sslip.io/
I'm getting a DNS error/"Unknown host" while connecting to (...).localhost
- Try configuring via-127-0-0-1.nip.io as hostname suffix
How to use with Geyser?
- Currently you need to set the parameters (at least the hostname) in Geyser's `address` field:
```yml
remote:
# The IP address of the remote (Java Edition) server
address: 2b2t.org._v1_12_2.via.localhost
```
- If you are using a public GeyserConnect instance: connect to a publicly available VIAaaS instance, like ```mc.example.com.via.example.net``` as a Java Edition server.
- If you are using a public GeyserConnect instance: connect to a publicly available VIAaaS instance,
like ```mc.example.com.via.example.net``` as a Java Edition server.
Can I use it to connect to .onion Minecraft hidden servers?
- You can use .onion addresses if the instance is proxying the backend connections to TOR.
Note that VIAaaS may log your requests.
- You can use .onion addresses if the instance is proxying the backend connections to TOR. Note that VIAaaS may log your
requests.
Can you support more versions?
- See [DirtMultiVersion](https://github.com/DirtPowered/DirtMultiversion)

View File

@ -102,9 +102,11 @@ tasks {
tasks.named<ProcessResources>("processResources") {
filesMatching("viaaas_info.json") {
filter<org.apache.tools.ant.filters.ReplaceTokens>("tokens" to mapOf(
filter<org.apache.tools.ant.filters.ReplaceTokens>(
"tokens" to mapOf(
"version" to project.property("version")
))
)
)
}
}

View File

@ -1 +1 @@
<meta http-equiv="refresh" content="0; url=https://viaversion.github.io/VIAaaS/src/main/resources/web/">
<meta content="0; url=https://viaversion.github.io/VIAaaS/src/main/resources/web/" http-equiv="refresh">

View File

@ -7,14 +7,14 @@ import com.google.common.primitives.Ints
import com.google.gson.JsonObject
import com.viaversion.aas.config.VIAaaSConfig
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.request.*
import io.netty.buffer.ByteBuf
import io.netty.channel.Channel
import io.netty.channel.ChannelFutureListener
import io.netty.handler.codec.DecoderException
import org.slf4j.LoggerFactory
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import java.math.BigInteger
import java.net.InetAddress
import java.net.InetSocketAddress

View File

@ -1,6 +1,5 @@
package com.viaversion.aas
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.viaversion.aas.command.VIAaaSConsole
import com.viaversion.aas.command.ViaAspirinCommand
@ -11,6 +10,10 @@ import com.viaversion.aas.platform.*
import com.viaversion.aas.protocol.registerAspirinProtocols
import com.viaversion.aas.web.ViaWebApp
import com.viaversion.aas.web.WebDashboardServer
import com.viaversion.viaversion.ViaManagerImpl
import com.viaversion.viaversion.api.Via
import com.viaversion.viaversion.api.data.MappingDataLoader
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import de.gerrygames.viarewind.api.ViaRewindConfigImpl
import io.ktor.application.*
import io.ktor.client.*
@ -37,15 +40,9 @@ import io.netty.channel.socket.nio.NioSocketChannel
import io.netty.util.concurrent.Future
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.io.IoBuilder
import com.viaversion.viaversion.ViaManagerImpl
import com.viaversion.viaversion.api.Via
import com.viaversion.viaversion.api.data.MappingDataLoader
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import java.io.File
import java.net.InetAddress
import java.security.KeyPairGenerator
import java.security.SecureRandom
import java.util.*
import java.util.concurrent.CompletableFuture
val viaaasVer = JsonParser.parseString(

View File

@ -41,20 +41,20 @@ class VIAaaSAddress {
fun parseOption(part: String): Boolean {
val option = when {
part.length < 2 -> null
part.startsWith("_") -> part[1]
part[1] == '_' -> part[0]
else -> null
}?.toString()
part.length < 2 -> null
part.startsWith("_") -> part[1]
part[1] == '_' -> part[0]
else -> null
}?.toString()
if (option != null) {
val arg = part.substring(2)
when (option.toLowerCase(Locale.ROOT)) {
"p" -> port = arg.toInt()
"o" -> online = when {
arg.startsWith("t", ignoreCase = true) -> true
arg.startsWith("f", ignoreCase = true) -> false
else -> null
}
arg.startsWith("t", ignoreCase = true) -> true
arg.startsWith("f", ignoreCase = true) -> false
else -> null
}
"v" -> parseProtocol(arg)
"u" -> {
if (arg.length > 16) throw StacklessException("Invalid username")

View File

@ -1,10 +1,10 @@
package com.viaversion.aas.codec
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.DecoderException
import io.netty.handler.codec.MessageToMessageCodec
import com.viaversion.viaversion.api.type.Type
import java.util.zip.Deflater
import java.util.zip.Inflater

View File

@ -1,11 +1,11 @@
package com.viaversion.aas.codec
import com.viaversion.aas.badLength
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.exception.CancelDecoderException
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.ByteToMessageCodec
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.exception.CancelDecoderException
class FrameCodec : ByteToMessageCodec<ByteBuf>() {
override fun decode(ctx: ChannelHandlerContext, input: ByteBuf, out: MutableList<Any>) {

View File

@ -4,11 +4,12 @@ import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.packet.PacketRegistry
import com.viaversion.aas.util.StacklessException
import com.viaversion.viaversion.api.protocol.packet.Direction
import com.viaversion.viaversion.exception.CancelEncoderException
import io.netty.buffer.ByteBuf
import io.netty.buffer.ByteBufAllocator
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.MessageToMessageCodec
import com.viaversion.viaversion.exception.CancelEncoderException
class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
override fun encode(ctx: ChannelHandlerContext, msg: Packet, out: MutableList<Any>) {
@ -16,7 +17,12 @@ class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
val buf = ByteBufAllocator.DEFAULT.buffer()
try {
val handler = ctx.pipeline().get(MinecraftHandler::class.java)
PacketRegistry.encode(msg, buf, handler.data.frontVer!!, serverBound = !handler.frontEnd)
PacketRegistry.encode(
msg,
buf,
handler.data.frontVer!!,
if (handler.frontEnd) Direction.CLIENTBOUND else Direction.SERVERBOUND
)
out.add(buf.retain())
} finally {
buf.release()
@ -30,7 +36,8 @@ class MinecraftCodec : MessageToMessageCodec<ByteBuf, Packet>() {
PacketRegistry.decode(
msg,
handler.data.frontVer ?: 0,
handler.data.state.state, handler.frontEnd
handler.data.state.state,
if (handler.frontEnd) Direction.SERVERBOUND else Direction.CLIENTBOUND
)
)
if (msg.isReadable) throw StacklessException("Remaining bytes!!!")

View File

@ -2,12 +2,12 @@ package com.viaversion.aas.command
import com.viaversion.aas.command.sub.StopSubCommand
import com.viaversion.aas.serverFinishing
import com.viaversion.viaversion.api.command.ViaCommandSender
import net.minecrell.terminalconsole.SimpleTerminalConsole
import org.jline.reader.Candidate
import org.jline.reader.LineReader
import org.jline.reader.LineReaderBuilder
import org.slf4j.LoggerFactory
import com.viaversion.viaversion.api.command.ViaCommandSender
import java.util.*
object VIAaaSConsole : SimpleTerminalConsole(), ViaCommandSender {

View File

@ -4,7 +4,7 @@ import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.viaversion.api.command.ViaCommandSender
import com.viaversion.viaversion.api.command.ViaSubCommand
object AspirinReloadSubCommand: ViaSubCommand() {
object AspirinReloadSubCommand : ViaSubCommand() {
override fun name() = "aasreload"
override fun description() = "Reloads VIAaaS config"

View File

@ -3,11 +3,11 @@ package com.viaversion.aas.handler
import com.viaversion.aas.codec.FrameCodec
import com.viaversion.aas.codec.MinecraftCodec
import com.viaversion.aas.handler.autoprotocol.ProtocolDetectorHandler
import com.viaversion.viaversion.connection.UserConnectionImpl
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl
import io.netty.channel.Channel
import io.netty.channel.ChannelInitializer
import io.netty.handler.timeout.ReadTimeoutHandler
import com.viaversion.viaversion.connection.UserConnectionImpl
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl
import java.util.concurrent.TimeUnit
class BackEndInit(val connectionData: ConnectionData) : ChannelInitializer<Channel>() {

View File

@ -3,11 +3,11 @@ package com.viaversion.aas.handler
import com.viaversion.aas.mcLogger
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.setAutoRead
import com.viaversion.viaversion.exception.CancelCodecException
import io.netty.channel.Channel
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler
import io.netty.handler.proxy.Socks5ProxyHandler
import com.viaversion.viaversion.exception.CancelCodecException
import java.net.SocketAddress
import java.nio.channels.ClosedChannelException

View File

@ -3,9 +3,9 @@ package com.viaversion.aas.handler
import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.send
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import io.netty.channel.ChannelPipeline
import io.netty.handler.proxy.Socks5ProxyHandler
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import java.net.InetSocketAddress
fun forward(handler: MinecraftHandler, packet: Packet, flush: Boolean = false) {

View File

@ -1,11 +1,11 @@
package com.viaversion.aas.handler
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.MessageToMessageCodec
import com.viaversion.viaversion.api.connection.UserConnection
import com.viaversion.viaversion.exception.CancelDecoderException
import com.viaversion.viaversion.exception.CancelEncoderException
import io.netty.buffer.ByteBuf
import io.netty.channel.ChannelHandlerContext
import io.netty.handler.codec.MessageToMessageCodec
class ViaCodec(val info: UserConnection) : MessageToMessageCodec<ByteBuf, ByteBuf>() {
override fun decode(ctx: ChannelHandlerContext, bytebuf: ByteBuf, out: MutableList<Any>) {

View File

@ -1,17 +1,16 @@
package com.viaversion.aas.handler.autoprotocol
import com.google.gson.JsonParser
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.handler.state.MinecraftConnectionState
import com.viaversion.aas.mcLogger
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.packet.status.StatusResponse
import com.viaversion.aas.parseProtocol
import com.google.gson.JsonParser
import com.viaversion.aas.util.StacklessException
import io.netty.channel.ChannelHandlerContext
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.protocol.packet.State
import java.nio.channels.ClosedChannelException
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import io.netty.channel.ChannelHandlerContext
import java.util.concurrent.CompletableFuture
class ProtocolDetectionState(val future: CompletableFuture<ProtocolVersion>) : MinecraftConnectionState {
@ -22,7 +21,7 @@ class ProtocolDetectionState(val future: CompletableFuture<ProtocolVersion>) : M
handler.data.frontChannel.close()
if (packet !is StatusResponse) throw StacklessException("unexpected packet")
val ver = JsonParser.parseString(packet.json).asJsonObject
.getAsJsonObject("version").get("protocol").asInt.parseProtocol()
.getAsJsonObject("version").get("protocol").asInt.parseProtocol()
future.complete(ver)
mcLogger.info("A.D.: ${handler.endRemoteAddress} $ver")
}

View File

@ -1,5 +1,7 @@
package com.viaversion.aas.handler.autoprotocol
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import com.viaversion.aas.channelSocketFactory
import com.viaversion.aas.childLoop
import com.viaversion.aas.codec.FrameCodec
@ -11,8 +13,8 @@ import com.viaversion.aas.mcLogger
import com.viaversion.aas.packet.handshake.Handshake
import com.viaversion.aas.packet.status.StatusRequest
import com.viaversion.aas.send
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import io.netty.bootstrap.Bootstrap
import io.netty.channel.Channel
import io.netty.channel.ChannelFuture
@ -21,8 +23,6 @@ import io.netty.channel.ChannelOption
import io.netty.handler.timeout.ReadTimeoutHandler
import io.netty.resolver.NoopAddressResolverGroup
import io.netty.util.concurrent.Future
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.protocol.packet.State
import java.net.InetSocketAddress
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutionException

View File

@ -3,12 +3,11 @@ package com.viaversion.aas.handler.autoprotocol
import com.viaversion.aas.handler.ConnectionData
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.mcLogger
import io.netty.channel.ChannelDuplexHandler
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.ChannelPromise
import java.net.InetSocketAddress
import java.util.concurrent.TimeUnit
import io.netty.channel.ChannelDuplexHandler
import java.lang.Exception
import java.util.function.Consumer
// https://github.com/ViaVersion/ViaFabric/blob/mc-1.16/src/main/java/com/github/creeper123123321/viafabric/handler/clientside/ProtocolDetectionHandler.java
@ -28,15 +27,15 @@ class ProtocolDetectorHandler(val connectionData: ConnectionData) : ChannelDuple
ctx.pipeline().remove(this)
}, 10, TimeUnit.SECONDS)
ProtocolDetector.detectVersion(address).whenComplete { protocol, _ ->
if (protocol != null && protocol.version != -1) {
connectionData.viaBackServerVer = protocol.version
} else {
connectionData.viaBackServerVer = -1 // fallback
}
ctx.pipeline().remove(this)
timeoutRun.cancel(false)
if (protocol != null && protocol.version != -1) {
connectionData.viaBackServerVer = protocol.version
} else {
connectionData.viaBackServerVer = -1 // fallback
}
ctx.pipeline().remove(this)
timeoutRun.cancel(false)
}
// Let's cache it before we need it
}
}

View File

@ -1,18 +1,18 @@
package com.viaversion.aas.handler.state
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.RateLimiter
import com.viaversion.aas.VIAaaSAddress
import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.mcLogger
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.packet.handshake.Handshake
import com.google.common.cache.CacheBuilder
import com.google.common.cache.CacheLoader
import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.RateLimiter
import com.viaversion.aas.util.StacklessException
import io.netty.channel.ChannelHandlerContext
import com.viaversion.viaversion.api.protocol.packet.State
import io.netty.channel.ChannelHandlerContext
import java.net.InetAddress
import java.net.InetSocketAddress
import java.util.concurrent.TimeUnit

View File

@ -10,13 +10,13 @@ import com.viaversion.aas.handler.forward
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.packet.login.*
import com.viaversion.aas.util.StacklessException
import com.viaversion.viaversion.api.protocol.packet.State
import io.netty.channel.Channel
import io.netty.channel.ChannelHandlerContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.future.await
import kotlinx.coroutines.launch
import com.viaversion.viaversion.api.protocol.packet.State
import java.util.*
import java.util.concurrent.CompletableFuture
import javax.crypto.Cipher

View File

@ -1,10 +1,10 @@
package com.viaversion.aas.handler.state
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.mcLogger
import io.netty.channel.ChannelHandlerContext
import com.viaversion.aas.packet.Packet
import com.viaversion.viaversion.api.protocol.packet.State
import io.netty.channel.ChannelHandlerContext
interface MinecraftConnectionState {
val state: State

View File

@ -1,5 +1,6 @@
package com.viaversion.aas.handler.state
import com.google.gson.JsonPrimitive
import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.handler.forward
@ -10,14 +11,13 @@ import com.viaversion.aas.packet.play.Kick
import com.viaversion.aas.packet.play.PluginMessage
import com.viaversion.aas.parseProtocol
import com.viaversion.aas.readRemainingBytes
import com.viaversion.aas.writeFlushClose
import com.google.gson.JsonPrimitive
import com.viaversion.aas.util.StacklessException
import com.viaversion.aas.writeFlushClose
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBufAllocator
import io.netty.buffer.Unpooled
import io.netty.channel.ChannelHandlerContext
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
object PlayState : MinecraftConnectionState {
override val state: State
@ -40,7 +40,8 @@ object PlayState : MinecraftConnectionState {
} else {
Type.STRING.read(Unpooled.wrappedBuffer(pluginMessage.data))
} + " (VIAaaS C: ${handler.data.frontVer!!.parseProtocol()} S: ${
handler.data.viaBackServerVer!!.parseProtocol()})"
handler.data.viaBackServerVer!!.parseProtocol()
})"
if (is1_7(handler)) {
pluginMessage.data = brand.toByteArray(Charsets.UTF_8)

View File

@ -1,5 +1,8 @@
package com.viaversion.aas.handler.state
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.viaversion.aas.config.VIAaaSConfig
import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.handler.forward
@ -7,14 +10,11 @@ import com.viaversion.aas.packet.Packet
import com.viaversion.aas.packet.UnknownPacket
import com.viaversion.aas.packet.status.StatusResponse
import com.viaversion.aas.parseProtocol
import com.viaversion.aas.writeFlushClose
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.viaversion.aas.util.StacklessException
import io.netty.channel.ChannelHandlerContext
import com.viaversion.aas.writeFlushClose
import com.viaversion.viaversion.api.Via
import com.viaversion.viaversion.api.protocol.packet.State
import io.netty.channel.ChannelHandlerContext
import java.util.*
object StatusState : MinecraftConnectionState {

View File

@ -8,6 +8,7 @@ import com.viaversion.aas.handler.MinecraftHandler
import com.viaversion.aas.handler.forward
import com.viaversion.aas.packet.handshake.Handshake
import com.viaversion.aas.util.StacklessException
import com.viaversion.viaversion.api.protocol.packet.State
import io.netty.bootstrap.Bootstrap
import io.netty.channel.ChannelFuture
import io.netty.channel.ChannelFutureListener
@ -17,7 +18,6 @@ import io.netty.resolver.NoopAddressResolverGroup
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import com.viaversion.viaversion.api.protocol.packet.State
import java.net.Inet4Address
import java.net.InetAddress
import java.net.InetSocketAddress

View File

@ -1,5 +1,6 @@
package com.viaversion.aas.packet
import com.google.common.collect.Range
import com.viaversion.aas.packet.handshake.Handshake
import com.viaversion.aas.packet.login.*
import com.viaversion.aas.packet.play.Kick
@ -8,91 +9,100 @@ import com.viaversion.aas.packet.status.StatusPing
import com.viaversion.aas.packet.status.StatusPong
import com.viaversion.aas.packet.status.StatusRequest
import com.viaversion.aas.packet.status.StatusResponse
import com.google.common.collect.Range
import com.viaversion.aas.util.StacklessException
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.packet.Direction
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15
import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9
import io.netty.buffer.ByteBuf
import java.util.function.Supplier
object PacketRegistry {
val entries = mutableListOf<RegistryEntry>()
init {
// Obviosly stolen from https://github.com/VelocityPowered/Velocity/blob/dev/1.1.0/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java
register(Range.all(), State.HANDSHAKE, 0, true, ::Handshake)
register(Range.all(), State.LOGIN, 0, true, ::LoginStart)
register(Range.all(), State.LOGIN, 1, true, ::CryptoResponse)
register(Range.atLeast(ProtocolVersion.v1_13.version), State.LOGIN, 2, true, ::PluginResponse)
register(Range.all(), State.LOGIN, 0, false, ::LoginDisconnect)
register(Range.all(), State.LOGIN, 1, false, ::CryptoRequest)
register(Range.all(), State.LOGIN, 2, false, ::LoginSuccess)
register(Range.all(), State.LOGIN, 3, false, ::SetCompression)
register(Range.atLeast(ProtocolVersion.v1_13.version), State.LOGIN, 4, false, ::PluginRequest)
register(Range.all(), State.STATUS, 0, true, ::StatusRequest)
register(Range.all(), State.STATUS, 1, true, ::StatusPing)
register(Range.all(), State.STATUS, 0, false, ::StatusResponse)
register(Range.all(), State.STATUS, 1, false, ::StatusPong)
// Obviously stolen from https://github.com/VelocityPowered/Velocity/blob/dev/1.1.0/proxy/src/main/java/com/velocitypowered/proxy/protocol/StateRegistry.java
register(State.HANDSHAKE, Direction.SERVERBOUND, ::Handshake, Range.all(), 0)
register(State.LOGIN, Direction.SERVERBOUND, ::LoginStart, Range.all(), 0)
register(State.LOGIN, Direction.SERVERBOUND, ::CryptoResponse, Range.all(), 1)
register(State.LOGIN, Direction.SERVERBOUND, ::PluginResponse, Range.atLeast(ProtocolVersion.v1_13.version), 2)
register(State.LOGIN, Direction.CLIENTBOUND, ::LoginDisconnect, Range.all(), 0)
register(State.LOGIN, Direction.CLIENTBOUND, ::CryptoRequest, Range.all(), 1)
register(State.LOGIN, Direction.CLIENTBOUND, ::LoginSuccess, Range.all(), 2)
register(State.LOGIN, Direction.CLIENTBOUND, ::SetCompression, Range.all(), 3)
register(State.LOGIN, Direction.CLIENTBOUND, ::PluginRequest, Range.atLeast(ProtocolVersion.v1_13.version), 4)
register(State.STATUS, Direction.SERVERBOUND, ::StatusRequest, Range.all(), 0)
register(State.STATUS, Direction.SERVERBOUND, ::StatusPing, Range.all(), 1)
register(State.STATUS, Direction.CLIENTBOUND, ::StatusResponse, Range.all(), 0)
register(State.STATUS, Direction.CLIENTBOUND, ::StatusPong, Range.all(), 1)
// Play
register(
::Kick, State.PLAY, false, mapOf(
Range.closed(ProtocolVersion.v1_7_1.version, ProtocolVersion.v1_8.version) to 0x40,
Range.closed(ProtocolVersion.v1_9.version, ProtocolVersion.v1_12_2.version) to 0x1A,
Range.closed(ProtocolVersion.v1_13.version, ProtocolVersion.v1_13_2.version) to 0x1B,
Range.closed(ProtocolVersion.v1_14.version, ProtocolVersion.v1_14_4.version) to 0x1A,
Range.closed(ProtocolVersion.v1_15.version, ProtocolVersion.v1_15_2.version) to 0x1B,
Range.closed(ProtocolVersion.v1_16.version, ProtocolVersion.v1_16_1.version) to 0x1A,
Range.closed(ProtocolVersion.v1_16_2.version, ProtocolVersion.v1_16_4.version) to 0x19
State.PLAY, Direction.CLIENTBOUND, ::Kick, mapOf(
ProtocolVersion.v1_7_1..ProtocolVersion.v1_8 to ClientboundPackets1_8.DISCONNECT.id,
ProtocolVersion.v1_9..ProtocolVersion.v1_12_2 to ClientboundPackets1_9.DISCONNECT.id,
ProtocolVersion.v1_13..ProtocolVersion.v1_13_2 to ClientboundPackets1_13.DISCONNECT.id,
ProtocolVersion.v1_14..ProtocolVersion.v1_14_4 to ClientboundPackets1_14.DISCONNECT.id,
ProtocolVersion.v1_15..ProtocolVersion.v1_15_2 to ClientboundPackets1_15.DISCONNECT.id,
ProtocolVersion.v1_16..ProtocolVersion.v1_16_1 to ClientboundPackets1_16.DISCONNECT.id,
ProtocolVersion.v1_16_2..ProtocolVersion.v1_16_4 to ClientboundPackets1_16_2.DISCONNECT.id,
Range.singleton(ProtocolVersion.v1_17.fullSnapshotVersion) to ClientboundPackets1_17.DISCONNECT.id
)
)
register(
::PluginMessage, State.PLAY, true, mapOf(
Range.closed(ProtocolVersion.v1_7_1.version, ProtocolVersion.v1_8.version) to 0x17,
Range.closed(ProtocolVersion.v1_9.version, ProtocolVersion.v1_11_1.version) to 0x09,
Range.singleton(ProtocolVersion.v1_12.version) to 0x0A,
Range.closed(ProtocolVersion.v1_12_1.version, ProtocolVersion.v1_12_2.version) to 0x09,
Range.closed(ProtocolVersion.v1_13.version, ProtocolVersion.v1_13_2.version) to 0x0A,
Range.closed(ProtocolVersion.v1_14.version, ProtocolVersion.v1_16_4.version) to 0x0B
)
)
register(
::PluginMessage, State.PLAY, false,
mapOf(
Range.closed(ProtocolVersion.v1_7_1.version, ProtocolVersion.v1_8.version) to 0x3F,
Range.closed(ProtocolVersion.v1_9.version, ProtocolVersion.v1_12_2.version) to 0x18,
Range.closed(ProtocolVersion.v1_13.version, ProtocolVersion.v1_13_2.version) to 0x19,
Range.closed(ProtocolVersion.v1_14.version, ProtocolVersion.v1_14_4.version) to 0x18,
Range.closed(ProtocolVersion.v1_15.version, ProtocolVersion.v1_15_2.version) to 0x19,
Range.closed(ProtocolVersion.v1_16.version, ProtocolVersion.v1_16_1.version) to 0x18,
Range.closed(ProtocolVersion.v1_16_2.version, ProtocolVersion.v1_16_4.version) to 0x17
State.PLAY, Direction.CLIENTBOUND, ::PluginMessage, mapOf(
ProtocolVersion.v1_7_1..ProtocolVersion.v1_8 to ClientboundPackets1_8.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_9..ProtocolVersion.v1_12_2 to ClientboundPackets1_9.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_13..ProtocolVersion.v1_13_2 to ClientboundPackets1_13.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_14..ProtocolVersion.v1_14_4 to ClientboundPackets1_14.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_15..ProtocolVersion.v1_15_2 to ClientboundPackets1_15.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_16..ProtocolVersion.v1_16_1 to ClientboundPackets1_16.PLUGIN_MESSAGE.id,
ProtocolVersion.v1_16_2..ProtocolVersion.v1_16_4 to ClientboundPackets1_16_2.PLUGIN_MESSAGE.id,
Range.singleton(ProtocolVersion.v1_17.fullSnapshotVersion) to ClientboundPackets1_17.PLUGIN_MESSAGE.id
)
)
}
operator fun ProtocolVersion.rangeTo(o: ProtocolVersion): Range<Int> {
return Range.closed(this.originalVersion, o.originalVersion)
}
inline fun <reified P : Packet> register(
protocol: Range<Int>,
state: State,
id: Int,
serverBound: Boolean,
constructor: Supplier<P>
) {
entries.add(RegistryEntry(protocol, state, id, serverBound, constructor, P::class.java))
}
inline fun <reified P : Packet> register(
direction: Direction,
constructor: Supplier<P>,
state: State,
serverBound: Boolean,
idByProtocol: Map<Range<Int>, Int>
idByProtocol: Map<Range<Int>, Int>,
klass: Class<P> = P::class.java,
) {
idByProtocol.forEach { (protocol, id) -> register(protocol, state, id, serverBound, constructor) }
entries.add(RegistryEntry(idByProtocol, state, direction, constructor, klass))
}
inline fun <reified P : Packet> register(
state: State,
direction: Direction,
constructor: Supplier<P>,
protocol: Range<Int>,
id: Int
) {
register(constructor = constructor, direction = direction, state = state, idByProtocol = mapOf(protocol to id))
}
data class RegistryEntry(
val versionRange: Range<Int>,
val idByVersion: Map<Range<Int>, Int>,
val state: State,
val id: Int,
val serverBound: Boolean,
val direction: Direction,
val constructor: Supplier<out Packet>,
val packetClass: Class<out Packet>
)
@ -101,34 +111,35 @@ object PacketRegistry {
protocolVersion: Int,
state: State,
id: Int,
serverBound: Boolean
direction: Direction
): Supplier<out Packet>? {
return entries.firstOrNull {
it.serverBound == serverBound && it.state == state
&& it.versionRange.contains(protocolVersion) && it.id == id
it.direction == direction
&& it.state == state
&& it.idByVersion.entries.firstOrNull { it.key.contains(protocolVersion) }?.value == id
}?.constructor
}
fun getPacketId(packetClass: Class<out Packet>, protocolVersion: Int, serverBound: Boolean): Int? {
fun getPacketId(packetClass: Class<out Packet>, protocolVersion: Int, direction: Direction): Int? {
return entries.firstOrNull {
it.versionRange.contains(protocolVersion) && it.packetClass == packetClass && it.serverBound == serverBound
}?.id
it.packetClass == packetClass && it.direction == direction
}?.idByVersion?.entries?.firstOrNull { it.key.contains(protocolVersion) }?.value
}
fun decode(byteBuf: ByteBuf, protocolVersion: Int, state: State, serverBound: Boolean): Packet {
fun decode(byteBuf: ByteBuf, protocolVersion: Int, state: State, direction: Direction): Packet {
val packetId = Type.VAR_INT.readPrimitive(byteBuf)
val packet =
getPacketConstructor(protocolVersion, state, packetId, serverBound)?.get() ?: UnknownPacket(packetId)
getPacketConstructor(protocolVersion, state, packetId, direction)?.get() ?: UnknownPacket(packetId)
packet.decode(byteBuf, protocolVersion)
if (byteBuf.isReadable) throw StacklessException("Remaining bytes!")
return packet
}
fun encode(packet: Packet, byteBuf: ByteBuf, protocolVersion: Int, serverBound: Boolean) {
fun encode(packet: Packet, byteBuf: ByteBuf, protocolVersion: Int, direction: Direction) {
val id = if (packet is UnknownPacket) {
packet.id
} else {
getPacketId(packet.javaClass, protocolVersion, serverBound)!!
getPacketId(packet.javaClass, protocolVersion, direction)!!
}
Type.VAR_INT.writePrimitive(byteBuf, id)
packet.encode(byteBuf, protocolVersion)

View File

@ -1,9 +1,9 @@
package com.viaversion.aas.packet.handshake
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import kotlin.properties.Delegates
class Handshake : Packet {

View File

@ -2,9 +2,9 @@ package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.readByteArray
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import java.security.KeyFactory
import java.security.PublicKey
import java.security.spec.X509EncodedKeySpec

View File

@ -2,9 +2,9 @@ package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.readByteArray
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class CryptoResponse : Packet {
lateinit var encryptedKey: ByteArray

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class LoginDisconnect : Packet {
lateinit var msg: String

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class LoginStart : Packet {
lateinit var username: String

View File

@ -2,9 +2,9 @@ package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.parseUndashedId
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import java.util.*
class LoginSuccess : Packet {

View File

@ -2,8 +2,8 @@ package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.readRemainingBytes
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import kotlin.properties.Delegates
class PluginRequest : Packet {

View File

@ -2,8 +2,8 @@ package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.readRemainingBytes
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import kotlin.properties.Delegates
class PluginResponse : Packet {

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.packet.login
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
import kotlin.properties.Delegates
class SetCompression : Packet {

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.packet.play
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class Kick : Packet {
lateinit var msg: String

View File

@ -3,9 +3,9 @@ package com.viaversion.aas.packet.play
import com.viaversion.aas.packet.Packet
import com.viaversion.aas.readByteArray
import com.viaversion.aas.readRemainingBytes
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class PluginMessage : Packet {
lateinit var channel: String

View File

@ -3,7 +3,7 @@ package com.viaversion.aas.packet.status
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
class StatusRequest: Packet {
class StatusRequest : Packet {
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
}

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.packet.status
import com.viaversion.aas.packet.Packet
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.Type
import io.netty.buffer.ByteBuf
class StatusResponse : Packet {
lateinit var json: String

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.platform
import com.viaversion.viabackwards.api.ViaBackwardsPlatform
import org.slf4j.LoggerFactory
import com.viaversion.viaversion.sponge.util.LoggerWrapper
import org.slf4j.LoggerFactory
import java.io.File
import java.util.logging.Logger

View File

@ -1,20 +1,19 @@
package com.viaversion.aas.platform
import com.google.common.util.concurrent.ThreadFactoryBuilder
import com.viaversion.aas.config.AspirinViaConfig
import com.viaversion.aas.initFuture
import com.viaversion.aas.viaaasVer
import com.google.common.util.concurrent.ThreadFactoryBuilder
import io.netty.channel.DefaultEventLoop
import org.slf4j.LoggerFactory
import com.viaversion.viaversion.api.ViaAPI
import com.viaversion.viaversion.api.configuration.ViaVersionConfig
import com.viaversion.viaversion.api.command.ViaCommandSender
import com.viaversion.viaversion.api.configuration.ConfigurationProvider
import com.viaversion.viaversion.api.platform.PlatformTask
import com.viaversion.viaversion.api.configuration.ViaVersionConfig
import com.viaversion.viaversion.api.platform.ViaPlatform
import com.viaversion.viaversion.libs.gson.JsonObject
import com.viaversion.viaversion.sponge.util.LoggerWrapper
import com.viaversion.viaversion.util.VersionInfo
import com.viaversion.viaversion.libs.gson.JsonObject
import io.netty.channel.DefaultEventLoop
import org.slf4j.LoggerFactory
import java.io.File
import java.util.*
import java.util.concurrent.CompletableFuture
@ -47,7 +46,7 @@ object AspirinPlatform : ViaPlatform<UUID> {
override fun getDump(): JsonObject = JsonObject()
override fun kickPlayer(p0: UUID, p1: String): Boolean = false
override fun getApi(): ViaAPI<UUID> = AspirinViaAPI
override fun getDataFolder(): File = File("viaversion")
override fun getDataFolder(): File = File("viaversion")
override fun getConf(): ViaVersionConfig = AspirinViaConfig
override fun runAsync(p0: Runnable): AspirinTask = AspirinTask(CompletableFuture.runAsync(p0, executor))
override fun getLogger(): Logger = LoggerWrapper(LoggerFactory.getLogger("ViaVersion"))

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.platform
import com.viaversion.viaversion.sponge.util.LoggerWrapper
import de.gerrygames.viarewind.api.ViaRewindPlatform
import org.slf4j.LoggerFactory
import com.viaversion.viaversion.sponge.util.LoggerWrapper
import java.util.logging.Logger
object AspirinRewind : ViaRewindPlatform {

View File

@ -8,6 +8,10 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
// cursed 1.7 -> 1.8 from https://github.com/Gerrygames/ClientViaVersion
// + https://github.com/creeper123123321/ViaRewind/tree/17to18
fun registerAspirinProtocols() {
Via.getManager().protocolManager.registerProtocol(Protocol1_7_6to1_7_2, ProtocolVersion.v1_7_6, ProtocolVersion.v1_7_1)
Via.getManager().protocolManager.registerProtocol(
Protocol1_7_6to1_7_2,
ProtocolVersion.v1_7_6,
ProtocolVersion.v1_7_1
)
Via.getManager().protocolManager.registerProtocol(Protocol1_8To1_7_6, ProtocolVersion.v1_8, ProtocolVersion.v1_7_6)
}

View File

@ -1,7 +1,7 @@
package com.viaversion.aas.protocol
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.minecraft.Position
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.protocol.remapper.ValueReader
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer
import com.viaversion.viaversion.api.protocol.remapper.ValueWriter

View File

@ -4,7 +4,6 @@ import com.viaversion.aas.protocol.id47toid5.packets.*
import com.viaversion.aas.protocol.id47toid5.storage.*
import com.viaversion.viaversion.api.connection.UserConnection
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol
import java.util.*
// Based on https://github.com/Gerrygames/ClientViaVersion
object Protocol1_8To1_7_6 : AbstractSimpleProtocol() {

View File

@ -1,10 +1,10 @@
package com.viaversion.aas.protocol.id47toid5.chunks
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.type.types.CustomByteType
import io.netty.buffer.ByteBuf
import java.io.IOException
import java.util.stream.IntStream
import java.util.zip.DataFormatException
@ -102,7 +102,8 @@ object ChunkPacketTransformer {
}
val chunks = arrayOfNulls<Chunk1_8to1_7_6_10>(columnCount)
(0 until columnCount).forEach {
chunks[it] = Chunk1_8to1_7_6_10(inflatedBuffers[it]!!, primaryBitMask[it], addBitMask[it], skyLightSent, true)
chunks[it] =
Chunk1_8to1_7_6_10(inflatedBuffers[it]!!, primaryBitMask[it], addBitMask[it], skyLightSent, true)
}
packetWrapper.write(Type.BOOLEAN, skyLightSent)
packetWrapper.write(Type.VAR_INT, columnCount)
@ -133,13 +134,13 @@ object ChunkPacketTransformer {
packetWrapper.write(Type.INT, chunkX)
packetWrapper.write(Type.INT, chunkZ)
packetWrapper.write(Type.BLOCK_CHANGE_RECORD_ARRAY, IntStream.range(0, size)
.mapToObj {
val encodedPos = (positions[it].toInt())
val x = encodedPos.ushr(12).and(0xF)
val y = encodedPos.and(0xFF)
val z = encodedPos.ushr(8).and(0xF)
BlockChangeRecord1_8(x, y, z, blocks[it].toInt())
}
.toList().toTypedArray())
.mapToObj {
val encodedPos = (positions[it].toInt())
val x = encodedPos.ushr(12).and(0xF)
val y = encodedPos.and(0xFF)
val z = encodedPos.ushr(8).and(0xF)
BlockChangeRecord1_8(x, y, z, blocks[it].toInt())
}
.toList().toTypedArray())
}
}

View File

@ -1,11 +1,10 @@
package com.viaversion.aas.protocol.id47toid5.metadata
import de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6_10
import com.viaversion.viaversion.api.Via
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types
import com.viaversion.viaversion.api.minecraft.metadata.Metadata
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8
import java.util.*
import de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6_10
object MetadataRewriter {
fun transform(type: Entity1_10Types.EntityType?, list: MutableList<Metadata>) {

View File

@ -5,13 +5,13 @@ import com.viaversion.aas.protocol.id47toid5.metadata.MetadataRewriter
import com.viaversion.aas.protocol.id47toid5.storage.EntityTracker
import com.viaversion.aas.protocol.id47toid5.type.CustomIntType
import com.viaversion.aas.protocol.xyzToPosition
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.type.types.version.Types1_8
import com.viaversion.viaversion.api.protocol.packet.State
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import kotlin.experimental.and
fun Protocol1_8To1_7_6.registerEntityPackets() {
@ -36,7 +36,10 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
packetWrapper.write(Type.VAR_INT, entityId) //Entity Id
packetWrapper.write(Type.UNSIGNED_BYTE, 0.toShort()) //Index
packetWrapper.write(Type.UNSIGNED_BYTE, 0.toShort()) //Type
packetWrapper.write(Type.BYTE, (if (animation.toInt() == 104) 0x02 else 0x00).toByte()) //Value (sneaking/not sneaking)
packetWrapper.write(
Type.BYTE,
(if (animation.toInt() == 104) 0x02 else 0x00).toByte()
) //Value (sneaking/not sneaking)
packetWrapper.write(Type.UNSIGNED_BYTE, 255.toShort()) //end
} else {
packetWrapper.write(Type.VAR_INT, entityId) //Entity Id
@ -381,7 +384,12 @@ fun Protocol1_8To1_7_6.registerEntityPackets() {
this.registerServerbound(State.PLAY, 0x0B, 0x0B, object : PacketRemapper() {
override fun registerMap() {
map(Type.VAR_INT, Type.INT) //Entity Id
handler { packetWrapper -> packetWrapper.write(Type.BYTE, (packetWrapper.read(Type.VAR_INT) + 1).toByte()) } //Action Id
handler { packetWrapper ->
packetWrapper.write(
Type.BYTE,
(packetWrapper.read(Type.VAR_INT) + 1).toByte()
)
} //Action Id
map(Type.VAR_INT, Type.INT) //Action Paramter
}
})

View File

@ -2,14 +2,14 @@ package com.viaversion.aas.protocol.id47toid5.packets
import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.aas.protocol.id47toid5.storage.Windows
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import com.viaversion.viaversion.api.minecraft.item.Item
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.libs.kyori.adventure.text.Component
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
fun Protocol1_8To1_7_6.registerInventoryPackets() {

View File

@ -1,9 +1,9 @@
package com.viaversion.aas.protocol.id47toid5.packets
import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
fun Protocol1_8To1_7_6.registerLoginPackets() {
//Encryption Request

View File

@ -9,24 +9,23 @@ import com.viaversion.aas.protocol.id47toid5.storage.Scoreboard
import com.viaversion.aas.protocol.id47toid5.storage.Tablist
import com.viaversion.aas.protocol.xyzToPosition
import com.viaversion.aas.protocol.xyzUBytePos
import com.viaversion.aas.readRemainingBytes
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.CustomStringType
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import de.gerrygames.viarewind.utils.ChatUtil
import io.netty.buffer.Unpooled
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.Via
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types
import com.viaversion.viaversion.api.minecraft.item.Item
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.type.types.CustomByteType
import com.viaversion.viaversion.api.type.types.version.Types1_8
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.util.ChatColorUtil
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag
import com.viaversion.viaversion.util.ChatColorUtil
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.CustomStringType
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import de.gerrygames.viarewind.utils.ChatUtil
import io.netty.buffer.Unpooled
import java.nio.charset.StandardCharsets
import java.util.*
import kotlin.experimental.and

View File

@ -5,14 +5,14 @@ import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.aas.protocol.id47toid5.chunks.ChunkPacketTransformer
import com.viaversion.aas.protocol.id47toid5.data.Particle1_8to1_7
import com.viaversion.aas.protocol.id47toid5.storage.MapStorage
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.protocol.remapper.TypeRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8
import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10
import kotlin.experimental.and
fun Protocol1_8To1_7_6.registerWorldPackets() {

View File

@ -2,14 +2,13 @@ package com.viaversion.aas.protocol.id47toid5.storage
import com.viaversion.aas.protocol.id47toid5.Protocol1_8To1_7_6
import com.viaversion.aas.protocol.id47toid5.metadata.MetadataRewriter
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.connection.StoredObject
import com.viaversion.viaversion.api.connection.UserConnection
import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types
import com.viaversion.viaversion.api.minecraft.metadata.Metadata
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.type.types.version.Types1_8
import java.lang.Exception
import java.util.concurrent.ConcurrentHashMap
class EntityTracker(user: UserConnection) : StoredObject(user) {

View File

@ -2,7 +2,6 @@ package com.viaversion.aas.protocol.id47toid5.storage
import com.viaversion.viaversion.api.connection.StoredObject
import com.viaversion.viaversion.api.connection.UserConnection
import java.util.*
class MapStorage(user: UserConnection) : StoredObject(user) {
private val maps: MutableMap<Int, MapData> = HashMap()
@ -18,5 +17,6 @@ class MapStorage(user: UserConnection) : StoredObject(user) {
var scale: Byte = 0
var mapIcons = emptyArray<MapIcon>()
}
class MapIcon(var direction: Byte, var type: Byte, var x: Byte, var z: Byte)
}

View File

@ -2,7 +2,6 @@ package com.viaversion.aas.protocol.id47toid5.storage
import com.viaversion.viaversion.api.connection.StoredObject
import com.viaversion.viaversion.api.connection.UserConnection
import java.util.*
class Scoreboard(user: UserConnection) : StoredObject(user) {
private val objectives = HashMap<String, String>()

View File

@ -1,7 +1,7 @@
package com.viaversion.aas.protocol.id47toid5.type
import io.netty.buffer.ByteBuf
import com.viaversion.viaversion.api.type.PartialType
import io.netty.buffer.ByteBuf
class CustomIntType(amount: Int) : PartialType<IntArray, Int>(amount, IntArray::class.java) {
override fun read(p0: ByteBuf, p1: Int): IntArray {

View File

@ -3,9 +3,9 @@ package com.viaversion.aas.protocol.id5toid4
import com.viaversion.aas.protocol.INSERT_DASHES
import com.viaversion.viaversion.api.connection.UserConnection
import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol
import com.viaversion.viaversion.api.protocol.packet.State
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper
import com.viaversion.viaversion.api.type.Type
import com.viaversion.viaversion.api.protocol.packet.State
// Based on https://github.com/Gerrygames/ClientViaVersion
object Protocol1_7_6to1_7_2 : AbstractSimpleProtocol() {

View File

@ -1,8 +1,8 @@
package com.viaversion.aas.web
import com.viaversion.aas.config.VIAaaSConfig
import com.google.common.collect.Sets
import com.google.common.util.concurrent.RateLimiter
import com.viaversion.aas.config.VIAaaSConfig
import io.ktor.features.*
import io.ktor.websocket.*
import java.util.*

View File

@ -26,7 +26,8 @@ class WebLogin : WebState {
"offline_login" -> {
if (!sha512Hex(msg.toByteArray(Charsets.UTF_8)).startsWith("00000")) throw StacklessException("PoW failed")
if ((obj.getAsJsonPrimitive("date").asLong - System.currentTimeMillis()).absoluteValue
> Duration.ofMinutes(2).toMillis()) {
> Duration.ofMinutes(2).toMillis()
) {
throw StacklessException("Invalid PoW date")
}
val username = obj.get("username").asString.trim()

View File

@ -2,140 +2,171 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>VIAaaS</title>
<meta name="application-name" content="VIAaaS">
<meta property="og:site_name" content="VIAaaS">
<meta name="description" content="VIAaaS - ViaVersion as a Service - ViaVersion standalone proxy">
<meta property="og:title" content="VIAaaS">
<meta property="og:description" content="VIAaaS - ViaVersion as a Service - ViaVersion standalone proxy">
<meta property="og:type" content="game">
<meta property="og:image" content="https://cdn.discordapp.com/attachments/698483428915675186/821487447664885770/unknown.png">
<link rel="icon" href="https://cdn.discordapp.com/attachments/698483428915675186/821487447664885770/unknown.png">
<meta http-equiv="Content-Security-Policy" content="default-src 'self';
<meta content="VIAaaS" name="application-name">
<meta content="VIAaaS" property="og:site_name">
<meta content="VIAaaS - ViaVersion as a Service - ViaVersion standalone proxy" name="description">
<meta content="VIAaaS" property="og:title">
<meta content="VIAaaS - ViaVersion as a Service - ViaVersion standalone proxy" property="og:description">
<meta content="game" property="og:type">
<meta content="https://cdn.discordapp.com/attachments/698483428915675186/821487447664885770/unknown.png"
property="og:image">
<link href="https://cdn.discordapp.com/attachments/698483428915675186/821487447664885770/unknown.png" rel="icon">
<meta content="default-src 'self';
style-src https://cdnjs.cloudflare.com/ 'self';
img-src data: https://cdn.discordapp.com/ https://crafthead.net/ https://crafatar.com/;
connect-src 'self' http://localhost:*/ https: wss:;
script-src 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'self' https://ajax.cloudflare.com/ https://cdnjs.cloudflare.com/ https://alcdn.msauth.net/">
<meta name="referrer" content="no-referrer">
<meta name="robots" content="noindex">
<meta name="theme-color" content="#0468a1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta1/js/bootstrap.bundle.min.js" integrity="sha512-q2vREMvON/xrz1KuOj5QKWmdvcHtM4XNbNer+Qbf4TOj+RMDnul0Fg3VmmYprdf3fnL1gZgzKhZszsp62r5Ugg==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.js" integrity="sha512-1lagjLfnC1I0iqH9plHYIUq3vDMfjhZsLy9elfK89RBcpcRcx4l+kRJBSnHh2Mh6kLxRHoObD1M5UTUbgFy6nA==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js" integrity="sha512-UNM1njAgOFUa74Z0bADwAq8gbTcqZC8Ej4xPSzpnh0l6KMevwvkBvbldF9uR++qKeJ+MOZHRjV1HZjoRvjDfNQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/3.2.0/sha.min.js" integrity="sha512-/yIGjYJZIXZx10ig0yhbK41OiwcqBUxIj0xQJe+NwkMIdS/u07b6Mwo0nvXB4o7A6WiKnKOf92JwE5Ezo27u9Q==" crossorigin="anonymous"></script>
<script src="https://alcdn.msauth.net/browser/2.7.0/js/msal-browser.js" integrity="sha384-5Fqyq1ncNYhL2mXCdWAFXkf2wWtKeA0mXYp++ryAX1lowD0ctAHFdity37L/ULXh" crossorigin="anonymous"></script>
script-src 'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=' 'self' https://ajax.cloudflare.com/ https://cdnjs.cloudflare.com/ https://alcdn.msauth.net/" http-equiv="Content-Security-Policy">
<meta content="no-referrer" name="referrer">
<meta content="noindex" name="robots">
<meta content="#0468a1" name="theme-color">
<link crossorigin="anonymous"
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta1/css/bootstrap.min.css" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1"
rel="stylesheet">
<script crossorigin="anonymous"
integrity="sha512-q2vREMvON/xrz1KuOj5QKWmdvcHtM4XNbNer+Qbf4TOj+RMDnul0Fg3VmmYprdf3fnL1gZgzKhZszsp62r5Ugg=="
src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.0.0-beta1/js/bootstrap.bundle.min.js"></script>
<script crossorigin="anonymous"
integrity="sha512-1lagjLfnC1I0iqH9plHYIUq3vDMfjhZsLy9elfK89RBcpcRcx4l+kRJBSnHh2Mh6kLxRHoObD1M5UTUbgFy6nA=="
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.js"></script>
<script crossorigin="anonymous"
integrity="sha512-UNM1njAgOFUa74Z0bADwAq8gbTcqZC8Ej4xPSzpnh0l6KMevwvkBvbldF9uR++qKeJ+MOZHRjV1HZjoRvjDfNQ=="
src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js"></script>
<script crossorigin="anonymous"
integrity="sha512-/yIGjYJZIXZx10ig0yhbK41OiwcqBUxIj0xQJe+NwkMIdS/u07b6Mwo0nvXB4o7A6WiKnKOf92JwE5Ezo27u9Q=="
src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/3.2.0/sha.min.js"></script>
<script crossorigin="anonymous"
integrity="sha384-5Fqyq1ncNYhL2mXCdWAFXkf2wWtKeA0mXYp++ryAX1lowD0ctAHFdity37L/ULXh"
src="https://alcdn.msauth.net/browser/2.7.0/js/msal-browser.js"></script>
<link href="style.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="javascript:">VIAaaS</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav nav" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-bs-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Status</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="accounts-tab" data-bs-toggle="tab" href="#accounts" role="tab" aria-controls="accounts" aria-selected="false">Accounts</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="settings-tab" data-bs-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">Settings</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="aboutDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
About
</a>
<ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="aboutDropdown">
<li><a class="dropdown-item" data-bs-toggle="modal" href="#aboutModal" role="tab">About VIAaaS</a></li>
</ul>
</li>
</ul>
<div class="container-fluid">
<a class="navbar-brand" href="javascript:">VIAaaS</a>
<button aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation" class="navbar-toggler"
data-bs-target="#navbarSupportedContent" data-bs-toggle="collapse" type="button">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav nav" role="tablist">
<li class="nav-item" role="presentation">
<a aria-controls="home" aria-selected="true" class="nav-link active" data-bs-toggle="tab" href="#home"
id="home-tab" role="tab">Status</a>
</li>
<li class="nav-item" role="presentation">
<a aria-controls="accounts" aria-selected="false" class="nav-link" data-bs-toggle="tab" href="#accounts"
id="accounts-tab" role="tab">Accounts</a>
</li>
<li class="nav-item" role="presentation">
<a aria-controls="settings" aria-selected="false" class="nav-link" data-bs-toggle="tab" href="#settings"
id="settings-tab" role="tab">Settings</a>
</li>
<li class="nav-item dropdown">
<a aria-expanded="false" class="nav-link dropdown-toggle" data-bs-toggle="dropdown" href="#"
id="aboutDropdown" role="button">
About
</a>
<ul aria-labelledby="aboutDropdown" class="dropdown-menu dropdown-menu-dark">
<li><a class="dropdown-item" data-bs-toggle="modal" href="#aboutModal" role="tab">About
VIAaaS</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</nav>
<div class="container tab-content" id="content">
<div id="home" class="tab-pane fade show active" aria-labelledby="home-tab">
<p>WebSocket connection status: <span id="connection_status" class="text-white bg-dark">?</span></p>
<p>CORS Proxy status: <span id="cors_status" class="text-white bg-dark">?</span></p>
<hr>
<p><span id="actions"></span></p>
<p>Listening to logins from: <span id="listening"></span></p>
<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>
<p><span id="actions"></span></p>
<p>Listening to logins from: <span id="listening"></span></p>
</div>
<div id="settings" class="tab-pane fade" aria-labelledby="settings-tab">
<div aria-labelledby="settings-tab" class="tab-pane fade" id="settings">
<div class="mb-3">
<label for="cors-proxy" class="form-label">CORS Proxy URL Prefix</label>
<p>See <a href="https://github.com/ViaVersion/VIAaaS#cors-proxy">README</a>
for setting up one. Mojang APIs are called through this proxy, and a remote IP address may look suspicious and block your account.
It will receive sensitive data like email, passwords and tokens. HTTPS is required for non-localhost addresses.</p>
<input type="url" class="form-control" id="cors-proxy" placeholder="http://localhost:8080/">
<label class="form-label" for="cors-proxy">CORS Proxy URL Prefix</label>
<p>See <a href="https://github.com/ViaVersion/VIAaaS#cors-proxy">README</a>
for setting up one. Mojang APIs are called through this proxy, and a remote IP address may look
suspicious and block your account.
It will receive sensitive data like email, passwords and tokens. HTTPS is required for non-localhost
addresses.</p>
<input class="form-control" id="cors-proxy" placeholder="http://localhost:8080/" type="url">
</div>
<div class="mb-3">
<label for="ws-url" class="form-label">WebSocket URL</label>
<p>It exchanges sensitive data like minecraft.id tokens, server session hashes and usernames. WSS is required.</p>
<input type="url" class="form-control" id="ws-url" placeholder="wss://viaaas.example.com/ws">
<label class="form-label" for="ws-url">WebSocket URL</label>
<p>It exchanges sensitive data like minecraft.id tokens, server session hashes and usernames. WSS is
required.</p>
<input class="form-control" id="ws-url" placeholder="wss://viaaas.example.com/ws" type="url">
</div>
</div>
<div id="accounts" class="tab-pane fade" aria-labelledby="accounts-tab">
<div>
<p>Browser Minecraft accounts:</p>
<div id="accounts-list"></div>
<hr>
</div>
<div aria-labelledby="accounts-tab" class="tab-pane fade" id="accounts">
<div>
<p>Browser Minecraft accounts:</p>
<div id="accounts-list"></div>
<hr>
</div>
<div id="add-account">
<label for="form_add_ms" class="mb-3">Add Microsoft account:</label>
<form id="form_add_ms" class="row">
<div class="col-auto">
<button id="login_submit_ms" type="submit" class="btn btn-primary mb-3">Login with Microsoft</button>
</div>
<label class="mb-3" for="form_add_ms">Add Microsoft account:</label>
<form class="row" id="form_add_ms">
<div class="col-auto">
<button class="btn btn-primary mb-3" id="login_submit_ms" type="submit">Login with Microsoft
</button>
</div>
</form>
<label for="form_add_mc" class="mb-3">Add Mojang account:</label>
<form id="form_add_mc" class="row g-3">
<div class="col-auto">
<label for="email" class="visually-hidden">Username/Email</label>
<input type="text" id="email" name="email" class="form-control" placeholder="mc@example.com">
</div>
<div class="col-auto">
<label for="password" class="visually-hidden">Password</label>
<input type="password" id="password" name="password" class="form-control" placeholder="password">
</div>
<div class="col-auto">
<button id="login_submit_mc" type="submit" class="btn btn-primary mb-3">Login with Minecraft</button>
</div>
<label class="mb-3" for="form_add_mc">Add Mojang account:</label>
<form class="row g-3" id="form_add_mc">
<div class="col-auto">
<label class="visually-hidden" for="email">Username/Email</label>
<input class="form-control" id="email" name="email" placeholder="mc@example.com" type="text">
</div>
<div class="col-auto">
<label class="visually-hidden" for="password">Password</label>
<input class="form-control" id="password" name="password" placeholder="password" type="password">
</div>
<div class="col-auto">
<button class="btn btn-primary mb-3" id="login_submit_mc" type="submit">Login with Minecraft
</button>
</div>
</form>
</div>
</div>
</div>
<div class="modal fade" id="aboutModal" tabindex="-1" aria-labelledby="aboutModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="aboutModalLabel">About</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Copyright © 2020-2021 <a href="https://github.com/creeper123123321">creeper123123321</a></p>
<p>Copyright © 2021 <a href="https://github.com/ViaVersion/VIAaaS/graphs/contributors">contributors</a></p>
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
<p>This program 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 Affero General Public License for more details.</p>
<p>You should have received a copy of the GNU Affero General Public License along with this program. If not, see
<a href="https://gnu.org/licenses">http://www.gnu.org/licenses/</a>.</p>
</div>
<div class="modal-footer">
<a role="button" type="button" class="btn btn-secondary" href="https://github.com/ViaVersion/VIAaaS/">Source Code</a>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
<div aria-hidden="true" aria-labelledby="aboutModalLabel" class="modal fade" id="aboutModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="aboutModalLabel">About</h5>
<button aria-label="Close" class="btn-close" data-bs-dismiss="modal" type="button"></button>
</div>
<div class="modal-body">
<p>Copyright © 2020-2021 <a href="https://github.com/creeper123123321">creeper123123321</a></p>
<p>Copyright © 2021 <a href="https://github.com/ViaVersion/VIAaaS/graphs/contributors">contributors</a>
</p>
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU
Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your option) any later
version.</p>
<p>This program 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 Affero General Public License for
more details.</p>
<p>You should have received a copy of the GNU Affero General Public License along with this program. If
not, see
<a href="https://gnu.org/licenses">http://www.gnu.org/licenses/</a>.</p>
</div>
<div class="modal-footer">
<a class="btn btn-secondary" href="https://github.com/ViaVersion/VIAaaS/" role="button" type="button">Source
Code</a>
<button class="btn btn-primary" data-bs-dismiss="modal" type="button">Close</button>
</div>
</div>
</div>
</div>
</div>
<div class="toast-container position-absolute top-0 end-0 p-3" id="toasts"></div>