SteamWar/BungeeCore
Archiviert
13
2

Fix communication
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-06-14 09:32:43 +02:00
Ursprung b285585608
Commit 7aadaa2df3
3 geänderte Dateien mit 6 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.commands.*;
import de.steamwar.bungeecore.listeners.*; import de.steamwar.bungeecore.listeners.*;
import de.steamwar.bungeecore.listeners.mods.*; import de.steamwar.bungeecore.listeners.mods.*;
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.network.NetworkReceiver;
import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.sql.*;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
@ -157,6 +158,7 @@ public class BungeeCore extends Plugin {
new EventStarter(); new EventStarter();
new SessionManager(); new SessionManager();
new NetworkReceiver(); new NetworkReceiver();
BungeeNetworkHandler.register();
new TablistManager(); new TablistManager();
new SettingsChangedListener(); new SettingsChangedListener();

Datei anzeigen

@ -25,9 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.sql.*;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import io.netty.channel.ConnectTimeoutException;
import net.md_5.bungee.BungeeCord; 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.ChatColor;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
@ -660,7 +658,7 @@ public class TeamCommand extends BasicCommand {
Message.send("TEAM_SERVER_SET", player); 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 // Check if the address is a valid special local or loop back
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
return true; return true;

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.bungeecore.network; package de.steamwar.bungeecore.network;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.commands.TeamCommand;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.NetworkPacket; import de.steamwar.network.packets.NetworkPacket;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
@ -36,18 +37,17 @@ import java.util.logging.Level;
public class NetworkReceiver extends BasicListener { public class NetworkReceiver extends BasicListener {
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge"); 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; public static ServerInfo sender;
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public synchronized void onPluginMessage(PluginMessageEvent event) { 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()); BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag());
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if(!event.getTag().equalsIgnoreCase("sw:bridge")) if(!event.getTag().equals("sw:bridge"))
return; return;
event.setCancelled(true); event.setCancelled(true);