Added support for bukkit plugins to retrieve player IPs, domains, and run bungeecord commands

This commit is contained in:
LAX1DUDE 2022-06-26 01:44:34 -07:00
parent 07b6e8a771
commit 05e929cf06
9 changed files with 70 additions and 38 deletions

View File

@ -25,14 +25,6 @@ public interface ConfigurationAdapter {
Collection<String> getPermissions(final String p0);
Collection<String> getBlacklistURLs();
boolean getBlacklistOfflineDownload();
boolean getBlacklistReplits();
boolean getBlacklistOriginless();
boolean getSimpleWhitelistEnabled();
Collection<String> getBlacklistSimpleWhitelist();

View File

@ -27,6 +27,11 @@ public class Configuration {
private int playerLimit;
private String name;
private boolean showBanType;
private boolean blacklistOfflineDownload;
private boolean blacklistReplits;
private boolean blacklistOriginless;
private boolean simpleWhitelistEnabled;
private boolean acceptBukkitConsoleCommandPacket;
public Configuration() {
this.timeout = 30000;
@ -53,6 +58,11 @@ public class Configuration {
this.playerLimit = adapter.getInt("player_limit", this.playerLimit);
this.name = adapter.getString("server_name", EaglercraftBungee.name + " Server");
this.showBanType = adapter.getBoolean("display_ban_type_on_kick", false);
this.blacklistOfflineDownload = adapter.getBoolean("origin_blacklist_block_offline_download", false);
this.blacklistReplits = adapter.getBoolean("origin_blacklist_block_replit_clients", false);
this.blacklistOriginless = adapter.getBoolean("origin_blacklist_block_missing_origin_header", false);
this.simpleWhitelistEnabled = adapter.getBoolean("origin_blacklist_use_simple_whitelist", false);
this.acceptBukkitConsoleCommandPacket = adapter.getBoolean("accept_bukkit_console_command_packets", false);
Preconditions.checkArgument(this.listeners != null && !this.listeners.isEmpty(), (Object) "No listeners defined.");
final Map<String, ServerInfo> newServers = adapter.getServers();
Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), (Object) "No servers defined");
@ -108,5 +118,25 @@ public class Configuration {
public boolean shouldShowBanType() {
return this.showBanType;
}
public boolean shouldBlacklistOfflineDownload() {
return blacklistOfflineDownload;
}
public boolean shouldBlacklistReplits() {
return blacklistReplits;
}
public boolean shouldBlacklistOriginless() {
return blacklistOriginless;
}
public boolean isSimpleWhitelistEnabled() {
return simpleWhitelistEnabled;
}
public boolean shouldAcceptBukkitConsoleCommandPacket() {
return acceptBukkitConsoleCommandPacket;
}
}

View File

@ -17,7 +17,6 @@ import net.md_5.bungee.api.config.MOTDCacheConfiguration;
import java.util.Collection;
import java.net.InetSocketAddress;
import java.util.Iterator;
import net.md_5.bungee.Util;
import net.md_5.bungee.api.config.ServerInfo;
import java.util.logging.Level;
@ -305,26 +304,6 @@ public class YamlConfig implements ConfigurationAdapter {
return c;
}
@Override
public boolean getBlacklistOfflineDownload() {
return this.getBoolean("origin_blacklist_block_offline_download", false);
}
@Override
public boolean getBlacklistReplits() {
return this.getBoolean("origin_blacklist_block_replit_clients", false);
}
@Override
public boolean getBlacklistOriginless() {
return this.getBoolean("origin_blacklist_block_missing_origin_header", false);
}
@Override
public boolean getSimpleWhitelistEnabled() {
return this.getBoolean("origin_blacklist_use_simple_whitelist", false);
}
@Override
public Collection<String> getBlacklistSimpleWhitelist() {
Collection<String> c = this.get("origin_blacklist_simple_whitelist", null);

View File

@ -5,6 +5,8 @@
package net.md_5.bungee.connection;
import java.beans.ConstructorProperties;
import java.net.InetAddress;
import net.md_5.bungee.api.event.ServerKickEvent;
import java.util.Objects;
import net.md_5.bungee.protocol.packet.PacketFFKick;
@ -27,6 +29,7 @@ import net.md_5.bungee.api.score.Objective;
import net.md_5.bungee.protocol.packet.PacketCEScoreboardObjective;
import net.md_5.bungee.protocol.packet.PacketC9PlayerListItem;
import net.md_5.bungee.protocol.packet.Packet0KeepAlive;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.EntityMap;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.netty.ChannelWrapper;
@ -201,8 +204,14 @@ public class DownstreamBridge extends PacketHandler {
}
if (subChannel.equals("IP")) {
out.writeUTF("IP");
out.writeUTF(this.con.getAddress().getHostString());
out.writeInt(this.con.getAddress().getPort());
Object ob = this.con.getAttachment().get("remoteAddr");
if(ob != null && (ob instanceof InetAddress)) {
out.writeUTF(((InetAddress)ob).getHostAddress());
out.writeInt(this.con.getAddress().getPort());
}else {
out.writeUTF(this.con.getAddress().getHostString());
out.writeInt(this.con.getAddress().getPort());
}
}
if (subChannel.equals("PlayerCount")) {
final String target = in.readUTF();
@ -246,6 +255,26 @@ public class DownstreamBridge extends PacketHandler {
out.writeUTF("GetServer");
out.writeUTF(this.server.getInfo().getName());
}
if (subChannel.equals("EAG|GetDomain")) {
out.writeUTF("EAG|GetDomain");
Object ob = this.con.getAttachment().get("origin");
if(ob != null && (ob instanceof String)) {
out.writeBoolean(true);
out.writeUTF((String)ob);
}else {
out.writeBoolean(false);
out.writeUTF("");
}
}
if (subChannel.equals("EAG|ConsoleCommand")) {
if(BungeeCord.getInstance().config.shouldAcceptBukkitConsoleCommandPacket()) {
String cmd = in.readUTF();
bungee.getLogger().info("Connection [" + this.con.getName() + "] <-> [" + this.server.getInfo().getName() + "] executed bungee console command: " + cmd);
bungee.getPluginManager().dispatchCommand(bungee.getConsole(), cmd);
}else {
bungee.getLogger().info("Connection [" + this.con.getName() + "] <-> [" + this.server.getInfo().getName() + "] tried executing a bungee console command but \"accept_bukkit_console_command_packets\" is set to false in config.yml");
}
}
if (out != null) {
final byte[] b = out.toByteArray();
if (b.length != 0) {

View File

@ -20,6 +20,7 @@ import java.util.regex.PatternSyntaxException;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.config.ConfigurationAdapter;
import net.md_5.bungee.config.Configuration;
public class DomainBlacklist {
@ -108,12 +109,13 @@ public class DomainBlacklist {
regexLocalBlacklist.clear();
regexBlacklistReplit.clear();
simpleWhitelist.clear();
ConfigurationAdapter cfg = bg.getConfigurationAdapter();
blacklistSubscriptions = cfg.getBlacklistURLs();
blockOfflineDownload = cfg.getBlacklistOfflineDownload();
blockAllReplits = cfg.getBlacklistReplits();
simpleWhitelistMode = cfg.getSimpleWhitelistEnabled();
simpleWhitelist.addAll(cfg.getBlacklistSimpleWhitelist());
ConfigurationAdapter cfg2 = bg.getConfigurationAdapter();
Configuration cfg = bg.config;
blacklistSubscriptions = cfg2.getBlacklistURLs();
blockOfflineDownload = cfg.shouldBlacklistOfflineDownload();
blockAllReplits = cfg.shouldBlacklistReplits();
simpleWhitelistMode = cfg.isSimpleWhitelistEnabled();
simpleWhitelist.addAll(cfg2.getBlacklistSimpleWhitelist());
lastLocalUpdate = 0l;
lastUpdate = System.currentTimeMillis() - updateRate - 1000l;
update();

View File

@ -58,7 +58,7 @@ public class WebSocketListener extends WebSocketServer {
this.info = info;
this.bungeeProxy = sock;
this.bungeeCord = bungeeCord;
this.blockOriginless = bungeeCord.getConfigurationAdapter().getBlacklistOriginless();
this.blockOriginless = ((BungeeCord)bungeeCord).config.shouldBlacklistOriginless();
this.ratelimitIP = info.getRateLimitIP();
this.ratelimitLogin = info.getRateLimitLogin();
this.ratelimitMOTD = info.getRateLimitMOTD();