diff --git a/Dorkbox-Network/src/dorkbox/network/Client.java b/Dorkbox-Network/src/dorkbox/network/Client.java
index dc413103..8b747fd9 100644
--- a/Dorkbox-Network/src/dorkbox/network/Client.java
+++ b/Dorkbox-Network/src/dorkbox/network/Client.java
@@ -1,10 +1,13 @@
package dorkbox.network;
import io.netty.bootstrap.Bootstrap;
+import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
+import io.netty.channel.epoll.EpollEventLoopGroup;
+import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -34,6 +37,7 @@ import dorkbox.network.util.exceptions.InitializationException;
import dorkbox.network.util.exceptions.SecurityException;
import dorkbox.network.util.udt.UdtEndpointProxy;
import dorkbox.util.NamedThreadFactory;
+import dorkbox.util.OS;
/**
* The client is both SYNC and ASYNC, meaning that once the client is connected to the server, you can access it however you want.
@@ -123,11 +127,20 @@ public class Client extends EndPointClient {
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
tcpBootstrap.channel(OioSocketChannel.class);
} else {
- boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
- tcpBootstrap.channel(NioSocketChannel.class);
+ if (OS.isLinux()) {
+ // JNI network stack is MUCH faster (but only on linux)
+ boss = new EpollEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
+
+ tcpBootstrap.channel(EpollSocketChannel.class);
+ } else {
+ boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
+
+ tcpBootstrap.channel(NioSocketChannel.class);
+ }
}
tcpBootstrap.group(boss)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.remoteAddress(options.host, options.tcpPort)
.handler(new RegistrationRemoteHandlerClientTCP(this.name,
this.registrationWrapper,
@@ -153,11 +166,14 @@ public class Client extends EndPointClient {
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-UDP", nettyGroup));
udpBootstrap.channel(OioDatagramChannel.class);
} else {
+ // CANNOT USE EpollDatagramChannel on the client!
boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-UDP", nettyGroup));
+
udpBootstrap.channel(NioDatagramChannel.class);
}
udpBootstrap.group(boss)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.localAddress(new InetSocketAddress(0))
.remoteAddress(new InetSocketAddress(options.host, options.udpPort))
.handler(new RegistrationRemoteHandlerClientUDP(this.name,
@@ -201,6 +217,7 @@ public class Client extends EndPointClient {
UdtEndpointProxy.setChannelFactory(udtBootstrap);
udtBootstrap.group(boss)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.remoteAddress(options.host, options.udtPort)
.handler(new RegistrationRemoteHandlerClientUDT(this.name,
this.registrationWrapper,
diff --git a/Dorkbox-Network/src/dorkbox/network/DnsClient.java b/Dorkbox-Network/src/dorkbox/network/DnsClient.java
index 7d4e6285..913a0142 100644
--- a/Dorkbox-Network/src/dorkbox/network/DnsClient.java
+++ b/Dorkbox-Network/src/dorkbox/network/DnsClient.java
@@ -131,16 +131,31 @@ public class DnsClient {
}
/**
- * Submits a question to the DNS server
+ * Submits a question to the DNS server.
+ *
+ * Note that PTR absolutely MUST end in '.in-addr.arpa' in order for the DNS server to understand it.
+ * -- because of this, we will automatically fix this in case that clients are unaware of this requirement
+ *
* @return always non-null, a list of answers from the server. Am empty list can also mean there was an error.
*/
@SuppressWarnings("unchecked")
- public synchronized List submitQuestion(final DnsQuestion question) {
+ public synchronized List submitQuestion(DnsQuestion question) {
if (this.dnsServer == null) {
this.logger.error("Cannot submit query. There was no connection to the DNS server.");
return Collections.EMPTY_LIST;
}
+ if (question.type() == DnsType.PTR) {
+ // PTR absolutely MUST end in ".in-addr.arpa"
+ String name = question.name();
+ String ptrSuffix = ".in-addr.arpa";
+
+ if (!name.endsWith(ptrSuffix)) {
+ question = new DnsQuestion(name + ".in-addr.arpa", DnsType.PTR, question.dnsClass());
+ }
+ }
+
+
DnsQuery query = new DnsQuery(ThreadLocalRandom.current().nextInt(), this.dnsServer).addQuestion(question);
final Promise promise = GlobalEventExecutor.INSTANCE.newPromise();
diff --git a/Dorkbox-Network/src/dorkbox/network/Server.java b/Dorkbox-Network/src/dorkbox/network/Server.java
index c3c5b443..90547319 100644
--- a/Dorkbox-Network/src/dorkbox/network/Server.java
+++ b/Dorkbox-Network/src/dorkbox/network/Server.java
@@ -2,10 +2,15 @@ package dorkbox.network;
import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap;
+import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption;
import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup;
+import io.netty.channel.epoll.EpollChannelOption;
+import io.netty.channel.epoll.EpollDatagramChannel;
+import io.netty.channel.epoll.EpollEventLoopGroup;
+import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
@@ -26,6 +31,7 @@ import dorkbox.network.util.exceptions.InitializationException;
import dorkbox.network.util.exceptions.SecurityException;
import dorkbox.network.util.udt.UdtEndpointProxy;
import dorkbox.util.NamedThreadFactory;
+import dorkbox.util.OS;
/**
@@ -140,6 +146,7 @@ public class Server extends EndPointServer {
this.localBootstrap.group(boss, worker)
.channel(LocalServerChannel.class)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.localAddress(new LocalAddress(this.localChannelName))
.childHandler(new RegistrationLocalHandlerServer(this.name,
this.registrationWrapper));
@@ -159,15 +166,28 @@ public class Server extends EndPointServer {
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
this.tcpBootstrap.channel(OioServerSocketChannel.class);
} else {
- boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
- worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
- this.tcpBootstrap.channel(NioServerSocketChannel.class);
+ if (OS.isLinux()) {
+ // JNI network stack is MUCH faster (but only on linux)
+ boss = new EpollEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
+ worker = new EpollEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
+
+ this.tcpBootstrap.channel(EpollServerSocketChannel.class);
+ } else {
+ boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
+ worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
+
+ this.tcpBootstrap.channel(NioServerSocketChannel.class);
+ }
}
+ // TODO: If we use netty for an HTTP server,
+ // Beside the usual ChannelOptions the Native Transport allows to enable TCP_CORK which may come in handy if you implement a HTTP Server.
+
manageForShutdown(boss);
manageForShutdown(worker);
this.tcpBootstrap.group(boss, worker)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.SO_BACKLOG, backlogConnectionCount)
.option(ChannelOption.SO_REUSEADDR, true)
.childHandler(new RegistrationRemoteHandlerServerTCP(this.name,
@@ -196,13 +216,23 @@ public class Server extends EndPointServer {
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
this.udpBootstrap.channel(OioDatagramChannel.class);
} else {
- worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
- this.udpBootstrap.channel(NioDatagramChannel.class);
+ if (OS.isLinux()) {
+ // JNI network stack is MUCH faster (but only on linux)
+ worker = new EpollEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
+
+ this.udpBootstrap.channel(EpollDatagramChannel.class)
+ .option(EpollChannelOption.SO_REUSEPORT, true);
+ } else {
+ worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
+
+ this.udpBootstrap.channel(NioDatagramChannel.class);
+ }
}
manageForShutdown(worker);
this.udpBootstrap.group(worker)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// not binding to specific address, since it's driven by TCP, and that can be bound to a specific address
.localAddress(this.udpPort) // if you bind to a specific interface, Linux will be unable to receive broadcast packets!
.handler(new RegistrationRemoteHandlerServerUDP(this.name, this.registrationWrapper, this.serializationManager));
@@ -233,6 +263,7 @@ public class Server extends EndPointServer {
UdtEndpointProxy.setChannelFactory(this.udtBootstrap);
this.udtBootstrap.group(boss, worker)
.option(ChannelOption.SO_BACKLOG, backlogConnectionCount)
+ .option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// not binding to specific address, since it's driven by TCP, and that can be bound to a specific address
.localAddress(this.udtPort)
.childHandler(new RegistrationRemoteHandlerServerUDT(this.name,
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/ConnectionImpl.java b/Dorkbox-Network/src/dorkbox/network/connection/ConnectionImpl.java
index b66e0528..b6b04cdb 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/ConnectionImpl.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/ConnectionImpl.java
@@ -4,6 +4,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.epoll.EpollDatagramChannel;
+import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
@@ -389,16 +391,22 @@ public class ConnectionImpl extends ChannelInboundHandlerAdapter
}
Channel channel = context.channel();
+ Class extends Channel> channelClass = channel.getClass();
+
+ boolean isTCP = channelClass == NioSocketChannel.class || channelClass == EpollSocketChannel.class;
if (this.logger.isInfoEnabled()) {
String type;
- if (channel instanceof NioSocketChannel) {
+
+ if (isTCP) {
type = "TCP";
- } else if (channel instanceof NioDatagramChannel) {
+ } else if (channelClass == NioDatagramChannel.class) {
type = "UDP";
- } else if (channel instanceof NioUdtByteConnectorChannel) {
+ } else if (channelClass == EpollDatagramChannel.class) {
+ type = "UDP";
+ } else if (channelClass == NioUdtByteConnectorChannel.class) {
type = "UDT";
- } else if (channel instanceof LocalChannel) {
+ } else if (channelClass == LocalChannel.class) {
type = "LOCAL";
} else {
type = "UNKNOWN";
@@ -408,7 +416,7 @@ public class ConnectionImpl extends ChannelInboundHandlerAdapter
}
// our master channels are TCP/LOCAL (which are mutually exclusive). Only key disconnect events based on the status of them.
- if (channel instanceof NioSocketChannel || channel instanceof LocalChannel) {
+ if (isTCP || channelClass == LocalChannel.class) {
// this is because channelInactive can ONLY happen when netty shuts down the channel.
// and connection.close() can be called by the user.
this.sessionManager.connectionDisconnected(this);
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
index 5e89649b..b8e5c507 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/EndPoint.java
@@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
-import java.util.concurrent.Semaphore;
+import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
@@ -122,7 +122,7 @@ public abstract class EndPoint {
private List eventLoopGroups = new ArrayList(8);
private List shutdownChannelList = new ArrayList();
- private final Semaphore blockUntilDone = new Semaphore(0);
+ private final CountDownLatch blockUntilDone = new CountDownLatch(1);
protected final Object shutdownInProgress = new Object();
protected AtomicBoolean isConnected = new AtomicBoolean(false);
@@ -338,22 +338,8 @@ public abstract class EndPoint {
String threadName = currentThread.getName();
boolean inEventThread = !threadName.equals(shutdownHookName) && !threadName.equals(stopTreadName);
- // we must also account for the shutdown hook calling this!
- // if we are in the shutdown hook, then we cannot possibly be in our event thread
- if (inEventThread) {
- inEventThread = false;
-
- // we need to test to see if our current thread is in ANY of the event group threads. If it IS, then we risk deadlocking!
- List eventLoopGroups2 = this.eventLoopGroups;
- synchronized (eventLoopGroups2) {
- for (EventLoopGroup loopGroup : eventLoopGroups2) {
- if (!inEventThread) {
- inEventThread = checkInEventGroup(currentThread, loopGroup);
- break;
- }
- }
- }
- }
+ // used to check the event groups to see if we are running from one of them. NOW we force to
+ // ALWAYS shutdown inside a NEW thread
if (!inEventThread) {
stopInThread();
@@ -372,9 +358,6 @@ public abstract class EndPoint {
// This actually does the "stopping", since there is some logic to making sure we don't deadlock, this is important
private final void stopInThread() {
- // tell the blocked "bind" method that it may continue (and exit)
- this.blockUntilDone.release();
-
// make sure we are not trying to stop during a startup procedure.
// This will wait until we have finished starting up/shutting down.
synchronized (this.shutdownInProgress) {
@@ -415,7 +398,6 @@ public abstract class EndPoint {
// shutdown the database store
this.propertyStore.shutdown();
-
// now we stop all of our channels
for (ChannelFuture f : this.shutdownChannelList) {
Channel channel = f.channel();
@@ -439,6 +421,9 @@ public abstract class EndPoint {
// when the eventloop closes, the associated selectors are ALSO closed!
}
+
+ // tell the blocked "bind" method that it may continue (and exit)
+ this.blockUntilDone.countDown();
}
/**
@@ -467,15 +452,17 @@ public abstract class EndPoint {
}
/**
- * Blocks the current thread until the client has been stopped.
+ * Blocks the current thread until the endpoint has been stopped.
+ *
* @param blockUntilTerminate if TRUE, then this endpoint will block until STOP is called, otherwise it will not block
*/
public final void waitForStop(boolean blockUntilTerminate) {
if (blockUntilTerminate) {
// we now BLOCK until the stop method is called.
try {
- this.blockUntilDone.acquire();
+ this.blockUntilDone.await();
} catch (InterruptedException e) {
+ this.logger.error("Thread interrupted while waiting for stop!");
}
}
}
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/ListenerRaw.java b/Dorkbox-Network/src/dorkbox/network/connection/ListenerRaw.java
index 2c287b96..264055d5 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/ListenerRaw.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/ListenerRaw.java
@@ -15,12 +15,18 @@ public abstract class ListenerRaw {
// for sub-classed listeners, we might have to specify which parameter to use.
protected ListenerRaw(int lastParameterIndex) {
if (lastParameterIndex > -1) {
- Class> objectType = ClassHelper.getGenericParameterAsClassForSuperClass(getClass(), lastParameterIndex);
+ @SuppressWarnings("rawtypes")
+ Class extends ListenerRaw> class1 = getClass();
+
+ Class> objectType = ClassHelper.getGenericParameterAsClassForSuperClass(class1, lastParameterIndex);
if (objectType != null) {
// SOMETIMES generics get confused on which parameter we actually mean (when sub-classing)
- if (objectType.isAssignableFrom(Connection.class)) {
- objectType = ClassHelper.getGenericParameterAsClassForSuperClass(getClass(), lastParameterIndex+1);
+ if (objectType != Object.class && ClassHelper.hasInterface(Connection.class, objectType)) {
+ Class> objectType2 = ClassHelper.getGenericParameterAsClassForSuperClass(class1, lastParameterIndex+1);
+ if (objectType2 != null) {
+ objectType = objectType2;
+ }
}
this.objectType = objectType;
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/PropertyStore.java b/Dorkbox-Network/src/dorkbox/network/connection/PropertyStore.java
index dea33356..cdba4e6f 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/PropertyStore.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/PropertyStore.java
@@ -194,10 +194,8 @@ class PropertyStore extends SettingsStore {
return remove != null;
}
-
@Override
public void shutdown() {
Storage.close(this.storage);
- super.shutdown();
}
}
diff --git a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java
index 0ee39849..9bd455e9 100644
--- a/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java
+++ b/Dorkbox-Network/src/dorkbox/network/connection/registration/remote/RegistrationRemoteHandler.java
@@ -3,6 +3,8 @@ package dorkbox.network.connection.registration.remote;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
+import io.netty.channel.epoll.EpollDatagramChannel;
+import io.netty.channel.epoll.EpollSocketChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.udt.nio.NioUdtByteConnectorChannel;
@@ -97,15 +99,24 @@ public abstract class RegistrationRemoteHandler extends RegistrationHandler {
// add the channel so we can access it later.
// do NOT want to add UDP channels, since they are tracked differently.
+
+ // this whole bit is inside a if (logger.isDebugEnabled()) section.
Channel channel = context.channel();
+ Class extends Channel> channelClass = channel.getClass();
+
+
StringBuilder stringBuilder = new StringBuilder(76);
stringBuilder.append("Connected to remote ");
- if (channel instanceof NioSocketChannel) {
+ if (channelClass == NioSocketChannel.class) {
stringBuilder.append("TCP");
- } else if (channel instanceof NioDatagramChannel) {
+ } else if (channelClass == EpollSocketChannel.class) {
+ stringBuilder.append("TCP");
+ } else if (channelClass == NioDatagramChannel.class) {
stringBuilder.append("UDP");
- } else if (channel instanceof NioUdtByteConnectorChannel) {
+ } else if (channelClass == EpollDatagramChannel.class) {
+ stringBuilder.append("UDP");
+ } else if (channelClass == NioUdtByteConnectorChannel.class) {
stringBuilder.append("UDT");
}
else {
diff --git a/Dorkbox-Network/src/dorkbox/network/util/store/SettingsStore.java b/Dorkbox-Network/src/dorkbox/network/util/store/SettingsStore.java
index 1f3b69bf..33b65558 100644
--- a/Dorkbox-Network/src/dorkbox/network/util/store/SettingsStore.java
+++ b/Dorkbox-Network/src/dorkbox/network/util/store/SettingsStore.java
@@ -7,7 +7,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dorkbox.network.util.exceptions.SecurityException;
-import dorkbox.util.storage.Storage;
/**
* This class provides a way for the network stack to use the server's database, instead of a property file (which it uses when stand-alone)
@@ -296,7 +295,5 @@ public abstract class SettingsStore {
/**
* Take the proper steps to shutdown the storage system.
*/
- public void shutdown() {
- Storage.shutdown();
- }
+ public abstract void shutdown();
}
diff --git a/Dorkbox-Network/test/dorkbox/network/ChunkedDataTest.java b/Dorkbox-Network/test/dorkbox/network/ChunkedDataTest.java
index 1cfc071f..f161718b 100644
--- a/Dorkbox-Network/test/dorkbox/network/ChunkedDataTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ChunkedDataTest.java
@@ -56,6 +56,7 @@ public class ChunkedDataTest extends BaseTest {
private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
register(server.getSerialization());
addEndPoint(server);
server.setIdleTimeout(100);
@@ -80,6 +81,7 @@ public class ChunkedDataTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
register(client.getSerialization());
addEndPoint(client);
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/ClientSendTest.java b/Dorkbox-Network/test/dorkbox/network/ClientSendTest.java
index 67909991..c6435475 100644
--- a/Dorkbox-Network/test/dorkbox/network/ClientSendTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ClientSendTest.java
@@ -26,6 +26,7 @@ public class ClientSendTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
register(server.getSerialization());
@@ -39,6 +40,7 @@ public class ClientSendTest extends BaseTest {
});
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
register(client.getSerialization());
client.connect(5000);
diff --git a/Dorkbox-Network/test/dorkbox/network/ConnectionTest.java b/Dorkbox-Network/test/dorkbox/network/ConnectionTest.java
index 8d5eb0f3..8fb6f97d 100644
--- a/Dorkbox-Network/test/dorkbox/network/ConnectionTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ConnectionTest.java
@@ -118,6 +118,7 @@ public class ConnectionTest extends BaseTest {
server = new Server();
}
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
server.listeners().add(new Listener() {
@@ -145,6 +146,7 @@ public class ConnectionTest extends BaseTest {
} else {
client = new Client();
}
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/DiscoverHostTest.java b/Dorkbox-Network/test/dorkbox/network/DiscoverHostTest.java
index 5bc4b469..74470e3c 100644
--- a/Dorkbox-Network/test/dorkbox/network/DiscoverHostTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/DiscoverHostTest.java
@@ -25,6 +25,7 @@ public class DiscoverHostTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
@@ -38,6 +39,7 @@ public class DiscoverHostTest extends BaseTest {
}
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
@Override
diff --git a/Dorkbox-Network/test/dorkbox/network/IdleTest.java b/Dorkbox-Network/test/dorkbox/network/IdleTest.java
index 7da9d47c..1ade717d 100644
--- a/Dorkbox-Network/test/dorkbox/network/IdleTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/IdleTest.java
@@ -93,6 +93,7 @@ public class IdleTest extends BaseTest {
private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
register(server.getSerialization());
addEndPoint(server);
server.setIdleTimeout(100);
@@ -114,6 +115,7 @@ public class IdleTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
register(client.getSerialization());
addEndPoint(client);
client.listeners().add(new Listener() {
@@ -140,6 +142,7 @@ public class IdleTest extends BaseTest {
private void streamSpecificType(final int largeDataSize, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
server.getSerialization().setRegistrationRequired(false);
addEndPoint(server);
server.setIdleTimeout(100);
@@ -180,6 +183,7 @@ public class IdleTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
client.getSerialization().setRegistrationRequired(false);
addEndPoint(client);
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/LargeBufferTest.java b/Dorkbox-Network/test/dorkbox/network/LargeBufferTest.java
index b978b9be..4f4a1810 100644
--- a/Dorkbox-Network/test/dorkbox/network/LargeBufferTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/LargeBufferTest.java
@@ -33,6 +33,7 @@ public class LargeBufferTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
register(server.getSerialization());
@@ -58,6 +59,7 @@ public class LargeBufferTest extends BaseTest {
});
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
register(client.getSerialization());
client.connect(5000);
diff --git a/Dorkbox-Network/test/dorkbox/network/ListenerTest.java b/Dorkbox-Network/test/dorkbox/network/ListenerTest.java
index 81d95314..36871b86 100644
--- a/Dorkbox-Network/test/dorkbox/network/ListenerTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ListenerTest.java
@@ -70,6 +70,7 @@ public class ListenerTest extends BaseTest {
}
};
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
@@ -137,6 +138,7 @@ public class ListenerTest extends BaseTest {
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
@Override
diff --git a/Dorkbox-Network/test/dorkbox/network/MultipleServerTest.java b/Dorkbox-Network/test/dorkbox/network/MultipleServerTest.java
index 0eeab203..10b373da 100644
--- a/Dorkbox-Network/test/dorkbox/network/MultipleServerTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/MultipleServerTest.java
@@ -26,6 +26,7 @@ public class MultipleServerTest extends BaseTest {
Server server1 = new Server(connectionOptions1);
+ server1.disableRemoteKeyValidation();
server1.getSerialization().register(String[].class);
addEndPoint(server1);
@@ -49,6 +50,7 @@ public class MultipleServerTest extends BaseTest {
Server server2 = new Server(connectionOptions2);
+ server2.disableRemoteKeyValidation();
server2.getSerialization().register(String[].class);
addEndPoint(server2);
server2.bind(false);
@@ -68,7 +70,9 @@ public class MultipleServerTest extends BaseTest {
connectionOptions1.localChannelName = null;
connectionOptions1.host = host;
+
Client client1 = new Client(connectionOptions1);
+ client1.disableRemoteKeyValidation();
client1.getSerialization().register(String[].class);
addEndPoint(client1);
client1.listeners().add(new Listener() {
@@ -82,7 +86,9 @@ public class MultipleServerTest extends BaseTest {
connectionOptions2.localChannelName = null;
connectionOptions2.host = host;
+
Client client2 = new Client(connectionOptions2);
+ client2.disableRemoteKeyValidation();
client2.getSerialization().register(String[].class);
addEndPoint(client2);
client2.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/MultipleThreadTest.java b/Dorkbox-Network/test/dorkbox/network/MultipleThreadTest.java
index cba0b38b..9c5295e4 100644
--- a/Dorkbox-Network/test/dorkbox/network/MultipleThreadTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/MultipleThreadTest.java
@@ -41,6 +41,8 @@ public class MultipleThreadTest extends BaseTest {
final Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
+
server.getSerialization().register(String[].class);
server.getSerialization().register(DataClass.class);
addEndPoint(server);
@@ -90,6 +92,8 @@ public class MultipleThreadTest extends BaseTest {
final int index = i;
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
+
this.clients.add(client);
client.getSerialization().register(String[].class);
client.getSerialization().register(DataClass.class);
diff --git a/Dorkbox-Network/test/dorkbox/network/PingPongLocalTest.java b/Dorkbox-Network/test/dorkbox/network/PingPongLocalTest.java
index 2845cbdf..2f88f5fc 100644
--- a/Dorkbox-Network/test/dorkbox/network/PingPongLocalTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/PingPongLocalTest.java
@@ -27,6 +27,7 @@ public class PingPongLocalTest extends BaseTest {
populateData(dataLOCAL);
Server server = new Server();
+ server.disableRemoteKeyValidation();
addEndPoint(server);
register(server.getSerialization());
server.bind(false);
@@ -50,6 +51,7 @@ public class PingPongLocalTest extends BaseTest {
// ----
Client client = new Client();
+ client.disableRemoteKeyValidation();
addEndPoint(client);
register(client.getSerialization());
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/PingPongTest.java b/Dorkbox-Network/test/dorkbox/network/PingPongTest.java
index 2be59fa0..fba02ed8 100644
--- a/Dorkbox-Network/test/dorkbox/network/PingPongTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/PingPongTest.java
@@ -49,6 +49,7 @@ public class PingPongTest extends BaseTest {
populateData(dataUDT, TYPE.UDT);
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
register(server.getSerialization());
server.bind(false);
@@ -91,6 +92,7 @@ public class PingPongTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
register(client.getSerialization());
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/PingTest.java b/Dorkbox-Network/test/dorkbox/network/PingTest.java
index 4e85452d..5bf4078e 100644
--- a/Dorkbox-Network/test/dorkbox/network/PingTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/PingTest.java
@@ -29,12 +29,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.connect(5000);
@@ -60,12 +62,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.connect(5000);
@@ -109,12 +113,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.connect(5000);
@@ -155,12 +161,14 @@ public class PingTest extends BaseTest {
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.connect(5000);
@@ -190,12 +198,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.connect(5000);
diff --git a/Dorkbox-Network/test/dorkbox/network/ReconnectTest.java b/Dorkbox-Network/test/dorkbox/network/ReconnectTest.java
index 229605fb..c5ae1cca 100644
--- a/Dorkbox-Network/test/dorkbox/network/ReconnectTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ReconnectTest.java
@@ -28,6 +28,7 @@ public class ReconnectTest extends BaseTest {
final Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.bind(false);
server.listeners().add(new Listener() {
@@ -47,6 +48,7 @@ public class ReconnectTest extends BaseTest {
final AtomicInteger reconnectCount = new AtomicInteger();
final Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
@Override
diff --git a/Dorkbox-Network/test/dorkbox/network/ReuseTest.java b/Dorkbox-Network/test/dorkbox/network/ReuseTest.java
index 919dd6ce..9be307c6 100644
--- a/Dorkbox-Network/test/dorkbox/network/ReuseTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/ReuseTest.java
@@ -29,6 +29,7 @@ public class ReuseTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.listeners().add(new Listener() {
@Override
@@ -47,6 +48,7 @@ public class ReuseTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
@Override
@@ -91,6 +93,7 @@ public class ReuseTest extends BaseTest {
this.clientCount = new AtomicInteger(0);
Server server = new Server();
+ server.disableRemoteKeyValidation();
addEndPoint(server);
server.listeners().add(new Listener() {
@Override
@@ -108,6 +111,7 @@ public class ReuseTest extends BaseTest {
// ----
Client client = new Client();
+ client.disableRemoteKeyValidation();
addEndPoint(client);
client.listeners().add(new Listener() {
@Override
diff --git a/Dorkbox-Network/test/dorkbox/network/UnregisteredClassTest.java b/Dorkbox-Network/test/dorkbox/network/UnregisteredClassTest.java
index 69967586..b0f2c11b 100644
--- a/Dorkbox-Network/test/dorkbox/network/UnregisteredClassTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/UnregisteredClassTest.java
@@ -42,6 +42,7 @@ public class UnregisteredClassTest extends BaseTest {
populateData(dataUDP, false);
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
server.getSerialization().setRegistrationRequired(false);
addEndPoint(server);
server.bind(false);
@@ -74,6 +75,7 @@ public class UnregisteredClassTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
client.getSerialization().setRegistrationRequired(false);
addEndPoint(client);
client.listeners().add(new Listener() {
diff --git a/Dorkbox-Network/test/dorkbox/network/dns/DnsRecordDecoderTests.java b/Dorkbox-Network/test/dorkbox/network/dns/DnsRecordDecoderTests.java
index 433f7ad5..e2c82a18 100644
--- a/Dorkbox-Network/test/dorkbox/network/dns/DnsRecordDecoderTests.java
+++ b/Dorkbox-Network/test/dorkbox/network/dns/DnsRecordDecoderTests.java
@@ -11,7 +11,6 @@ import io.netty.handler.codec.dns.DnsQuestion;
import io.netty.handler.codec.dns.DnsResource;
import io.netty.handler.codec.dns.DnsResponse;
import io.netty.handler.codec.dns.DnsResponseDecoder;
-import io.netty.handler.codec.dns.DnsType;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@@ -28,8 +27,9 @@ public class DnsRecordDecoderTests {
private static void submitDNS(final String server, final DnsQuestion question) {
final InetSocketAddress dnsServer = new InetSocketAddress(server, 53);
+
DnsClient dnsClient = new DnsClient(dnsServer);
- dnsClient.submitQuestion(question);
+ List answers = dnsClient.submitQuestion(question);
dnsClient.stop();
@@ -41,7 +41,6 @@ public class DnsRecordDecoderTests {
// bootstrap.channel(NioDatagramChannel.class);
// bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
//
-//
// bootstrap.handler(new ChannelInitializer() {
// @Override
// protected void initChannel(DatagramChannel ch) throws Exception {
@@ -134,7 +133,7 @@ public class DnsRecordDecoderTests {
@Test
public void decode_A_Record() {
- submitDNS("resolver1.opendns.com", new DnsQuestion("myip.opendns.com", DnsType.A)); //good
+ // submitDNS("resolver1.opendns.com", new DnsQuestion("myip.opendns.com", DnsType.A)); //good
byte[] data = new byte[] {0,1,-127,-128,0,1,0,1,0,0,0,0,4,109,121,105,112,7,111,112,101,110,100,110,115,
3,99,111,109,0,0,1,0,1,-64,12,0,1,0,1,0,0,0,0,0,4,127,0,0,1};
@@ -165,12 +164,13 @@ public class DnsRecordDecoderTests {
@Test
public void decode_PTR_Record() {
- // i think that the encoder is bad? It doesn't seem like it encodes PTR queries correctly.
-// submitDNS("192.168.42.1", new DnsQuestion("212.58.241.131", DnsType.valueOf(12, "PTR"))); //bad
+ // PTR absolutely MUST end in '.in-addr.arpa' in order for the DNS server to understand it.
+ // our DNS client will FIX THIS, so that end-users do NOT have to know this!
+ // submitDNS("127.0.1.1", new DnsQuestion("204.228.150.3", DnsType.PTR));
- byte[] data = new byte[] {0,1,-127,-125,0,1,0,0,0,1,0,0,3,50,49,50,2,53,56,3,50,52,49,3,49,51,49,0,0,12,0,1,0,0,6,0,1,0,0,7,7,
- 0,64,1,97,12,114,111,111,116,45,115,101,114,118,101,114,115,3,110,101,116,0,5,110,115,116,108,100,12,118,101,114,105,115,105,103,110,45,103,114,
- 115,3,99,111,109,0,120,12,-107,5,0,0,7,8,0,0,3,-124,0,9,58,-128,0,1,81,-128};
+ byte[] data = new byte[] {0,1,-127,-128,0,1,0,1,0,0,0,0,3,50,48,52,3,50,50,56,3,49,53,48,1,51,7,105,110,45,97,100,100,114,4,97,114,112,97,0,0,
+ 12,0,1,-64,12,0,12,0,1,0,0,84,95,0,32,16,110,48,48,51,45,48,48,48,45,48,48,48,45,48,48,48,6,115,116,97,116,105,99,2,
+ 103,101,3,99,111,109,0};
EmbeddedChannel embedder = new EmbeddedChannel(new DnsResponseDecoder());
ByteBuf packet = Unpooled.wrappedBuffer(data);
@@ -186,9 +186,9 @@ public class DnsRecordDecoderTests {
for (DnsResource answer : answers) {
Object record = RecordDecoderFactory.getFactory().decode(dnsResponse, answer);
- if (record instanceof InetAddress) {
- String hostAddress = ((InetAddress)record).getHostAddress();
- assertEquals(hostAddress, "127.0.0.1");
+ if (record instanceof String) {
+ String hostAddress = (String)record;
+ assertEquals(hostAddress, "n003-000-000-000.static.ge.com");
return;
}
}
diff --git a/Dorkbox-Network/test/dorkbox/network/rmi/RmiSendObjectTest.java b/Dorkbox-Network/test/dorkbox/network/rmi/RmiSendObjectTest.java
index f31b4c7d..94879817 100644
--- a/Dorkbox-Network/test/dorkbox/network/rmi/RmiSendObjectTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/rmi/RmiSendObjectTest.java
@@ -31,6 +31,7 @@ public class RmiSendObjectTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
SerializationManager serverSer = server.getSerialization();
register(serverSer);
addEndPoint(server);
@@ -71,6 +72,7 @@ public class RmiSendObjectTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
register(client.getSerialization());
addEndPoint(client);
diff --git a/Dorkbox-Network/test/dorkbox/network/rmi/RmiTest.java b/Dorkbox-Network/test/dorkbox/network/rmi/RmiTest.java
index bc66deef..767a4392 100644
--- a/Dorkbox-Network/test/dorkbox/network/rmi/RmiTest.java
+++ b/Dorkbox-Network/test/dorkbox/network/rmi/RmiTest.java
@@ -34,6 +34,7 @@ public class RmiTest extends BaseTest {
connectionOptions.host = host;
Server server = new Server(connectionOptions);
+ server.disableRemoteKeyValidation();
register(server.getSerialization());
addEndPoint(server);
server.bind(false);
@@ -51,6 +52,7 @@ public class RmiTest extends BaseTest {
// ----
Client client = new Client(connectionOptions);
+ client.disableRemoteKeyValidation();
register(client.getSerialization());
addEndPoint(client);