mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 19:15:08 -05:00
Log play state disconnect messages
This commit is contained in:
parent
c9af00ed98
commit
f966a34c1a
3 changed files with 52 additions and 5 deletions
|
@ -242,6 +242,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<Packet> {
|
||||||
}
|
}
|
||||||
this.proxyConnection.getPacketHandlers().add(new CompressionPacketHandler(this.proxyConnection));
|
this.proxyConnection.getPacketHandlers().add(new CompressionPacketHandler(this.proxyConnection));
|
||||||
this.proxyConnection.getPacketHandlers().add(new LoginPacketHandler(this.proxyConnection));
|
this.proxyConnection.getPacketHandlers().add(new LoginPacketHandler(this.proxyConnection));
|
||||||
|
this.proxyConnection.getPacketHandlers().add(new DisconnectPacketHandler(this.proxyConnection));
|
||||||
if (clientVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
if (clientVersion.newerThanOrEqualTo(ProtocolVersion.v1_20_5)) {
|
||||||
this.proxyConnection.getPacketHandlers().add(new TransferPacketHandler(this.proxyConnection));
|
this.proxyConnection.getPacketHandlers().add(new TransferPacketHandler(this.proxyConnection));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/*
|
||||||
|
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
||||||
|
* Copyright (C) 2021-2024 RK_01/RaphiMC and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package net.raphimc.viaproxy.proxy.packethandler;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelFutureListener;
|
||||||
|
import net.raphimc.netminecraft.packet.Packet;
|
||||||
|
import net.raphimc.netminecraft.packet.impl.common.S2CDisconnectPacket;
|
||||||
|
import net.raphimc.netminecraft.packet.impl.login.S2CLoginDisconnectPacket;
|
||||||
|
import net.raphimc.viaproxy.cli.ConsoleFormatter;
|
||||||
|
import net.raphimc.viaproxy.proxy.session.ProxyConnection;
|
||||||
|
import net.raphimc.viaproxy.util.logging.Logger;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DisconnectPacketHandler extends PacketHandler {
|
||||||
|
|
||||||
|
public DisconnectPacketHandler(ProxyConnection proxyConnection) {
|
||||||
|
super(proxyConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) throws Exception {
|
||||||
|
if (packet instanceof S2CLoginDisconnectPacket loginDisconnectPacket) {
|
||||||
|
Logger.u_info("server disconnect", this.proxyConnection, ConsoleFormatter.convert(loginDisconnectPacket.reason.asLegacyFormatString()));
|
||||||
|
} else if (packet instanceof S2CDisconnectPacket disconnectPacket) {
|
||||||
|
Logger.u_info("server disconnect", this.proxyConnection, ConsoleFormatter.convert(disconnectPacket.reason.asLegacyFormatString()));
|
||||||
|
}
|
||||||
|
return super.handleP2S(packet, listeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -25,11 +25,13 @@ import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
import net.raphimc.netminecraft.netty.crypto.AESEncryption;
|
import net.raphimc.netminecraft.netty.crypto.AESEncryption;
|
||||||
import net.raphimc.netminecraft.netty.crypto.CryptUtil;
|
import net.raphimc.netminecraft.netty.crypto.CryptUtil;
|
||||||
import net.raphimc.netminecraft.packet.Packet;
|
import net.raphimc.netminecraft.packet.Packet;
|
||||||
import net.raphimc.netminecraft.packet.impl.login.*;
|
import net.raphimc.netminecraft.packet.impl.login.C2SLoginHelloPacket;
|
||||||
|
import net.raphimc.netminecraft.packet.impl.login.C2SLoginKeyPacket;
|
||||||
|
import net.raphimc.netminecraft.packet.impl.login.S2CLoginGameProfilePacket;
|
||||||
|
import net.raphimc.netminecraft.packet.impl.login.S2CLoginHelloPacket;
|
||||||
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
|
||||||
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
|
import net.raphimc.vialegacy.protocol.release.r1_6_4tor1_7_2_5.storage.ProtocolMetadataStorage;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.cli.ConsoleFormatter;
|
|
||||||
import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent;
|
import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent;
|
||||||
import net.raphimc.viaproxy.plugins.events.ShouldVerifyOnlineModeEvent;
|
import net.raphimc.viaproxy.plugins.events.ShouldVerifyOnlineModeEvent;
|
||||||
import net.raphimc.viaproxy.proxy.LoginState;
|
import net.raphimc.viaproxy.proxy.LoginState;
|
||||||
|
@ -138,9 +140,7 @@ public class LoginPacketHandler extends PacketHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) throws GeneralSecurityException, ExecutionException, InterruptedException {
|
public boolean handleP2S(Packet packet, List<ChannelFutureListener> listeners) throws GeneralSecurityException, ExecutionException, InterruptedException {
|
||||||
if (packet instanceof S2CLoginDisconnectPacket loginDisconnectPacket) {
|
if (packet instanceof S2CLoginHelloPacket loginHelloPacket) {
|
||||||
Logger.u_info("server kick", this.proxyConnection, ConsoleFormatter.convert(loginDisconnectPacket.reason.asLegacyFormatString()));
|
|
||||||
} else if (packet instanceof S2CLoginHelloPacket loginHelloPacket) {
|
|
||||||
final PublicKey publicKey = CryptUtil.decodeRsaPublicKey(loginHelloPacket.publicKey);
|
final PublicKey publicKey = CryptUtil.decodeRsaPublicKey(loginHelloPacket.publicKey);
|
||||||
final SecretKey secretKey = CryptUtil.generateSecretKey();
|
final SecretKey secretKey = CryptUtil.generateSecretKey();
|
||||||
final String serverHash = new BigInteger(CryptUtil.computeServerIdHash(loginHelloPacket.serverId, publicKey, secretKey)).toString(16);
|
final String serverHash = new BigInteger(CryptUtil.computeServerIdHash(loginHelloPacket.serverId, publicKey, secretKey)).toString(16);
|
||||||
|
|
Loading…
Reference in a new issue