ConnectFilter API now public

This commit is contained in:
Anuken
2023-11-23 14:24:59 -05:00
parent f5424ea59b
commit d2956d1f2c
2 changed files with 20 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import arc.func.*;
import arc.math.*;
import arc.net.*;
import arc.net.FrameworkMessage.*;
import arc.net.Server.*;
import arc.net.dns.*;
import arc.struct.*;
import arc.util.*;
@@ -161,6 +162,11 @@ public class ArcNetProvider implements NetProvider{
server.setConnectFilter(connectFilter);
}
@Override
public ServerConnectFilter getConnectFilter(){
return server.getConnectFilter();
}
private static boolean isLocal(InetAddress addr){
if(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) return true;

View File

@@ -3,6 +3,7 @@ package mindustry.net;
import arc.*;
import arc.func.*;
import arc.net.*;
import arc.net.Server.*;
import arc.struct.*;
import arc.util.*;
import mindustry.game.EventType.*;
@@ -325,6 +326,15 @@ public class Net{
}
}
/** Sets a connection filter by IP address. If the filter returns {@code false}, the connection will be closed. Server only. */
public void setConnectFilter(ServerConnectFilter filter){
provider.setConnectFilter(filter);
}
public ServerConnectFilter getConnectFilter(){
return provider.getConnectFilter();
}
/**
* Pings a host in a pooled thread. If an error occurred, failed() should be called with the exception.
* If the port is the default mindustry port, SRV records are checked too.
@@ -401,5 +411,9 @@ public class Net{
/** Sets a connection filter by IP address. If the filter returns {@code false}, the connection will be closed. */
default void setConnectFilter(Server.ServerConnectFilter connectFilter){}
default ServerConnectFilter getConnectFilter(){
return null;
}
}
}