#2752: Configurable connect and ping timeouts
This commit is contained in:
parent
70370faf5d
commit
0a4b9b4984
@ -78,6 +78,22 @@ public interface ProxyConfig
|
|||||||
*/
|
*/
|
||||||
Collection<String> getDisabledCommands();
|
Collection<String> getDisabledCommands();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in milliseconds before timing out a clients request to connect to a
|
||||||
|
* server.
|
||||||
|
*
|
||||||
|
* @return connect timeout
|
||||||
|
*/
|
||||||
|
int getServerConnectTimeout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time in milliseconds before timing out a ping request from the proxy to a
|
||||||
|
* server when attempting to request server list info.
|
||||||
|
*
|
||||||
|
* @return ping timeout
|
||||||
|
*/
|
||||||
|
int getRemotePingTimeout();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The connection throttle delay.
|
* The connection throttle delay.
|
||||||
*
|
*
|
||||||
@ -87,7 +103,7 @@ public interface ProxyConfig
|
|||||||
int getThrottle();
|
int getThrottle();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the proxy will parse IPs with spigot or not
|
* Whether the proxy will parse IPs with spigot or not.
|
||||||
*
|
*
|
||||||
* @return ip forward
|
* @return ip forward
|
||||||
*/
|
*/
|
||||||
|
@ -73,6 +73,6 @@ public class ServerConnectRequest
|
|||||||
public static class Builder
|
public static class Builder
|
||||||
{
|
{
|
||||||
|
|
||||||
private int connectTimeout = 5000; // TODO: Configurable
|
private int connectTimeout = ProxyServer.getInstance().getConfig().getServerConnectTimeout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Collection;
|
|||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ServerConnectRequestTest
|
public class ServerConnectRequestTest
|
||||||
@ -79,13 +78,6 @@ public class ServerConnectRequestTest
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDefaultConnectTimeout()
|
|
||||||
{
|
|
||||||
ServerConnectRequest request = ServerConnectRequest.builder().target( DUMMY_INFO ).reason( ServerConnectEvent.Reason.JOIN_PROXY ).build();
|
|
||||||
Assert.assertEquals( 5000, request.getConnectTimeout() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = NullPointerException.class)
|
@Test(expected = NullPointerException.class)
|
||||||
public void testNullTarget()
|
public void testNullTarget()
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ public class BungeeServerInfo implements ServerInfo
|
|||||||
.channel( PipelineUtils.getChannel( socketAddress ) )
|
.channel( PipelineUtils.getChannel( socketAddress ) )
|
||||||
.group( BungeeCord.getInstance().eventLoops )
|
.group( BungeeCord.getInstance().eventLoops )
|
||||||
.handler( PipelineUtils.BASE )
|
.handler( PipelineUtils.BASE )
|
||||||
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000 ) // TODO: Configurable
|
.option( ChannelOption.CONNECT_TIMEOUT_MILLIS, BungeeCord.getInstance().getConfig().getRemotePingTimeout() )
|
||||||
.remoteAddress( socketAddress )
|
.remoteAddress( socketAddress )
|
||||||
.connect()
|
.connect()
|
||||||
.addListener( listener );
|
.addListener( listener );
|
||||||
|
@ -55,6 +55,8 @@ public class Configuration implements ProxyConfig
|
|||||||
private int remotePingCache = -1;
|
private int remotePingCache = -1;
|
||||||
private int playerLimit = -1;
|
private int playerLimit = -1;
|
||||||
private Collection<String> disabledCommands;
|
private Collection<String> disabledCommands;
|
||||||
|
private int serverConnectTimeout = 5000;
|
||||||
|
private int remotePingTimeout = 5000;
|
||||||
private int throttle = 4000;
|
private int throttle = 4000;
|
||||||
private int throttleLimit = 3;
|
private int throttleLimit = 3;
|
||||||
private boolean ipForward;
|
private boolean ipForward;
|
||||||
@ -88,6 +90,8 @@ public class Configuration implements ProxyConfig
|
|||||||
logPings = adapter.getBoolean( "log_pings", logPings );
|
logPings = adapter.getBoolean( "log_pings", logPings );
|
||||||
remotePingCache = adapter.getInt( "remote_ping_cache", remotePingCache );
|
remotePingCache = adapter.getInt( "remote_ping_cache", remotePingCache );
|
||||||
playerLimit = adapter.getInt( "player_limit", playerLimit );
|
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 );
|
throttle = adapter.getInt( "connection_throttle", throttle );
|
||||||
throttleLimit = adapter.getInt( "connection_throttle_limit", throttleLimit );
|
throttleLimit = adapter.getInt( "connection_throttle_limit", throttleLimit );
|
||||||
ipForward = adapter.getBoolean( "ip_forward", ipForward );
|
ipForward = adapter.getBoolean( "ip_forward", ipForward );
|
||||||
|
Loading…
Reference in New Issue
Block a user