ConnectFilter API now public
This commit is contained in:
@@ -5,6 +5,7 @@ import arc.func.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.net.*;
|
import arc.net.*;
|
||||||
import arc.net.FrameworkMessage.*;
|
import arc.net.FrameworkMessage.*;
|
||||||
|
import arc.net.Server.*;
|
||||||
import arc.net.dns.*;
|
import arc.net.dns.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -161,6 +162,11 @@ public class ArcNetProvider implements NetProvider{
|
|||||||
server.setConnectFilter(connectFilter);
|
server.setConnectFilter(connectFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ServerConnectFilter getConnectFilter(){
|
||||||
|
return server.getConnectFilter();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isLocal(InetAddress addr){
|
private static boolean isLocal(InetAddress addr){
|
||||||
if(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) return true;
|
if(addr.isAnyLocalAddress() || addr.isLoopbackAddress()) return true;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package mindustry.net;
|
|||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.net.*;
|
import arc.net.*;
|
||||||
|
import arc.net.Server.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.game.EventType.*;
|
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.
|
* 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.
|
* 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. */
|
/** 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 void setConnectFilter(Server.ServerConnectFilter connectFilter){}
|
||||||
|
|
||||||
|
default ServerConnectFilter getConnectFilter(){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user