Skip to content

Commit

Permalink
Added support for 23w44a clients
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphiMC committed Nov 2, 2023
1 parent 368e86d commit fd05568
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
19 changes: 10 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ dependencies {
exclude group: "com.google.guava", module: "guava"
}
include "com.viaversion:viarewind-common:3.0.3-SNAPSHOT"
include "net.raphimc:ViaLegacy:2.2.21-SNAPSHOT"
include("net.raphimc:ViaLegacy:2.2.21-SNAPSHOT") {
exclude group: "net.lenni0451.mcstructs", module: "text"
}
include "net.raphimc:ViaAprilFools:2.0.10-SNAPSHOT"
include("net.raphimc:ViaBedrock:0.0.3-SNAPSHOT") {
exclude group: "io.netty", module: "netty-codec-http"
exclude group: "io.jsonwebtoken", module: "jjwt-impl"
exclude group: "io.jsonwebtoken", module: "jjwt-gson"
exclude group: "io.netty"
exclude group: "io.jsonwebtoken"
exclude group: "net.lenni0451.mcstructs", module: "text"
}
include("net.raphimc:ViaLoader:2.2.11-SNAPSHOT") {
exclude group: "org.slf4j", module: "slf4j-api"
Expand All @@ -88,7 +90,9 @@ dependencies {
include "net.lenni0451.classtransform:additionalclassprovider:1.11.0"
include "net.lenni0451:Reflect:1.3.0"
include "net.lenni0451:LambdaEvents:2.3.2"
include "net.raphimc.netminecraft:all:2.3.7-SNAPSHOT"
include("net.raphimc.netminecraft:all:2.3.7-SNAPSHOT") {
exclude group: "com.google.code.gson", module: "gson"
}
include("net.raphimc:MinecraftAuth:2.1.7-SNAPSHOT") {
exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.slf4j", module: "slf4j-api"
Expand All @@ -98,10 +102,7 @@ dependencies {
exclude group: "net.lenni0451.classtransform", module: "additionalclassprovider"
}
include("org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT") {
exclude group: "io.netty", module: "netty-common"
exclude group: "io.netty", module: "netty-buffer"
exclude group: "io.netty", module: "netty-codec"
exclude group: "io.netty", module: "netty-transport"
exclude group: "io.netty"
}
include "gs.mclo:api:3.0.1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.cli.ConsoleFormatter;
import net.raphimc.viaproxy.cli.options.Options;
import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent;
import net.raphimc.viaproxy.plugins.events.ShouldVerifyOnlineModeEvent;
Expand Down Expand Up @@ -149,7 +150,9 @@ public boolean handleC2P(IPacket packet, List<ChannelFutureListener> listeners)

@Override
public boolean handleP2S(IPacket packet, List<ChannelFutureListener> listeners) throws GeneralSecurityException, ExecutionException, InterruptedException {
if (packet instanceof S2CLoginKeyPacket1_7 loginKeyPacket) {
if (packet instanceof S2CLoginDisconnectPacket1_7 loginDisconnectPacket) {
Logger.u_info("server kick", this.proxyConnection.getC2P().remoteAddress(), this.proxyConnection.getGameProfile(), ConsoleFormatter.convert(loginDisconnectPacket.reason.asLegacyFormatString()));
} else if (packet instanceof S2CLoginKeyPacket1_7 loginKeyPacket) {
final PublicKey publicKey = CryptUtil.decodeRsaPublicKey(loginKeyPacket.publicKey);
final SecretKey secretKey = CryptUtil.generateSecretKey();
final String serverHash = new BigInteger(CryptUtil.computeServerIdHash(loginKeyPacket.serverId, publicKey, secretKey)).toString(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.netty.buffer.Unpooled;
import io.netty.channel.*;
import io.netty.util.AttributeKey;
import net.lenni0451.mcstructs.text.components.StringComponent;
import net.raphimc.netminecraft.constants.ConnectionState;
import net.raphimc.netminecraft.constants.MCPackets;
import net.raphimc.netminecraft.constants.MCPipeline;
Expand All @@ -35,11 +36,12 @@
import net.raphimc.netminecraft.packet.PacketTypes;
import net.raphimc.netminecraft.packet.impl.login.C2SLoginHelloPacket1_7;
import net.raphimc.netminecraft.packet.impl.login.S2CLoginCustomPayloadPacket;
import net.raphimc.netminecraft.packet.impl.login.S2CLoginDisconnectPacket;
import net.raphimc.netminecraft.packet.impl.login.S2CLoginDisconnectPacket1_20_3;
import net.raphimc.netminecraft.packet.impl.status.S2CStatusResponsePacket;
import net.raphimc.netminecraft.packet.registry.PacketRegistryUtil;
import net.raphimc.netminecraft.util.ServerAddress;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.viaproxy.cli.ConsoleFormatter;
import net.raphimc.viaproxy.proxy.external_interface.OpenAuthModConstants;
import net.raphimc.viaproxy.proxy.packethandler.PacketHandler;
import net.raphimc.viaproxy.proxy.util.CloseAndReturn;
Expand Down Expand Up @@ -247,7 +249,7 @@ public CompletableFuture<ByteBuf> sendCustomPayload(final String channel, final
PacketTypes.writeString(disconnectPacketData, channel);
PacketTypes.writeVarInt(disconnectPacketData, id);
disconnectPacketData.writeBytes(data);
this.c2p.writeAndFlush(new S2CLoginDisconnectPacket(messageToJson("§cYou need to install OpenAuthMod in order to join this server.§k\n" + Base64.getEncoder().encodeToString(ByteBufUtil.getBytes(disconnectPacketData)) + "\n" + OpenAuthModConstants.LEGACY_MAGIC_STRING))).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
this.c2p.writeAndFlush(new S2CLoginDisconnectPacket1_20_3(new StringComponent("§cYou need to install OpenAuthMod in order to join this server.§k\n" + Base64.getEncoder().encodeToString(ByteBufUtil.getBytes(disconnectPacketData)) + "\n" + OpenAuthModConstants.LEGACY_MAGIC_STRING))).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
}
break;
case PLAY:
Expand Down Expand Up @@ -275,13 +277,13 @@ public boolean handleCustomPayload(final int id, final ByteBuf data) {
}

public void kickClient(final String message) throws CloseAndReturn {
Logger.u_err("kick", this.c2p.remoteAddress(), this.getGameProfile(), message.replaceAll("§.", ""));
Logger.u_err("proxy kick", this.c2p.remoteAddress(), this.getGameProfile(), ConsoleFormatter.convert(message));

final ChannelFuture future;
if (this.c2pConnectionState == ConnectionState.STATUS) {
future = this.c2p.writeAndFlush(new S2CStatusResponsePacket("{\"players\":{\"max\":0,\"online\":0},\"description\":" + new JsonPrimitive(message) + ",\"version\":{\"protocol\":-1,\"name\":\"ViaProxy\"}}"));
} else if (this.c2pConnectionState == ConnectionState.LOGIN) {
future = this.c2p.writeAndFlush(new S2CLoginDisconnectPacket(messageToJson(message)));
future = this.c2p.writeAndFlush(new S2CLoginDisconnectPacket1_20_3(new StringComponent(message)));
} else if (this.c2pConnectionState == ConnectionState.CONFIGURATION) {
final ByteBuf disconnectPacket = Unpooled.buffer();
PacketTypes.writeVarInt(disconnectPacket, MCPackets.S2C_CONFIG_DISCONNECT.getId(this.clientVersion.getVersion()));
Expand Down

0 comments on commit fd05568

Please sign in to comment.