From a97a6a78e22e212eb3b7a889f8b3cbdfbabcdd61 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 11 Jun 2022 08:55:51 +0200 Subject: [PATCH] Fix Remote Plugin Messages --- .../bungeecore/network/NetworkReceiver.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/de/steamwar/bungeecore/network/NetworkReceiver.java b/src/de/steamwar/bungeecore/network/NetworkReceiver.java index a023a92..c0818f4 100644 --- a/src/de/steamwar/bungeecore/network/NetworkReceiver.java +++ b/src/de/steamwar/bungeecore/network/NetworkReceiver.java @@ -1,5 +1,6 @@ package de.steamwar.bungeecore.network; +import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.network.packets.NetworkPacket; import net.md_5.bungee.api.config.ServerInfo; @@ -7,12 +8,25 @@ import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; +import java.net.InetSocketAddress; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; + public class NetworkReceiver extends BasicListener { + private static final List blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge"); + private static final List allowedAddresses = Arrays.asList("localhost", "127.0.0.1", "0.0.0.0"); + public static ServerInfo sender; @EventHandler public void onPluginMessage(PluginMessageEvent event) { + if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) { + BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag()); + event.setCancelled(true); + return; + } if(!event.getTag().equalsIgnoreCase("sw:bridge")) return;