#2752: Configurable connect and ping timeouts

This commit is contained in:
Mystiflow
2020-01-25 11:11:30 +11:00
committed by md_5
parent 70370faf5d
commit 0a4b9b4984
5 changed files with 23 additions and 11 deletions

View File

@@ -78,6 +78,22 @@ public interface ProxyConfig
*/
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.
*
@@ -87,7 +103,7 @@ public interface ProxyConfig
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
*/

View File

@@ -73,6 +73,6 @@ public class ServerConnectRequest
public static class Builder
{
private int connectTimeout = 5000; // TODO: Configurable
private int connectTimeout = ProxyServer.getInstance().getConfig().getServerConnectTimeout();
}
}

View File

@@ -6,7 +6,6 @@ import java.util.Collection;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ServerConnectEvent;
import org.junit.Assert;
import org.junit.Test;
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)
public void testNullTarget()
{