mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-02-09 12:32:56 +08:00
Remove banned packets
client modifications already perform the job of blocking malicious packets from being executed, no point in having this if self-windy is wanted
This commit is contained in:
parent
5605163607
commit
f6326d6e4b
@ -12,8 +12,6 @@ import java.util.TreeMap;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PacketOpcodesUtils {
|
public class PacketOpcodesUtils {
|
||||||
public static final Set<Integer> BANNED_PACKETS =
|
|
||||||
Set.of(PacketOpcodes.WindSeedClientNotify, PacketOpcodes.PlayerLuaShellNotify);
|
|
||||||
public static final Set<Integer> LOOP_PACKETS =
|
public static final Set<Integer> LOOP_PACKETS =
|
||||||
Set.of(
|
Set.of(
|
||||||
PacketOpcodes.PingReq,
|
PacketOpcodes.PingReq,
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package emu.grasscutter.server.game;
|
package emu.grasscutter.server.game;
|
||||||
|
|
||||||
import static emu.grasscutter.config.Configuration.GAME_INFO;
|
|
||||||
import static emu.grasscutter.config.Configuration.SERVER;
|
|
||||||
import static emu.grasscutter.utils.Language.translate;
|
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.Grasscutter.ServerDebugMode;
|
import emu.grasscutter.Grasscutter.ServerDebugMode;
|
||||||
import emu.grasscutter.game.Account;
|
import emu.grasscutter.game.Account;
|
||||||
@ -17,11 +13,16 @@ import emu.grasscutter.utils.FileUtils;
|
|||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import static emu.grasscutter.config.Configuration.GAME_INFO;
|
||||||
|
import static emu.grasscutter.config.Configuration.SERVER;
|
||||||
|
import static emu.grasscutter.utils.Language.translate;
|
||||||
|
|
||||||
public class GameSession implements GameSessionManager.KcpChannel {
|
public class GameSession implements GameSessionManager.KcpChannel {
|
||||||
private final GameServer server;
|
private final GameServer server;
|
||||||
@ -109,13 +110,6 @@ public class GameSession implements GameSessionManager.KcpChannel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DO NOT REMOVE (unless we find a way to validate code before sending to client which I don't
|
|
||||||
// think we can)
|
|
||||||
// Stop WindSeedClientNotify from being sent for security purposes.
|
|
||||||
if (PacketOpcodesUtils.BANNED_PACKETS.contains(packet.getOpcode())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
if (packet.shouldBuildHeader()) {
|
if (packet.shouldBuildHeader()) {
|
||||||
packet.buildHeader(this.getNextClientSequence());
|
packet.buildHeader(this.getNextClientSequence());
|
||||||
|
@ -3,19 +3,21 @@ package emu.grasscutter.server.packet.send;
|
|||||||
import com.google.protobuf.ByteString;
|
import com.google.protobuf.ByteString;
|
||||||
import emu.grasscutter.net.packet.BasePacket;
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.WindSeedClientNotifyOuterClass.WindSeedClientNotify;
|
import emu.grasscutter.net.proto.WindSeedType1NotifyOuterClass.WindSeedType1Notify;
|
||||||
import emu.grasscutter.net.proto.WindSeedClientNotifyOuterClass.WindSeedClientNotify.AreaNotify;
|
|
||||||
|
|
||||||
public final class PacketWindSeedClientNotify extends BasePacket {
|
public final class PacketWindSeedClientNotify extends BasePacket {
|
||||||
|
/**
|
||||||
|
* Constructor for the generic WindSeedClientNotify packet.
|
||||||
|
*
|
||||||
|
* @param compiledLua The compiled Lua to send to the client.
|
||||||
|
*/
|
||||||
public PacketWindSeedClientNotify(byte[] compiledLua) {
|
public PacketWindSeedClientNotify(byte[] compiledLua) {
|
||||||
super(PacketOpcodes.WindSeedClientNotify);
|
super(PacketOpcodes.WindSeedType1Notify);
|
||||||
|
|
||||||
this.setData(
|
var packet = WindSeedType1Notify.newBuilder()
|
||||||
WindSeedClientNotify.newBuilder()
|
.setPayload(ByteString.copyFrom(compiledLua))
|
||||||
.setAreaNotify(
|
.build();
|
||||||
AreaNotify.newBuilder()
|
|
||||||
.setAreaId(1)
|
this.setData(packet);
|
||||||
.setAreaType(1)
|
|
||||||
.setAreaCode(ByteString.copyFrom(compiledLua))));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user