mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2025-02-19 02:11:50 +01:00
update via, fix address case
This commit is contained in:
parent
46f3df5c2e
commit
b47016626a
@ -57,8 +57,8 @@ dependencies {
|
||||
implementation(kotlin("stdlib-jdk8"))
|
||||
implementation(kotlin("reflect"))
|
||||
|
||||
val vvVer = "4.3.0-22w16b-SNAPSHOT"
|
||||
val vbVer = "4.3.0-22w16b-SNAPSHOT"
|
||||
val vvVer = "4.3.0-22w18a-SNAPSHOT"
|
||||
val vbVer = "4.3.0-22w18a-SNAPSHOT"
|
||||
val vrVer = "daa5e21"
|
||||
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
|
||||
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
|
||||
|
@ -1,13 +1,16 @@
|
||||
package com.viaversion.aas.codec.packet.login;
|
||||
|
||||
import com.viaversion.aas.codec.packet.Packet;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.StringType;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class LoginStart implements Packet {
|
||||
private String username;
|
||||
private CompoundTag publicKey;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
@ -20,10 +23,23 @@ public class LoginStart implements Packet {
|
||||
@Override
|
||||
public void decode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
|
||||
username = new StringType(16).read(byteBuf);
|
||||
if (protocolVersion >= ProtocolVersion.v1_19.getVersion()) {
|
||||
if (byteBuf.readBoolean()) {
|
||||
publicKey = Type.NBT.read(byteBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(@NotNull ByteBuf byteBuf, int protocolVersion) throws Exception {
|
||||
Type.STRING.write(byteBuf, username);
|
||||
if (protocolVersion >= ProtocolVersion.v1_19.getVersion()) {
|
||||
if (publicKey == null) {
|
||||
byteBuf.writeBoolean(false);
|
||||
} else {
|
||||
byteBuf.writeBoolean(true);
|
||||
Type.NBT.write(byteBuf, publicKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
src/main/java/com/viaversion/aas/type/AspirinTypes.java
Normal file
11
src/main/java/com/viaversion/aas/type/AspirinTypes.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.viaversion.aas.type;
|
||||
|
||||
import com.viaversion.aas.util.SignableProperty;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.ArrayType;
|
||||
|
||||
public enum AspirinTypes {;
|
||||
public static Type<String> OPTIONAL_STRING = new OptionalStringType();
|
||||
public static Type<SignableProperty> SIGNABLE_PROPERTY = new SignablePropertyType();
|
||||
public static Type<SignableProperty[]> SIGNABLE_PROPERTY_ARRAY = new ArrayType<>(SIGNABLE_PROPERTY);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.viaversion.aas.type;
|
||||
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class OptionalStringType extends Type<String> {
|
||||
protected OptionalStringType() {
|
||||
super(String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String read(ByteBuf buffer) throws Exception {
|
||||
return buffer.readBoolean() ? Type.STRING.read(buffer) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, String object) throws Exception {
|
||||
if (object == null) {
|
||||
buffer.writeBoolean(false);
|
||||
} else {
|
||||
buffer.writeBoolean(true);
|
||||
Type.STRING.write(buffer, object);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.viaversion.aas.type;
|
||||
|
||||
import com.viaversion.aas.util.SignableProperty;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
public class SignablePropertyType extends Type<SignableProperty> {
|
||||
protected SignablePropertyType() {
|
||||
super(SignableProperty.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SignableProperty read(ByteBuf buffer) throws Exception {
|
||||
String key = Type.STRING.read(buffer);
|
||||
String value = Type.STRING.read(buffer);
|
||||
String signature = AspirinTypes.OPTIONAL_STRING.read(buffer);
|
||||
return new SignableProperty(key, value, signature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf buffer, SignableProperty object) throws Exception {
|
||||
Type.STRING.write(buffer, object.getKey());
|
||||
Type.STRING.write(buffer, object.getValue());
|
||||
AspirinTypes.OPTIONAL_STRING.write(buffer, object.getSignature());
|
||||
}
|
||||
}
|
@ -21,7 +21,7 @@ public class AddressParser {
|
||||
String address = StringsKt.removeSuffix(rawAddress, ".");
|
||||
|
||||
String suffix = viaHostName.stream()
|
||||
.filter(s -> StringsKt.endsWith("." + address, s, true))
|
||||
.filter(s -> StringsKt.endsWith("." + address, s, false))
|
||||
.findAny()
|
||||
.orElse(null);
|
||||
|
||||
|
41
src/main/java/com/viaversion/aas/util/SignableProperty.java
Normal file
41
src/main/java/com/viaversion/aas/util/SignableProperty.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.viaversion.aas.util;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class SignableProperty {
|
||||
private String key;
|
||||
private String value;
|
||||
@Nullable
|
||||
private String signature;
|
||||
|
||||
public SignableProperty(String key, String value, @Nullable String signature) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public void setSignature(@Nullable String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ import com.viaversion.aas.codec.packet.status.StatusPing
|
||||
import com.viaversion.aas.codec.packet.status.StatusPong
|
||||
import com.viaversion.aas.codec.packet.status.StatusRequest
|
||||
import com.viaversion.aas.codec.packet.status.StatusResponse
|
||||
import com.viaversion.aas.protocol.sharewareVersion
|
||||
import com.viaversion.viaversion.api.protocol.packet.Direction
|
||||
import com.viaversion.viaversion.api.protocol.packet.State
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
|
||||
@ -21,6 +22,7 @@ import com.viaversion.viaversion.protocols.protocol1_16_2to1_16_1.ClientboundPac
|
||||
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_18to1_17_1.ClientboundPackets1_18
|
||||
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9
|
||||
import io.netty.buffer.ByteBuf
|
||||
@ -38,12 +40,23 @@ object PacketRegistry {
|
||||
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.SERVERBOUND, ::PluginResponse, sharewareVersion.singleton, 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.LOGIN, Direction.CLIENTBOUND, ::SetCompression, mapOf(
|
||||
Range.atLeast(ProtocolVersion.v1_8.version) to 3,
|
||||
sharewareVersion.singleton to 3
|
||||
)
|
||||
)
|
||||
register(
|
||||
State.LOGIN, Direction.CLIENTBOUND, ::PluginRequest, mapOf(
|
||||
Range.atLeast(ProtocolVersion.v1_13.version) to 4,
|
||||
sharewareVersion.singleton to 4
|
||||
)
|
||||
)
|
||||
|
||||
register(State.STATUS, Direction.SERVERBOUND, ::StatusRequest, Range.all(), 0)
|
||||
register(State.STATUS, Direction.SERVERBOUND, ::StatusPing, Range.all(), 1)
|
||||
@ -61,7 +74,8 @@ object PacketRegistry {
|
||||
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,
|
||||
ProtocolVersion.v1_17..ProtocolVersion.v1_17_1 to ClientboundPackets1_17.DISCONNECT.id,
|
||||
ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.DISCONNECT.id
|
||||
ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.DISCONNECT.id,
|
||||
ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.DISCONNECT.id
|
||||
)
|
||||
)
|
||||
|
||||
@ -75,7 +89,8 @@ object PacketRegistry {
|
||||
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,
|
||||
ProtocolVersion.v1_17..ProtocolVersion.v1_17_1 to ClientboundPackets1_17.PLUGIN_MESSAGE.id,
|
||||
ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.PLUGIN_MESSAGE.id
|
||||
ProtocolVersion.v1_18..ProtocolVersion.v1_18_2 to ClientboundPackets1_18.PLUGIN_MESSAGE.id,
|
||||
ProtocolVersion.v1_19.singleton to ClientboundPackets1_19.PLUGIN_MESSAGE.id
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -12,18 +12,18 @@ import java.security.spec.X509EncodedKeySpec
|
||||
class CryptoRequest : Packet {
|
||||
lateinit var serverId: String
|
||||
lateinit var publicKey: PublicKey
|
||||
lateinit var token: ByteArray
|
||||
lateinit var nonce: ByteArray
|
||||
|
||||
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
serverId = Type.STRING.read(byteBuf)
|
||||
if (protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1) {
|
||||
publicKey = KeyFactory.getInstance("RSA")
|
||||
.generatePublic(X509EncodedKeySpec(Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)))
|
||||
token = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
nonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
} else {
|
||||
publicKey = KeyFactory.getInstance("RSA")
|
||||
.generatePublic(X509EncodedKeySpec(byteBuf.readByteArray(byteBuf.readUnsignedShort())))
|
||||
token = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
nonce = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,13 +31,13 @@ class CryptoRequest : Packet {
|
||||
Type.STRING.write(byteBuf, serverId)
|
||||
if (protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1) {
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, publicKey.encoded)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, token)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, nonce)
|
||||
} else {
|
||||
val encodedKey = publicKey.encoded
|
||||
byteBuf.writeShort(encodedKey.size)
|
||||
byteBuf.writeBytes(encodedKey)
|
||||
byteBuf.writeShort(token.size)
|
||||
byteBuf.writeBytes(token)
|
||||
byteBuf.writeShort(nonce.size)
|
||||
byteBuf.writeBytes(nonce)
|
||||
}
|
||||
}
|
||||
}
|
@ -8,27 +8,55 @@ import io.netty.buffer.ByteBuf
|
||||
|
||||
class CryptoResponse : Packet {
|
||||
lateinit var encryptedKey: ByteArray
|
||||
lateinit var encryptedToken: ByteArray
|
||||
var encryptedNonce: ByteArray? = null
|
||||
var salt: Long? = null
|
||||
var signature: ByteArray? = null
|
||||
|
||||
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
if (protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1) {
|
||||
encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
encryptedToken = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
} else {
|
||||
encryptedKey = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
encryptedToken = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
when {
|
||||
protocolVersion >= ProtocolVersion.v1_19.version -> {
|
||||
encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
if (byteBuf.readBoolean()) {
|
||||
encryptedNonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
} else {
|
||||
salt = byteBuf.readLong()
|
||||
signature = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
}
|
||||
}
|
||||
protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1 -> {
|
||||
encryptedKey = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
encryptedNonce = Type.BYTE_ARRAY_PRIMITIVE.read(byteBuf)
|
||||
}
|
||||
else -> {
|
||||
encryptedKey = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
encryptedNonce = byteBuf.readByteArray(byteBuf.readUnsignedShort())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun encode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
if (protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1) {
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedToken)
|
||||
} else {
|
||||
byteBuf.writeShort(encryptedKey.size)
|
||||
byteBuf.writeBytes(encryptedKey)
|
||||
byteBuf.writeShort(encryptedToken.size)
|
||||
byteBuf.writeBytes(encryptedToken)
|
||||
when {
|
||||
protocolVersion >= ProtocolVersion.v1_19.version -> {
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey)
|
||||
if (encryptedNonce != null) {
|
||||
byteBuf.writeBoolean(true)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce)
|
||||
} else {
|
||||
byteBuf.writeBoolean(false)
|
||||
byteBuf.writeLong(salt!!)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, signature)
|
||||
}
|
||||
}
|
||||
protocolVersion >= ProtocolVersion.v1_8.version || protocolVersion == 1 -> {
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedKey)
|
||||
Type.BYTE_ARRAY_PRIMITIVE.write(byteBuf, encryptedNonce)
|
||||
}
|
||||
else -> {
|
||||
byteBuf.writeShort(encryptedKey.size)
|
||||
byteBuf.writeBytes(encryptedKey)
|
||||
byteBuf.writeShort(encryptedNonce!!.size)
|
||||
byteBuf.writeBytes(encryptedNonce)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package com.viaversion.aas.codec.packet.login
|
||||
|
||||
import com.viaversion.aas.codec.packet.Packet
|
||||
import com.viaversion.aas.parseUndashedId
|
||||
import com.viaversion.aas.type.AspirinTypes
|
||||
import com.viaversion.aas.util.SignableProperty
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion
|
||||
import com.viaversion.viaversion.api.type.Type
|
||||
import io.netty.buffer.ByteBuf
|
||||
@ -10,6 +12,7 @@ import java.util.*
|
||||
class LoginSuccess : Packet {
|
||||
lateinit var id: UUID
|
||||
lateinit var username: String
|
||||
val properties = mutableListOf<SignableProperty>()
|
||||
|
||||
override fun decode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
id = when {
|
||||
@ -22,6 +25,9 @@ class LoginSuccess : Packet {
|
||||
else -> parseUndashedId(Type.STRING.read(byteBuf))
|
||||
}
|
||||
username = Type.STRING.read(byteBuf)
|
||||
if (protocolVersion >= ProtocolVersion.v1_19.version) {
|
||||
properties.addAll(AspirinTypes.SIGNABLE_PROPERTY_ARRAY.read(byteBuf).asList())
|
||||
}
|
||||
}
|
||||
|
||||
override fun encode(byteBuf: ByteBuf, protocolVersion: Int) {
|
||||
@ -35,5 +41,8 @@ class LoginSuccess : Packet {
|
||||
else -> Type.STRING.write(byteBuf, id.toString().replace("-", ""))
|
||||
}
|
||||
Type.STRING.write(byteBuf, username)
|
||||
if (protocolVersion >= ProtocolVersion.v1_19.version) {
|
||||
AspirinTypes.SIGNABLE_PROPERTY_ARRAY.write(byteBuf, properties.toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ import java.util.concurrent.ThreadLocalRandom
|
||||
|
||||
class LoginState : ConnectionState {
|
||||
val callbackPlayerId = CompletableFuture<UUID>()
|
||||
lateinit var frontToken: ByteArray
|
||||
lateinit var frontNonce: ByteArray
|
||||
lateinit var frontServerId: String
|
||||
var frontOnline: Boolean? = null
|
||||
lateinit var frontName: String
|
||||
@ -84,15 +84,15 @@ class LoginState : ConnectionState {
|
||||
}
|
||||
|
||||
fun authenticateOnlineFront(frontChannel: Channel) {
|
||||
// We'll use non-vanilla server id, public key size and token size
|
||||
frontToken = generate128Bits()
|
||||
// We'll use non-vanilla server id, public key size and nonce size
|
||||
frontNonce = generate128Bits()
|
||||
frontServerId = generateServerId()
|
||||
|
||||
val cryptoRequest = CryptoRequest()
|
||||
cryptoRequest.serverId = frontServerId
|
||||
cryptoKey = AspirinServer.mcCryptoKey
|
||||
cryptoRequest.publicKey = cryptoKey.public
|
||||
cryptoRequest.token = frontToken
|
||||
cryptoRequest.nonce = frontNonce
|
||||
|
||||
send(frontChannel, cryptoRequest, true)
|
||||
}
|
||||
@ -141,7 +141,7 @@ class LoginState : ConnectionState {
|
||||
fun handleCryptoRequest(handler: MinecraftHandler, cryptoRequest: CryptoRequest) {
|
||||
val backServerId = cryptoRequest.serverId
|
||||
val backPublicKey = cryptoRequest.publicKey
|
||||
val backToken = cryptoRequest.token
|
||||
val backNonce = cryptoRequest.nonce
|
||||
|
||||
if (!callbackPlayerId.isDone) {
|
||||
authenticateOnlineFront(handler.data.frontChannel)
|
||||
@ -171,7 +171,7 @@ class LoginState : ConnectionState {
|
||||
|
||||
val cryptoResponse = CryptoResponse()
|
||||
cryptoResponse.encryptedKey = encryptRsa(backPublicKey, backKey)
|
||||
cryptoResponse.encryptedToken = encryptRsa(backPublicKey, backToken)
|
||||
cryptoResponse.encryptedNonce = encryptRsa(backPublicKey, backNonce)
|
||||
|
||||
forward(frontHandler, cryptoResponse, true)
|
||||
backChan.pipeline().addBefore("frame", "crypto", CryptoCodec(aesKey(backKey), aesKey(backKey)))
|
||||
@ -184,9 +184,12 @@ class LoginState : ConnectionState {
|
||||
fun handleCryptoResponse(handler: MinecraftHandler, cryptoResponse: CryptoResponse) {
|
||||
val frontHash = let {
|
||||
val frontKey = decryptRsa(cryptoKey.private, cryptoResponse.encryptedKey)
|
||||
val decryptedToken = decryptRsa(cryptoKey.private, cryptoResponse.encryptedToken)
|
||||
|
||||
if (!decryptedToken.contentEquals(frontToken)) throw StacklessException("Invalid verification token!")
|
||||
if (cryptoResponse.encryptedNonce != null) {
|
||||
val decryptedNonce = decryptRsa(cryptoKey.private, cryptoResponse.encryptedNonce!!)
|
||||
if (!decryptedNonce.contentEquals(frontNonce)) throw StacklessException("Invalid verification nonce!")
|
||||
} else {
|
||||
// todo handle rsa signature
|
||||
}
|
||||
|
||||
handler.data.frontChannel.pipeline()
|
||||
.addBefore("frame", "crypto", CryptoCodec(aesKey(frontKey), aesKey(frontKey)))
|
||||
|
@ -7,9 +7,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
|
||||
|
||||
val sharewareVersion = ProtocolVersion.register(1, "3D Shareware v1.34")
|
||||
fun registerAspirinProtocols() {
|
||||
Via.getManager().protocolManager.registerProtocol(Protocol1_8To1_7_6, ProtocolVersion.v1_8, ProtocolVersion.v1_7_6)
|
||||
// todo fix version checks
|
||||
val shareware = ProtocolVersion.register(1, "3D Shareware v1.34")
|
||||
Via.getManager().protocolManager.registerProtocol(ProtocolSharewareto1_14(), shareware, ProtocolVersion.v1_14)
|
||||
Via.getManager().protocolManager.registerProtocol(ProtocolSharewareto1_14(), sharewareVersion, ProtocolVersion.v1_14)
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ 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.util.SignableProperty
|
||||
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
|
||||
@ -103,12 +104,12 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
|
||||
packetWrapper.write(Type.UUID, uuid)
|
||||
val name = ChatColorUtil.stripColor(packetWrapper.read(Type.STRING)) //Name
|
||||
val dataCount = packetWrapper.read(Type.VAR_INT) //DataCunt
|
||||
val properties = ArrayList<Tablist.Property>()
|
||||
val properties = ArrayList<SignableProperty>()
|
||||
for (i in 0 until dataCount) {
|
||||
val key: String = packetWrapper.read(Type.STRING) //Name
|
||||
val value: String = packetWrapper.read(Type.STRING) //Value
|
||||
val signature: String = packetWrapper.read(Type.STRING) //Signature
|
||||
properties.add(Tablist.Property(key, value, signature))
|
||||
properties.add(SignableProperty(key, value, signature))
|
||||
}
|
||||
val x = packetWrapper.passthrough(Type.INT) //x
|
||||
val y = packetWrapper.passthrough(Type.INT) //y
|
||||
@ -148,7 +149,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
|
||||
packetPlayerListItem.write(Type.STRING, newentry.name)
|
||||
packetPlayerListItem.write(Type.VAR_INT, dataCount)
|
||||
for (property in newentry.properties) {
|
||||
packetPlayerListItem.write(Type.STRING, property.name)
|
||||
packetPlayerListItem.write(Type.STRING, property.key)
|
||||
packetPlayerListItem.write(Type.STRING, property.value)
|
||||
packetPlayerListItem.write(Type.BOOLEAN, property.signature != null)
|
||||
if (property.signature != null) packetPlayerListItem.write(Type.STRING, property.signature)
|
||||
@ -227,7 +228,7 @@ fun Protocol1_8To1_7_6.registerPlayerPackets() {
|
||||
packetWrapper.write(Type.STRING, entry.name)
|
||||
packetWrapper.write(Type.VAR_INT, entry.properties.size)
|
||||
for (property in entry.properties) {
|
||||
packetWrapper.write(Type.STRING, property.name)
|
||||
packetWrapper.write(Type.STRING, property.key)
|
||||
packetWrapper.write(Type.STRING, property.value)
|
||||
packetWrapper.write(Type.BOOLEAN, property.signature != null)
|
||||
if (property.signature != null) packetWrapper.write(Type.STRING, property.signature)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.viaversion.aas.protocol.id47toid5.storage
|
||||
|
||||
import com.viaversion.aas.util.SignableProperty
|
||||
import com.viaversion.viaversion.api.connection.StoredObject
|
||||
import com.viaversion.viaversion.api.connection.UserConnection
|
||||
import java.util.*
|
||||
@ -27,10 +28,9 @@ class Tablist(user: UserConnection?) : StoredObject(user) {
|
||||
class TabListEntry(var name: String, var uuid: UUID) {
|
||||
var displayName: String? = null
|
||||
var ping = 0
|
||||
var properties = mutableListOf<Property>()
|
||||
var properties = mutableListOf<SignableProperty>()
|
||||
}
|
||||
|
||||
class Property(var name: String?, var value: String?, var signature: String?)
|
||||
companion object {
|
||||
fun shouldUpdateDisplayName(oldName: String?, newName: String?): Boolean {
|
||||
return oldName == null && newName != null || oldName != null && newName == null || oldName != null && oldName != newName
|
||||
|
Loading…
Reference in New Issue
Block a user