Updated Source

This commit is contained in:
Juan Cruz Linsalata 2020-09-03 19:54:11 -03:00
parent e80b925ba6
commit 083dd1ec02
3 changed files with 465 additions and 3 deletions

View File

@ -1,4 +1,4 @@
From 0a9c85a009d2615d08941c87d2bd01033e8d4273 Mon Sep 17 00:00:00 2001
From e8604a4c597b305d1484d4240c76c6ec5f7af37b Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Sat, 15 Aug 2020 15:19:22 -0300
Subject: [PATCH] FlameCord Initial Patch
@ -3347,7 +3347,7 @@ index e860214f..9f008a31 100644
// Throttling options
tabThrottle = config.getInt("throttling.tab_complete", tabThrottle);
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index a17ed68e..7a70948d 100644
index a17ed68e..d6d4cd6e 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -1,33 +1,10 @@
@ -4107,7 +4107,7 @@ index a17ed68e..7a70948d 100644
+ * return (BungeeCord.class.getPackage().getImplementationVersion() == null) ?
+ * "unknown" : BungeeCord.class.getPackage().getImplementationVersion();
+ */
+ return "0.3.9";
+ return "0.4.0";
+ }
+
+ public void reloadMessages() {

View File

@ -0,0 +1,173 @@
From 949366cf4d86f210fa406e98c0e48fbbef9eca54 Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Thu, 3 Sep 2020 18:37:43 -0300
Subject: [PATCH] FlameCord Whitelist servers addresses
diff --git a/flamecord/.factorypath b/flamecord/.factorypath
index f398f41e..ed4e646c 100644
--- a/flamecord/.factorypath
+++ b/flamecord/.factorypath
@@ -1,4 +1,5 @@
<factorypath>
+ <factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/guava/guava/21.0/guava-21.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/google/code/findbugs/findbugs-annotations/3.0.1/findbugs-annotations-3.0.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/projectlombok/lombok/1.18.10/lombok-1.18.10.jar" enabled="true" runInBatchMode="false"/>
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
index 3a7f56ee..29c1573a 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/FlameCord.java
@@ -1,5 +1,6 @@
package dev._2lstudios.flamecord;
+import java.util.Collection;
import java.util.logging.Logger;
import dev._2lstudios.flamecord.configuration.FlameCordConfiguration;
@@ -21,21 +22,25 @@ public class FlameCord {
private final ModulesConfiguration modulesConfiguration;
@Getter
private final MessagesConfiguration messagesConfiguration;
+ @Getter
private final Thread thread;
- public static void renew(final Logger logger) {
+ public static void renew(final Logger logger, final Collection<String> whitelistedAddresses) {
if (FlameCord.instance != null) {
FlameCord.instance.thread.interrupt();
}
- FlameCord.instance = new FlameCord(logger);
+ final FlameCord instance = new FlameCord(logger, whitelistedAddresses);
+
+ FlameCord.instance = instance;
}
- private FlameCord(final Logger logger) {
- final ConfigurationProvider configurationProvider = YamlConfiguration.getProvider(YamlConfiguration.class);
+ private FlameCord(final Logger logger, final Collection<String> whitelistedAddresses) {
+ final ConfigurationProvider configurationProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
this.flameCordConfiguration = new FlameCordConfiguration(configurationProvider);
- this.firewallManager = new FirewallManager(logger, flameCordConfiguration.getFirewallSeconds());
+ this.firewallManager = new FirewallManager(logger, whitelistedAddresses,
+ flameCordConfiguration.getFirewallSeconds());
this.modulesConfiguration = new ModulesConfiguration(configurationProvider);
this.messagesConfiguration = new MessagesConfiguration(logger, configurationProvider);
this.thread = new Thread() {
diff --git a/flamecord/src/main/java/dev/_2lstudios/flamecord/firewall/FirewallManager.java b/flamecord/src/main/java/dev/_2lstudios/flamecord/firewall/FirewallManager.java
index a90c8426..8a474758 100644
--- a/flamecord/src/main/java/dev/_2lstudios/flamecord/firewall/FirewallManager.java
+++ b/flamecord/src/main/java/dev/_2lstudios/flamecord/firewall/FirewallManager.java
@@ -12,20 +12,35 @@ import lombok.Getter;
public class FirewallManager {
private final Logger logger;
+ private final Collection<String> whitelistedAddresses;
private final Collection<String> firewalled;
private final int defaultSeconds;
@Getter
private int seconds;
- public FirewallManager(final Logger logger, final int defaultSeconds) {
+ public FirewallManager(final Logger logger, final Collection<String> whitelistedAddresses,
+ final int defaultSeconds) {
this.logger = logger;
+ this.whitelistedAddresses = whitelistedAddresses;
this.firewalled = new HashSet<>();
this.defaultSeconds = defaultSeconds;
this.seconds = defaultSeconds;
}
+ public boolean isWhitelisted(final SocketAddress address) {
+ final String addressString = address.toString();
+
+ for (final String whitelistedAddressString : whitelistedAddresses) {
+ if (addressString.endsWith(whitelistedAddressString)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
public void addFirewalled(final SocketAddress address) {
- if (FlameCord.getInstance().getFlameCordConfiguration().isFirewallEnabled()) {
+ if (FlameCord.getInstance().getFlameCordConfiguration().isFirewallEnabled() && !isWhitelisted(address)) {
final InetSocketAddress iNetSocketAddress = (InetSocketAddress) address;
final String hostString = iNetSocketAddress.getHostString();
diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
index d6d4cd6e..34c0b675 100644
--- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
+++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java
@@ -288,19 +288,30 @@ public class BungeeCord extends ProxyServer {
workerEventLoopGroup = PipelineUtils.newEventLoopGroup(0,
new ThreadFactoryBuilder().setNameFormat("Netty Worker IO Thread #%1$d").build());
+ // FlameCord - Load config before
+ config.load();
+
// FlameCord - Use own module system and reload FlameCord
/*
* File moduleDirectory = new File( "modules" ); moduleManager.load( this,
* moduleDirectory ); pluginManager.detectPlugins( moduleDirectory );
*/
- FlameCord.renew(logger);
+ // FlameCord - Collect ips from servers
+ final Collection<String> whitelistedAddresses = new HashSet<>();
+
+ for (final ServerInfo serverInfo : getServers().values()) {
+ whitelistedAddresses.add(serverInfo.getSocketAddress().toString());
+ }
+
+ FlameCord.renew(logger, whitelistedAddresses);
registerModules();
pluginsFolder.mkdir();
pluginManager.detectPlugins(pluginsFolder);
pluginManager.loadPlugins();
- config.load();
+ // FlameCord - Load config before
+ // config.load();
if (config.isForgeSupport()) {
registerChannel(ForgeConstants.FML_TAG);
@@ -828,7 +839,14 @@ public class BungeeCord extends ProxyServer {
break;
}
case "reload": {
- FlameCord.renew(logger);
+ // FlameCord - Collect ips from servers
+ final Collection<String> whitelistedAddresses = new HashSet<>();
+
+ for (final ServerInfo serverInfo : getServers().values()) {
+ whitelistedAddresses.add(serverInfo.getSocketAddress().toString());
+ }
+
+ FlameCord.renew(logger, whitelistedAddresses);
sender.sendMessage(TextComponent
.fromLegacyText(messagesConfiguration.getTranslation("flamecord_reload")));
break;
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
index 687bf518..0f6ac089 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
@@ -146,11 +146,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter {
final SocketAddress remoteAddress = channel.remoteAddress();
if (remoteAddress != null) {
- final Throwable causeCause = cause.getCause();
-
- if (causeCause == null || !causeCause.getMessage().contains("TO_CLIENT")) {
- flameCord.getFirewallManager().addFirewalled(remoteAddress);
- }
+ flameCord.getFirewallManager().addFirewalled(remoteAddress);
}
}
--
2.27.0.windows.1

View File

@ -0,0 +1,289 @@
From d5be6b944bf8393e2eafa5add1e1bd16f7a7b800 Mon Sep 17 00:00:00 2001
From: Juan Cruz Linsalata <LinsaFTW@users.noreply.github.com>
Date: Thu, 3 Sep 2020 19:36:44 -0300
Subject: [PATCH] FlameCord Defaulted timeout from 30000 to 5000
diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
index 85d2197a..a984370e 100644
--- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
+++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java
@@ -29,13 +29,12 @@ import net.md_5.bungee.util.CaseInsensitiveSet;
* Core configuration for the proxy.
*/
@Getter
-public abstract class Configuration implements ProxyConfig
-{
-
+public abstract class Configuration implements ProxyConfig {
+ // FlameCord - Default from 30000 to 5000
/**
* Time before users are disconnected due to no network activity.
*/
- private int timeout = 30000;
+ private int timeout = 5000;
/**
* UUID used for metrics.
*/
@@ -72,79 +71,84 @@ public abstract class Configuration implements ProxyConfig
private boolean forgeSupport = true; // Waterfall: default to enabled
@Synchronized("serversLock") // Waterfall
- public void load()
- {
+ public void load() {
ConfigurationAdapter adapter = ProxyServer.getInstance().getConfigurationAdapter();
adapter.load();
- File fav = new File( "server-icon.png" );
- if ( fav.exists() )
- {
- try
- {
- favicon = Favicon.create( ImageIO.read( fav ) );
- } catch ( IOException | IllegalArgumentException ex )
- {
- ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load server icon", ex );
+ File fav = new File("server-icon.png");
+ if (fav.exists()) {
+ try {
+ favicon = Favicon.create(ImageIO.read(fav));
+ } catch (IOException | IllegalArgumentException ex) {
+ ProxyServer.getInstance().getLogger().log(Level.WARNING, "Could not load server icon", ex);
}
}
listeners = adapter.getListeners();
- timeout = adapter.getInt( "timeout", timeout );
- uuid = adapter.getString( "stats", uuid );
- onlineMode = adapter.getBoolean( "online_mode", onlineMode );
- logCommands = adapter.getBoolean( "log_commands", logCommands );
- logPings = adapter.getBoolean( "log_pings", logPings );
- remotePingCache = adapter.getInt( "remote_ping_cache", remotePingCache );
- playerLimit = adapter.getInt( "player_limit", playerLimit );
- serverConnectTimeout = adapter.getInt( "server_connect_timeout", serverConnectTimeout );
- remotePingTimeout = adapter.getInt( "remote_ping_timeout", remotePingTimeout );
- throttle = adapter.getInt( "connection_throttle", throttle );
- throttleLimit = adapter.getInt( "connection_throttle_limit", throttleLimit );
- ipForward = adapter.getBoolean( "ip_forward", ipForward );
- compressionThreshold = adapter.getInt( "network_compression_threshold", compressionThreshold );
- preventProxyConnections = adapter.getBoolean( "prevent_proxy_connections", preventProxyConnections );
- forgeSupport = adapter.getBoolean( "forge_support", forgeSupport );
-
- disabledCommands = new CaseInsensitiveSet( (Collection<String>) adapter.getList( "disabled_commands", Arrays.asList( "disabledcommandhere" ) ) );
-
- Preconditions.checkArgument( listeners != null && !listeners.isEmpty(), "No listeners defined." );
+ timeout = adapter.getInt("timeout", timeout);
+ uuid = adapter.getString("stats", uuid);
+ onlineMode = adapter.getBoolean("online_mode", onlineMode);
+ logCommands = adapter.getBoolean("log_commands", logCommands);
+ logPings = adapter.getBoolean("log_pings", logPings);
+ remotePingCache = adapter.getInt("remote_ping_cache", remotePingCache);
+ playerLimit = adapter.getInt("player_limit", playerLimit);
+ serverConnectTimeout = adapter.getInt("server_connect_timeout", serverConnectTimeout);
+ remotePingTimeout = adapter.getInt("remote_ping_timeout", remotePingTimeout);
+ throttle = adapter.getInt("connection_throttle", throttle);
+ throttleLimit = adapter.getInt("connection_throttle_limit", throttleLimit);
+ ipForward = adapter.getBoolean("ip_forward", ipForward);
+ compressionThreshold = adapter.getInt("network_compression_threshold", compressionThreshold);
+ preventProxyConnections = adapter.getBoolean("prevent_proxy_connections", preventProxyConnections);
+ forgeSupport = adapter.getBoolean("forge_support", forgeSupport);
+
+ disabledCommands = new CaseInsensitiveSet(
+ (Collection<String>) adapter.getList("disabled_commands", Arrays.asList("disabledcommandhere")));
+
+ Preconditions.checkArgument(listeners != null && !listeners.isEmpty(), "No listeners defined.");
Map<String, ServerInfo> newServers = adapter.getServers();
- Preconditions.checkArgument( newServers != null && !newServers.isEmpty(), "No servers defined" );
+ Preconditions.checkArgument(newServers != null && !newServers.isEmpty(), "No servers defined");
- if ( servers == null )
- {
- servers = new CaseInsensitiveMap<>( newServers );
- } else
- {
+ if (servers == null) {
+ servers = new CaseInsensitiveMap<>(newServers);
+ } else {
Map<String, ServerInfo> oldServers = getServersCopy();
- for ( ServerInfo oldServer : oldServers.values() )
- {
+ for (ServerInfo oldServer : oldServers.values()) {
ServerInfo newServer = newServers.get(oldServer.getName());
- if ((newServer == null || !oldServer.getAddress().equals(newServer.getAddress())) && !oldServer.getPlayers().isEmpty()) {
+ if ((newServer == null || !oldServer.getAddress().equals(newServer.getAddress()))
+ && !oldServer.getPlayers().isEmpty()) {
BungeeCord.getInstance().getLogger().info("Moving players off of server: " + oldServer.getName());
// The server is being removed, or having it's address changed
for (ProxiedPlayer player : oldServer.getPlayers()) {
ListenerInfo listener = player.getPendingConnection().getListener();
- String destinationName = newServers.get(listener.getDefaultServer()) == null ? listener.getDefaultServer() : listener.getFallbackServer();
+ String destinationName = newServers.get(listener.getDefaultServer()) == null
+ ? listener.getDefaultServer()
+ : listener.getFallbackServer();
ServerInfo destination = newServers.get(destinationName);
if (destination == null) {
- BungeeCord.getInstance().getLogger().severe("Couldn't find server " + listener.getDefaultServer() + " or " + listener.getFallbackServer() + " to put player " + player.getName() + " on");
- player.disconnect(BungeeCord.getInstance().getTranslation("fallback_kick", "Not found on reload"));
+ BungeeCord.getInstance().getLogger()
+ .severe("Couldn't find server " + listener.getDefaultServer() + " or "
+ + listener.getFallbackServer() + " to put player " + player.getName()
+ + " on");
+ player.disconnect(
+ BungeeCord.getInstance().getTranslation("fallback_kick", "Not found on reload"));
continue;
}
player.connect(destination, (success, cause) -> {
if (!success) {
- BungeeCord.getInstance().getLogger().log(Level.WARNING, "Failed to connect " + player.getName() + " to " + destination.getName(), cause);
- player.disconnect(BungeeCord.getInstance().getTranslation("fallback_kick", cause.getCause().getClass().getName()));
+ BungeeCord.getInstance().getLogger().log(Level.WARNING,
+ "Failed to connect " + player.getName() + " to " + destination.getName(),
+ cause);
+ player.disconnect(BungeeCord.getInstance().getTranslation("fallback_kick",
+ cause.getCause().getClass().getName()));
}
});
}
} else {
// This server isn't new or removed, we'll use bungees behavior of just ignoring
- // any changes to info outside of the address, this is not ideal, but the alternative
+ // any changes to info outside of the address, this is not ideal, but the
+ // alternative
// requires resetting multiple objects of which have no proper identity
newServers.put(oldServer.getName(), oldServer);
}
@@ -152,18 +156,16 @@ public abstract class Configuration implements ProxyConfig
this.servers = new CaseInsensitiveMap<>(newServers);
}
- for ( ListenerInfo listener : listeners )
- {
- for ( int i = 0; i < listener.getServerPriority().size(); i++ )
- {
- String server = listener.getServerPriority().get( i );
- Preconditions.checkArgument( servers.containsKey( server ), "Server %s (priority %s) is not defined", server, i );
+ for (ListenerInfo listener : listeners) {
+ for (int i = 0; i < listener.getServerPriority().size(); i++) {
+ String server = listener.getServerPriority().get(i);
+ Preconditions.checkArgument(servers.containsKey(server), "Server %s (priority %s) is not defined",
+ server, i);
}
- for ( String server : listener.getForcedHosts().values() )
- {
- if ( !servers.containsKey( server ) )
- {
- ProxyServer.getInstance().getLogger().log( Level.WARNING, "Forced host server {0} is not defined", server );
+ for (String server : listener.getForcedHosts().values()) {
+ if (!servers.containsKey(server)) {
+ ProxyServer.getInstance().getLogger().log(Level.WARNING, "Forced host server {0} is not defined",
+ server);
}
}
}
@@ -171,14 +173,12 @@ public abstract class Configuration implements ProxyConfig
@Override
@Deprecated
- public String getFavicon()
- {
+ public String getFavicon() {
return getFaviconObject().getEncoded();
}
@Override
- public Favicon getFaviconObject()
- {
+ public Favicon getFaviconObject() {
return favicon;
}
@@ -186,64 +186,57 @@ public abstract class Configuration implements ProxyConfig
@Override
@Synchronized("serversLock")
public Map<String, ServerInfo> getServersCopy() {
- return ImmutableMap.copyOf( servers );
+ return ImmutableMap.copyOf(servers);
}
@Override
@Synchronized("serversLock")
- public ServerInfo getServerInfo(String name)
- {
- return this.servers.get( name );
+ public ServerInfo getServerInfo(String name) {
+ return this.servers.get(name);
}
@Override
@Synchronized("serversLock")
- public ServerInfo addServer(ServerInfo server)
- {
- return this.servers.put( server.getName(), server );
+ public ServerInfo addServer(ServerInfo server) {
+ return this.servers.put(server.getName(), server);
}
@Override
@Synchronized("serversLock")
- public boolean addServers(Collection<ServerInfo> servers)
- {
+ public boolean addServers(Collection<ServerInfo> servers) {
boolean changed = false;
- for ( ServerInfo server : servers )
- {
- if ( server != this.servers.put( server.getName(), server ) ) changed = true;
+ for (ServerInfo server : servers) {
+ if (server != this.servers.put(server.getName(), server))
+ changed = true;
}
return changed;
}
@Override
@Synchronized("serversLock")
- public ServerInfo removeServerNamed(String name)
- {
- return this.servers.remove( name );
+ public ServerInfo removeServerNamed(String name) {
+ return this.servers.remove(name);
}
@Override
@Synchronized("serversLock")
- public ServerInfo removeServer(ServerInfo server)
- {
- return this.servers.remove( server.getName() );
+ public ServerInfo removeServer(ServerInfo server) {
+ return this.servers.remove(server.getName());
}
@Override
@Synchronized("serversLock")
- public boolean removeServersNamed(Collection<String> names)
- {
- return this.servers.keySet().removeAll( names );
+ public boolean removeServersNamed(Collection<String> names) {
+ return this.servers.keySet().removeAll(names);
}
@Override
@Synchronized("serversLock")
- public boolean removeServers(Collection<ServerInfo> servers)
- {
+ public boolean removeServers(Collection<ServerInfo> servers) {
boolean changed = false;
- for ( ServerInfo server : servers )
- {
- if ( null != this.servers.remove( server.getName() ) ) changed = true;
+ for (ServerInfo server : servers) {
+ if (null != this.servers.remove(server.getName()))
+ changed = true;
}
return changed;
}
--
2.27.0.windows.1