13
0
geforkt von Mirrors/Velocity

Add asynchronous DNS resolution.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-24 07:37:59 -05:00
Ursprung e71bac2028
Commit 4a872ffabe
2 geänderte Dateien mit 10 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -33,6 +33,7 @@ dependencies {
compile "io.netty:netty-transport-native-epoll:${nettyVersion}" compile "io.netty:netty-transport-native-epoll:${nettyVersion}"
compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64" compile "io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64"
compile "io.netty:netty-transport-native-kqueue:${nettyVersion}:osx-x86_64" compile "io.netty:netty-transport-native-kqueue:${nettyVersion}:osx-x86_64"
compile "io.netty:netty-resolver-dns:${nettyVersion}"
compile "org.apache.logging.log4j:log4j-api:${log4jVersion}" compile "org.apache.logging.log4j:log4j-api:${log4jVersion}"
compile "org.apache.logging.log4j:log4j-core:${log4jVersion}" compile "org.apache.logging.log4j:log4j-core:${log4jVersion}"

Datei anzeigen

@ -11,6 +11,9 @@ import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelOption; import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup; import io.netty.channel.EventLoopGroup;
import io.netty.channel.WriteBufferWaterMark; import io.netty.channel.WriteBufferWaterMark;
import io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider;
import io.netty.resolver.dns.DnsAddressResolverGroup;
import io.netty.resolver.dns.MultiDnsServerAddressStreamProvider;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -31,6 +34,8 @@ public final class ConnectionManager {
private final VelocityServer server; private final VelocityServer server;
public final ServerChannelInitializerHolder serverChannelInitializer; public final ServerChannelInitializerHolder serverChannelInitializer;
private final DnsAddressResolverGroup resolverGroup;
public ConnectionManager(VelocityServer server) { public ConnectionManager(VelocityServer server) {
this.server = server; this.server = server;
this.transportType = TransportType.bestType(); this.transportType = TransportType.bestType();
@ -38,6 +43,8 @@ public final class ConnectionManager {
this.workerGroup = this.transportType.createEventLoopGroup(TransportType.Type.WORKER); this.workerGroup = this.transportType.createEventLoopGroup(TransportType.Type.WORKER);
this.serverChannelInitializer = new ServerChannelInitializerHolder( this.serverChannelInitializer = new ServerChannelInitializerHolder(
new ServerChannelInitializer(this.server)); new ServerChannelInitializer(this.server));
this.resolverGroup = new DnsAddressResolverGroup(this.transportType.datagramChannelClass,
DefaultDnsServerAddressStreamProvider.INSTANCE);
} }
public void logChannelInformation() { public void logChannelInformation() {
@ -91,7 +98,8 @@ public final class ConnectionManager {
.group(this.workerGroup) .group(this.workerGroup)
.option(ChannelOption.TCP_NODELAY, true) .option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, .option(ChannelOption.CONNECT_TIMEOUT_MILLIS,
this.server.getConfiguration().getConnectTimeout()); this.server.getConfiguration().getConnectTimeout())
.resolver(this.resolverGroup);
} }
public void close(InetSocketAddress oldBind) { public void close(InetSocketAddress oldBind) {