Fixed DNS client for PTR records. Fixed test examples to not enforce saved/verified endpoint keys
This commit is contained in:
parent
913dae7933
commit
6da536ddd4
@ -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.
|
||||
@ -122,12 +126,21 @@ public class Client extends EndPointClient {
|
||||
// android ONLY supports OIO (not NIO)
|
||||
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
|
||||
tcpBootstrap.channel(OioSocketChannel.class);
|
||||
} else {
|
||||
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,
|
||||
|
@ -131,16 +131,31 @@ public class DnsClient {
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits a question to the DNS server
|
||||
* Submits a question to the DNS server.
|
||||
* <p>
|
||||
* 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<Object> submitQuestion(final DnsQuestion question) {
|
||||
public synchronized List<Object> 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<Object> promise = GlobalEventExecutor.INSTANCE.newPromise();
|
||||
|
@ -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));
|
||||
@ -158,16 +165,29 @@ public class Server extends EndPointServer {
|
||||
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
|
||||
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
|
||||
this.tcpBootstrap.channel(OioServerSocketChannel.class);
|
||||
} else {
|
||||
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,
|
||||
@ -195,14 +215,24 @@ public class Server extends EndPointServer {
|
||||
// android ONLY supports OIO (not NIO)
|
||||
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
|
||||
this.udpBootstrap.channel(OioDatagramChannel.class);
|
||||
} else {
|
||||
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,
|
||||
|
@ -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);
|
||||
|
@ -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<EventLoopGroup> eventLoopGroups = new ArrayList<EventLoopGroup>(8);
|
||||
private List<ChannelFuture> shutdownChannelList = new ArrayList<ChannelFuture>();
|
||||
|
||||
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<EventLoopGroup> 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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,18 @@ public abstract class ListenerRaw<C extends Connection, M extends Object> {
|
||||
// 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;
|
||||
|
@ -194,10 +194,8 @@ class PropertyStore extends SettingsStore {
|
||||
return remove != null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
Storage.close(this.storage);
|
||||
super.shutdown();
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<Data>() {
|
||||
|
@ -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);
|
||||
|
@ -118,6 +118,7 @@ public class ConnectionTest extends BaseTest {
|
||||
server = new Server();
|
||||
}
|
||||
|
||||
server.disableRemoteKeyValidation();
|
||||
addEndPoint(server);
|
||||
server.bind(false);
|
||||
server.listeners().add(new Listener<Object>() {
|
||||
@ -145,6 +146,7 @@ public class ConnectionTest extends BaseTest {
|
||||
} else {
|
||||
client = new Client();
|
||||
}
|
||||
client.disableRemoteKeyValidation();
|
||||
addEndPoint(client);
|
||||
|
||||
client.listeners().add(new Listener<Object>() {
|
||||
|
@ -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<Object>() {
|
||||
@Override
|
||||
|
@ -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<Data>() {
|
||||
@ -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<byte[]>() {
|
||||
|
@ -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);
|
||||
|
@ -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<String>() {
|
||||
@Override
|
||||
|
@ -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<String>() {
|
||||
@ -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<String>() {
|
||||
|
@ -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);
|
||||
|
@ -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<Data>() {
|
||||
|
@ -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<Data>() {
|
||||
|
@ -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);
|
||||
|
@ -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<Object>() {
|
||||
@ -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<Object>() {
|
||||
@Override
|
||||
|
@ -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<String>() {
|
||||
@Override
|
||||
@ -47,6 +48,7 @@ public class ReuseTest extends BaseTest {
|
||||
// ----
|
||||
|
||||
Client client = new Client(connectionOptions);
|
||||
client.disableRemoteKeyValidation();
|
||||
addEndPoint(client);
|
||||
client.listeners().add(new Listener<String>() {
|
||||
@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<String>() {
|
||||
@Override
|
||||
@ -108,6 +111,7 @@ public class ReuseTest extends BaseTest {
|
||||
// ----
|
||||
|
||||
Client client = new Client();
|
||||
client.disableRemoteKeyValidation();
|
||||
addEndPoint(client);
|
||||
client.listeners().add(new Listener<String>() {
|
||||
@Override
|
||||
|
@ -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<Data>() {
|
||||
|
@ -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<Object> 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<DatagramChannel>() {
|
||||
// @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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user