geforkt von SteamWar/BungeeCore
Fix communication
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
b285585608
Commit
7aadaa2df3
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.*;
|
||||
import de.steamwar.bungeecore.listeners.*;
|
||||
import de.steamwar.bungeecore.listeners.mods.*;
|
||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
@ -157,6 +158,7 @@ public class BungeeCore extends Plugin {
|
||||
new EventStarter();
|
||||
new SessionManager();
|
||||
new NetworkReceiver();
|
||||
BungeeNetworkHandler.register();
|
||||
new TablistManager();
|
||||
new SettingsChangedListener();
|
||||
|
||||
|
@ -25,9 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||
import de.steamwar.bungeecore.sql.*;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import io.netty.channel.ConnectTimeoutException;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -660,7 +658,7 @@ public class TeamCommand extends BasicCommand {
|
||||
Message.send("TEAM_SERVER_SET", player);
|
||||
}
|
||||
|
||||
private static boolean isLocalhost(InetAddress addr) {
|
||||
public static boolean isLocalhost(InetAddress addr) {
|
||||
// Check if the address is a valid special local or loop back
|
||||
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
|
||||
return true;
|
||||
|
@ -20,6 +20,7 @@
|
||||
package de.steamwar.bungeecore.network;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||
import de.steamwar.network.packets.NetworkPacket;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@ -36,18 +37,17 @@ import java.util.logging.Level;
|
||||
public class NetworkReceiver extends BasicListener {
|
||||
|
||||
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
|
||||
private static final List<String> allowedAddresses = Arrays.asList("localhost", "127.0.0.1", "0.0.0.0");
|
||||
|
||||
public static ServerInfo sender;
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public synchronized void onPluginMessage(PluginMessageEvent event) {
|
||||
if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) {
|
||||
if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) {
|
||||
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"))
|
||||
if(!event.getTag().equals("sw:bridge"))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren