Added support for bukkit plugins to retrieve player IPs, domains, and run bungeecord commands
This commit is contained in:
parent
07b6e8a771
commit
05e929cf06
|
@ -26,14 +26,6 @@ public interface ConfigurationAdapter {
|
|||
|
||||
Collection<String> getBlacklistURLs();
|
||||
|
||||
boolean getBlacklistOfflineDownload();
|
||||
|
||||
boolean getBlacklistReplits();
|
||||
|
||||
boolean getBlacklistOriginless();
|
||||
|
||||
boolean getSimpleWhitelistEnabled();
|
||||
|
||||
Collection<String> getBlacklistSimpleWhitelist();
|
||||
|
||||
AuthServiceInfo getAuthSettings();
|
||||
|
|
|
@ -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");
|
||||
|
@ -109,4 +119,24 @@ public class Configuration {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,9 +204,15 @@ public class DownstreamBridge extends PacketHandler {
|
|||
}
|
||||
if (subChannel.equals("IP")) {
|
||||
out.writeUTF("IP");
|
||||
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();
|
||||
out.writeUTF("PlayerCount");
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user