mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-12-31 21:18:10 +01:00
290 lines
14 KiB
Diff
290 lines
14 KiB
Diff
From efe1b091836279bb375f6770fb8d98c4e5c1c4ed 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
|
|
|