Fixed DNS client for PTR records. Fixed test examples to not enforce saved/verified endpoint keys

This commit is contained in:
nathan 2014-09-30 17:55:13 +02:00
parent 913dae7933
commit 6da536ddd4
27 changed files with 184 additions and 62 deletions

View File

@ -1,10 +1,13 @@
package dorkbox.network; package dorkbox.network;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup; 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.LocalAddress;
import io.netty.channel.local.LocalChannel; import io.netty.channel.local.LocalChannel;
import io.netty.channel.nio.NioEventLoopGroup; 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.exceptions.SecurityException;
import dorkbox.network.util.udt.UdtEndpointProxy; import dorkbox.network.util.udt.UdtEndpointProxy;
import dorkbox.util.NamedThreadFactory; 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. * 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) // android ONLY supports OIO (not NIO)
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-TCP", nettyGroup)); boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
tcpBootstrap.channel(OioSocketChannel.class); 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 { } else {
boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-TCP", nettyGroup)); boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-TCP", nettyGroup));
tcpBootstrap.channel(NioSocketChannel.class); tcpBootstrap.channel(NioSocketChannel.class);
} }
}
tcpBootstrap.group(boss) tcpBootstrap.group(boss)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.remoteAddress(options.host, options.tcpPort) .remoteAddress(options.host, options.tcpPort)
.handler(new RegistrationRemoteHandlerClientTCP(this.name, .handler(new RegistrationRemoteHandlerClientTCP(this.name,
this.registrationWrapper, this.registrationWrapper,
@ -153,11 +166,14 @@ public class Client extends EndPointClient {
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-UDP", nettyGroup)); boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-UDP", nettyGroup));
udpBootstrap.channel(OioDatagramChannel.class); udpBootstrap.channel(OioDatagramChannel.class);
} else { } else {
// CANNOT USE EpollDatagramChannel on the client!
boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-UDP", nettyGroup)); boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-UDP", nettyGroup));
udpBootstrap.channel(NioDatagramChannel.class); udpBootstrap.channel(NioDatagramChannel.class);
} }
udpBootstrap.group(boss) udpBootstrap.group(boss)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.localAddress(new InetSocketAddress(0)) .localAddress(new InetSocketAddress(0))
.remoteAddress(new InetSocketAddress(options.host, options.udpPort)) .remoteAddress(new InetSocketAddress(options.host, options.udpPort))
.handler(new RegistrationRemoteHandlerClientUDP(this.name, .handler(new RegistrationRemoteHandlerClientUDP(this.name,
@ -201,6 +217,7 @@ public class Client extends EndPointClient {
UdtEndpointProxy.setChannelFactory(udtBootstrap); UdtEndpointProxy.setChannelFactory(udtBootstrap);
udtBootstrap.group(boss) udtBootstrap.group(boss)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.remoteAddress(options.host, options.udtPort) .remoteAddress(options.host, options.udtPort)
.handler(new RegistrationRemoteHandlerClientUDT(this.name, .handler(new RegistrationRemoteHandlerClientUDT(this.name,
this.registrationWrapper, this.registrationWrapper,

View File

@ -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. * @return always non-null, a list of answers from the server. Am empty list can also mean there was an error.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public synchronized List<Object> submitQuestion(final DnsQuestion question) { public synchronized List<Object> submitQuestion(DnsQuestion question) {
if (this.dnsServer == null) { if (this.dnsServer == null) {
this.logger.error("Cannot submit query. There was no connection to the DNS server."); this.logger.error("Cannot submit query. There was no connection to the DNS server.");
return Collections.EMPTY_LIST; 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); DnsQuery query = new DnsQuery(ThreadLocalRandom.current().nextInt(), this.dnsServer).addQuestion(question);
final Promise<Object> promise = GlobalEventExecutor.INSTANCE.newPromise(); final Promise<Object> promise = GlobalEventExecutor.INSTANCE.newPromise();

View File

@ -2,10 +2,15 @@ package dorkbox.network;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
import io.netty.bootstrap.ServerBootstrap; import io.netty.bootstrap.ServerBootstrap;
import io.netty.buffer.PooledByteBufAllocator;
import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.DefaultEventLoopGroup;
import io.netty.channel.EventLoopGroup; 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.LocalAddress;
import io.netty.channel.local.LocalServerChannel; import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup; 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.exceptions.SecurityException;
import dorkbox.network.util.udt.UdtEndpointProxy; import dorkbox.network.util.udt.UdtEndpointProxy;
import dorkbox.util.NamedThreadFactory; import dorkbox.util.NamedThreadFactory;
import dorkbox.util.OS;
/** /**
@ -140,6 +146,7 @@ public class Server extends EndPointServer {
this.localBootstrap.group(boss, worker) this.localBootstrap.group(boss, worker)
.channel(LocalServerChannel.class) .channel(LocalServerChannel.class)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.localAddress(new LocalAddress(this.localChannelName)) .localAddress(new LocalAddress(this.localChannelName))
.childHandler(new RegistrationLocalHandlerServer(this.name, .childHandler(new RegistrationLocalHandlerServer(this.name,
this.registrationWrapper)); this.registrationWrapper));
@ -158,16 +165,29 @@ public class Server extends EndPointServer {
boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup)); boss = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup));
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup)); worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
this.tcpBootstrap.channel(OioServerSocketChannel.class); 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 { } else {
boss = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-boss-TCP", nettyGroup)); 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)); worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-TCP", nettyGroup));
this.tcpBootstrap.channel(NioServerSocketChannel.class); 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(boss);
manageForShutdown(worker); manageForShutdown(worker);
this.tcpBootstrap.group(boss, worker) this.tcpBootstrap.group(boss, worker)
.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
.option(ChannelOption.SO_BACKLOG, backlogConnectionCount) .option(ChannelOption.SO_BACKLOG, backlogConnectionCount)
.option(ChannelOption.SO_REUSEADDR, true) .option(ChannelOption.SO_REUSEADDR, true)
.childHandler(new RegistrationRemoteHandlerServerTCP(this.name, .childHandler(new RegistrationRemoteHandlerServerTCP(this.name,
@ -195,14 +215,24 @@ public class Server extends EndPointServer {
// android ONLY supports OIO (not NIO) // android ONLY supports OIO (not NIO)
worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup)); worker = new OioEventLoopGroup(0, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
this.udpBootstrap.channel(OioDatagramChannel.class); 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 { } else {
worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup)); worker = new NioEventLoopGroup(DEFAULT_THREAD_POOL_SIZE, new NamedThreadFactory(this.name + "-worker-UDP", nettyGroup));
this.udpBootstrap.channel(NioDatagramChannel.class); this.udpBootstrap.channel(NioDatagramChannel.class);
} }
}
manageForShutdown(worker); manageForShutdown(worker);
this.udpBootstrap.group(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 // 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! .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)); .handler(new RegistrationRemoteHandlerServerUDP(this.name, this.registrationWrapper, this.serializationManager));
@ -233,6 +263,7 @@ public class Server extends EndPointServer {
UdtEndpointProxy.setChannelFactory(this.udtBootstrap); UdtEndpointProxy.setChannelFactory(this.udtBootstrap);
this.udtBootstrap.group(boss, worker) this.udtBootstrap.group(boss, worker)
.option(ChannelOption.SO_BACKLOG, backlogConnectionCount) .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 // not binding to specific address, since it's driven by TCP, and that can be bound to a specific address
.localAddress(this.udtPort) .localAddress(this.udtPort)
.childHandler(new RegistrationRemoteHandlerServerUDT(this.name, .childHandler(new RegistrationRemoteHandlerServerUDT(this.name,

View File

@ -4,6 +4,8 @@ import io.netty.channel.Channel;
import io.netty.channel.ChannelHandler.Sharable; import io.netty.channel.ChannelHandler.Sharable;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; 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.local.LocalChannel;
import io.netty.channel.socket.nio.NioDatagramChannel; import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
@ -389,16 +391,22 @@ public class ConnectionImpl extends ChannelInboundHandlerAdapter
} }
Channel channel = context.channel(); Channel channel = context.channel();
Class<? extends Channel> channelClass = channel.getClass();
boolean isTCP = channelClass == NioSocketChannel.class || channelClass == EpollSocketChannel.class;
if (this.logger.isInfoEnabled()) { if (this.logger.isInfoEnabled()) {
String type; String type;
if (channel instanceof NioSocketChannel) {
if (isTCP) {
type = "TCP"; type = "TCP";
} else if (channel instanceof NioDatagramChannel) { } else if (channelClass == NioDatagramChannel.class) {
type = "UDP"; type = "UDP";
} else if (channel instanceof NioUdtByteConnectorChannel) { } else if (channelClass == EpollDatagramChannel.class) {
type = "UDP";
} else if (channelClass == NioUdtByteConnectorChannel.class) {
type = "UDT"; type = "UDT";
} else if (channel instanceof LocalChannel) { } else if (channelClass == LocalChannel.class) {
type = "LOCAL"; type = "LOCAL";
} else { } else {
type = "UNKNOWN"; 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. // 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. // this is because channelInactive can ONLY happen when netty shuts down the channel.
// and connection.close() can be called by the user. // and connection.close() can be called by the user.
this.sessionManager.connectionDisconnected(this); this.sessionManager.connectionDisconnected(this);

View File

@ -13,7 +13,7 @@ import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Semaphore; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair; import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
@ -122,7 +122,7 @@ public abstract class EndPoint {
private List<EventLoopGroup> eventLoopGroups = new ArrayList<EventLoopGroup>(8); private List<EventLoopGroup> eventLoopGroups = new ArrayList<EventLoopGroup>(8);
private List<ChannelFuture> shutdownChannelList = new ArrayList<ChannelFuture>(); 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 final Object shutdownInProgress = new Object();
protected AtomicBoolean isConnected = new AtomicBoolean(false); protected AtomicBoolean isConnected = new AtomicBoolean(false);
@ -338,22 +338,8 @@ public abstract class EndPoint {
String threadName = currentThread.getName(); String threadName = currentThread.getName();
boolean inEventThread = !threadName.equals(shutdownHookName) && !threadName.equals(stopTreadName); boolean inEventThread = !threadName.equals(shutdownHookName) && !threadName.equals(stopTreadName);
// we must also account for the shutdown hook calling this! // used to check the event groups to see if we are running from one of them. NOW we force to
// if we are in the shutdown hook, then we cannot possibly be in our event thread // ALWAYS shutdown inside a NEW 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;
}
}
}
}
if (!inEventThread) { if (!inEventThread) {
stopInThread(); 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 // This actually does the "stopping", since there is some logic to making sure we don't deadlock, this is important
private final void stopInThread() { 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. // make sure we are not trying to stop during a startup procedure.
// This will wait until we have finished starting up/shutting down. // This will wait until we have finished starting up/shutting down.
synchronized (this.shutdownInProgress) { synchronized (this.shutdownInProgress) {
@ -415,7 +398,6 @@ public abstract class EndPoint {
// shutdown the database store // shutdown the database store
this.propertyStore.shutdown(); this.propertyStore.shutdown();
// now we stop all of our channels // now we stop all of our channels
for (ChannelFuture f : this.shutdownChannelList) { for (ChannelFuture f : this.shutdownChannelList) {
Channel channel = f.channel(); Channel channel = f.channel();
@ -439,6 +421,9 @@ public abstract class EndPoint {
// when the eventloop closes, the associated selectors are ALSO closed! // 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 * @param blockUntilTerminate if TRUE, then this endpoint will block until STOP is called, otherwise it will not block
*/ */
public final void waitForStop(boolean blockUntilTerminate) { public final void waitForStop(boolean blockUntilTerminate) {
if (blockUntilTerminate) { if (blockUntilTerminate) {
// we now BLOCK until the stop method is called. // we now BLOCK until the stop method is called.
try { try {
this.blockUntilDone.acquire(); this.blockUntilDone.await();
} catch (InterruptedException e) { } catch (InterruptedException e) {
this.logger.error("Thread interrupted while waiting for stop!");
} }
} }
} }

View File

@ -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. // for sub-classed listeners, we might have to specify which parameter to use.
protected ListenerRaw(int lastParameterIndex) { protected ListenerRaw(int lastParameterIndex) {
if (lastParameterIndex > -1) { 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) { if (objectType != null) {
// SOMETIMES generics get confused on which parameter we actually mean (when sub-classing) // SOMETIMES generics get confused on which parameter we actually mean (when sub-classing)
if (objectType.isAssignableFrom(Connection.class)) { if (objectType != Object.class && ClassHelper.hasInterface(Connection.class, objectType)) {
objectType = ClassHelper.getGenericParameterAsClassForSuperClass(getClass(), lastParameterIndex+1); Class<?> objectType2 = ClassHelper.getGenericParameterAsClassForSuperClass(class1, lastParameterIndex+1);
if (objectType2 != null) {
objectType = objectType2;
}
} }
this.objectType = objectType; this.objectType = objectType;

View File

@ -194,10 +194,8 @@ class PropertyStore extends SettingsStore {
return remove != null; return remove != null;
} }
@Override @Override
public void shutdown() { public void shutdown() {
Storage.close(this.storage); Storage.close(this.storage);
super.shutdown();
} }
} }

View File

@ -3,6 +3,8 @@ package dorkbox.network.connection.registration.remote;
import io.netty.channel.Channel; import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline; 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.NioDatagramChannel;
import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.channel.udt.nio.NioUdtByteConnectorChannel; 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. // add the channel so we can access it later.
// do NOT want to add UDP channels, since they are tracked differently. // 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(); Channel channel = context.channel();
Class<? extends Channel> channelClass = channel.getClass();
StringBuilder stringBuilder = new StringBuilder(76); StringBuilder stringBuilder = new StringBuilder(76);
stringBuilder.append("Connected to remote "); stringBuilder.append("Connected to remote ");
if (channel instanceof NioSocketChannel) { if (channelClass == NioSocketChannel.class) {
stringBuilder.append("TCP"); stringBuilder.append("TCP");
} else if (channel instanceof NioDatagramChannel) { } else if (channelClass == EpollSocketChannel.class) {
stringBuilder.append("TCP");
} else if (channelClass == NioDatagramChannel.class) {
stringBuilder.append("UDP"); stringBuilder.append("UDP");
} else if (channel instanceof NioUdtByteConnectorChannel) { } else if (channelClass == EpollDatagramChannel.class) {
stringBuilder.append("UDP");
} else if (channelClass == NioUdtByteConnectorChannel.class) {
stringBuilder.append("UDT"); stringBuilder.append("UDT");
} }
else { else {

View File

@ -7,7 +7,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import dorkbox.network.util.exceptions.SecurityException; 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) * 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. * Take the proper steps to shutdown the storage system.
*/ */
public void shutdown() { public abstract void shutdown();
Storage.shutdown();
}
} }

View File

@ -56,6 +56,7 @@ public class ChunkedDataTest extends BaseTest {
private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException { private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
register(server.getSerialization()); register(server.getSerialization());
addEndPoint(server); addEndPoint(server);
server.setIdleTimeout(100); server.setIdleTimeout(100);
@ -80,6 +81,7 @@ public class ChunkedDataTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
register(client.getSerialization()); register(client.getSerialization());
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Data>() { client.listeners().add(new Listener<Data>() {

View File

@ -26,6 +26,7 @@ public class ClientSendTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
register(server.getSerialization()); register(server.getSerialization());
@ -39,6 +40,7 @@ public class ClientSendTest extends BaseTest {
}); });
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
register(client.getSerialization()); register(client.getSerialization());
client.connect(5000); client.connect(5000);

View File

@ -118,6 +118,7 @@ public class ConnectionTest extends BaseTest {
server = new Server(); server = new Server();
} }
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
server.listeners().add(new Listener<Object>() { server.listeners().add(new Listener<Object>() {
@ -145,6 +146,7 @@ public class ConnectionTest extends BaseTest {
} else { } else {
client = new Client(); client = new Client();
} }
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Object>() { client.listeners().add(new Listener<Object>() {

View File

@ -25,6 +25,7 @@ public class DiscoverHostTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
@ -38,6 +39,7 @@ public class DiscoverHostTest extends BaseTest {
} }
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Object>() { client.listeners().add(new Listener<Object>() {
@Override @Override

View File

@ -93,6 +93,7 @@ public class IdleTest extends BaseTest {
private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException { private void sendObject(final Data mainData, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
register(server.getSerialization()); register(server.getSerialization());
addEndPoint(server); addEndPoint(server);
server.setIdleTimeout(100); server.setIdleTimeout(100);
@ -114,6 +115,7 @@ public class IdleTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
register(client.getSerialization()); register(client.getSerialization());
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Data>() { 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 { private void streamSpecificType(final int largeDataSize, ConnectionOptions connectionOptions, final ConnectionType type) throws InitializationException, SecurityException {
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
server.getSerialization().setRegistrationRequired(false); server.getSerialization().setRegistrationRequired(false);
addEndPoint(server); addEndPoint(server);
server.setIdleTimeout(100); server.setIdleTimeout(100);
@ -180,6 +183,7 @@ public class IdleTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
client.getSerialization().setRegistrationRequired(false); client.getSerialization().setRegistrationRequired(false);
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<byte[]>() { client.listeners().add(new Listener<byte[]>() {

View File

@ -33,6 +33,7 @@ public class LargeBufferTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
register(server.getSerialization()); register(server.getSerialization());
@ -58,6 +59,7 @@ public class LargeBufferTest extends BaseTest {
}); });
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
register(client.getSerialization()); register(client.getSerialization());
client.connect(5000); client.connect(5000);

View File

@ -70,6 +70,7 @@ public class ListenerTest extends BaseTest {
} }
}; };
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
@ -137,6 +138,7 @@ public class ListenerTest extends BaseTest {
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<String>() { client.listeners().add(new Listener<String>() {
@Override @Override

View File

@ -26,6 +26,7 @@ public class MultipleServerTest extends BaseTest {
Server server1 = new Server(connectionOptions1); Server server1 = new Server(connectionOptions1);
server1.disableRemoteKeyValidation();
server1.getSerialization().register(String[].class); server1.getSerialization().register(String[].class);
addEndPoint(server1); addEndPoint(server1);
@ -49,6 +50,7 @@ public class MultipleServerTest extends BaseTest {
Server server2 = new Server(connectionOptions2); Server server2 = new Server(connectionOptions2);
server2.disableRemoteKeyValidation();
server2.getSerialization().register(String[].class); server2.getSerialization().register(String[].class);
addEndPoint(server2); addEndPoint(server2);
server2.bind(false); server2.bind(false);
@ -68,7 +70,9 @@ public class MultipleServerTest extends BaseTest {
connectionOptions1.localChannelName = null; connectionOptions1.localChannelName = null;
connectionOptions1.host = host; connectionOptions1.host = host;
Client client1 = new Client(connectionOptions1); Client client1 = new Client(connectionOptions1);
client1.disableRemoteKeyValidation();
client1.getSerialization().register(String[].class); client1.getSerialization().register(String[].class);
addEndPoint(client1); addEndPoint(client1);
client1.listeners().add(new Listener<String>() { client1.listeners().add(new Listener<String>() {
@ -82,7 +86,9 @@ public class MultipleServerTest extends BaseTest {
connectionOptions2.localChannelName = null; connectionOptions2.localChannelName = null;
connectionOptions2.host = host; connectionOptions2.host = host;
Client client2 = new Client(connectionOptions2); Client client2 = new Client(connectionOptions2);
client2.disableRemoteKeyValidation();
client2.getSerialization().register(String[].class); client2.getSerialization().register(String[].class);
addEndPoint(client2); addEndPoint(client2);
client2.listeners().add(new Listener<String>() { client2.listeners().add(new Listener<String>() {

View File

@ -41,6 +41,8 @@ public class MultipleThreadTest extends BaseTest {
final Server server = new Server(connectionOptions); final Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
server.getSerialization().register(String[].class); server.getSerialization().register(String[].class);
server.getSerialization().register(DataClass.class); server.getSerialization().register(DataClass.class);
addEndPoint(server); addEndPoint(server);
@ -90,6 +92,8 @@ public class MultipleThreadTest extends BaseTest {
final int index = i; final int index = i;
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
this.clients.add(client); this.clients.add(client);
client.getSerialization().register(String[].class); client.getSerialization().register(String[].class);
client.getSerialization().register(DataClass.class); client.getSerialization().register(DataClass.class);

View File

@ -27,6 +27,7 @@ public class PingPongLocalTest extends BaseTest {
populateData(dataLOCAL); populateData(dataLOCAL);
Server server = new Server(); Server server = new Server();
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
register(server.getSerialization()); register(server.getSerialization());
server.bind(false); server.bind(false);
@ -50,6 +51,7 @@ public class PingPongLocalTest extends BaseTest {
// ---- // ----
Client client = new Client(); Client client = new Client();
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
register(client.getSerialization()); register(client.getSerialization());
client.listeners().add(new Listener<Data>() { client.listeners().add(new Listener<Data>() {

View File

@ -49,6 +49,7 @@ public class PingPongTest extends BaseTest {
populateData(dataUDT, TYPE.UDT); populateData(dataUDT, TYPE.UDT);
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
register(server.getSerialization()); register(server.getSerialization());
server.bind(false); server.bind(false);
@ -91,6 +92,7 @@ public class PingPongTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
register(client.getSerialization()); register(client.getSerialization());
client.listeners().add(new Listener<Data>() { client.listeners().add(new Listener<Data>() {

View File

@ -29,12 +29,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.connect(5000); client.connect(5000);
@ -60,12 +62,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.connect(5000); client.connect(5000);
@ -109,12 +113,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.connect(5000); client.connect(5000);
@ -155,12 +161,14 @@ public class PingTest extends BaseTest {
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.connect(5000); client.connect(5000);
@ -190,12 +198,14 @@ public class PingTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.connect(5000); client.connect(5000);

View File

@ -28,6 +28,7 @@ public class ReconnectTest extends BaseTest {
final Server server = new Server(connectionOptions); final Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
server.listeners().add(new Listener<Object>() { server.listeners().add(new Listener<Object>() {
@ -47,6 +48,7 @@ public class ReconnectTest extends BaseTest {
final AtomicInteger reconnectCount = new AtomicInteger(); final AtomicInteger reconnectCount = new AtomicInteger();
final Client client = new Client(connectionOptions); final Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Object>() { client.listeners().add(new Listener<Object>() {
@Override @Override

View File

@ -29,6 +29,7 @@ public class ReuseTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.listeners().add(new Listener<String>() { server.listeners().add(new Listener<String>() {
@Override @Override
@ -47,6 +48,7 @@ public class ReuseTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<String>() { client.listeners().add(new Listener<String>() {
@Override @Override
@ -91,6 +93,7 @@ public class ReuseTest extends BaseTest {
this.clientCount = new AtomicInteger(0); this.clientCount = new AtomicInteger(0);
Server server = new Server(); Server server = new Server();
server.disableRemoteKeyValidation();
addEndPoint(server); addEndPoint(server);
server.listeners().add(new Listener<String>() { server.listeners().add(new Listener<String>() {
@Override @Override
@ -108,6 +111,7 @@ public class ReuseTest extends BaseTest {
// ---- // ----
Client client = new Client(); Client client = new Client();
client.disableRemoteKeyValidation();
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<String>() { client.listeners().add(new Listener<String>() {
@Override @Override

View File

@ -42,6 +42,7 @@ public class UnregisteredClassTest extends BaseTest {
populateData(dataUDP, false); populateData(dataUDP, false);
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
server.getSerialization().setRegistrationRequired(false); server.getSerialization().setRegistrationRequired(false);
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
@ -74,6 +75,7 @@ public class UnregisteredClassTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
client.getSerialization().setRegistrationRequired(false); client.getSerialization().setRegistrationRequired(false);
addEndPoint(client); addEndPoint(client);
client.listeners().add(new Listener<Data>() { client.listeners().add(new Listener<Data>() {

View File

@ -11,7 +11,6 @@ import io.netty.handler.codec.dns.DnsQuestion;
import io.netty.handler.codec.dns.DnsResource; import io.netty.handler.codec.dns.DnsResource;
import io.netty.handler.codec.dns.DnsResponse; import io.netty.handler.codec.dns.DnsResponse;
import io.netty.handler.codec.dns.DnsResponseDecoder; import io.netty.handler.codec.dns.DnsResponseDecoder;
import io.netty.handler.codec.dns.DnsType;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -28,8 +27,9 @@ public class DnsRecordDecoderTests {
private static void submitDNS(final String server, final DnsQuestion question) { private static void submitDNS(final String server, final DnsQuestion question) {
final InetSocketAddress dnsServer = new InetSocketAddress(server, 53); final InetSocketAddress dnsServer = new InetSocketAddress(server, 53);
DnsClient dnsClient = new DnsClient(dnsServer); DnsClient dnsClient = new DnsClient(dnsServer);
dnsClient.submitQuestion(question); List<Object> answers = dnsClient.submitQuestion(question);
dnsClient.stop(); dnsClient.stop();
@ -41,7 +41,6 @@ public class DnsRecordDecoderTests {
// bootstrap.channel(NioDatagramChannel.class); // bootstrap.channel(NioDatagramChannel.class);
// bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); // bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
// //
//
// bootstrap.handler(new ChannelInitializer<DatagramChannel>() { // bootstrap.handler(new ChannelInitializer<DatagramChannel>() {
// @Override // @Override
// protected void initChannel(DatagramChannel ch) throws Exception { // protected void initChannel(DatagramChannel ch) throws Exception {
@ -134,7 +133,7 @@ public class DnsRecordDecoderTests {
@Test @Test
public void decode_A_Record() { 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, 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}; 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 @Test
public void decode_PTR_Record() { public void decode_PTR_Record() {
// i think that the encoder is bad? It doesn't seem like it encodes PTR queries correctly. // PTR absolutely MUST end in '.in-addr.arpa' in order for the DNS server to understand it.
// submitDNS("192.168.42.1", new DnsQuestion("212.58.241.131", DnsType.valueOf(12, "PTR"))); //bad // 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, 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,
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, 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,
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}; 103,101,3,99,111,109,0};
EmbeddedChannel embedder = new EmbeddedChannel(new DnsResponseDecoder()); EmbeddedChannel embedder = new EmbeddedChannel(new DnsResponseDecoder());
ByteBuf packet = Unpooled.wrappedBuffer(data); ByteBuf packet = Unpooled.wrappedBuffer(data);
@ -186,9 +186,9 @@ public class DnsRecordDecoderTests {
for (DnsResource answer : answers) { for (DnsResource answer : answers) {
Object record = RecordDecoderFactory.getFactory().decode(dnsResponse, answer); Object record = RecordDecoderFactory.getFactory().decode(dnsResponse, answer);
if (record instanceof InetAddress) { if (record instanceof String) {
String hostAddress = ((InetAddress)record).getHostAddress(); String hostAddress = (String)record;
assertEquals(hostAddress, "127.0.0.1"); assertEquals(hostAddress, "n003-000-000-000.static.ge.com");
return; return;
} }
} }

View File

@ -31,6 +31,7 @@ public class RmiSendObjectTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
SerializationManager serverSer = server.getSerialization(); SerializationManager serverSer = server.getSerialization();
register(serverSer); register(serverSer);
addEndPoint(server); addEndPoint(server);
@ -71,6 +72,7 @@ public class RmiSendObjectTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
register(client.getSerialization()); register(client.getSerialization());
addEndPoint(client); addEndPoint(client);

View File

@ -34,6 +34,7 @@ public class RmiTest extends BaseTest {
connectionOptions.host = host; connectionOptions.host = host;
Server server = new Server(connectionOptions); Server server = new Server(connectionOptions);
server.disableRemoteKeyValidation();
register(server.getSerialization()); register(server.getSerialization());
addEndPoint(server); addEndPoint(server);
server.bind(false); server.bind(false);
@ -51,6 +52,7 @@ public class RmiTest extends BaseTest {
// ---- // ----
Client client = new Client(connectionOptions); Client client = new Client(connectionOptions);
client.disableRemoteKeyValidation();
register(client.getSerialization()); register(client.getSerialization());
addEndPoint(client); addEndPoint(client);