From 472f45df0872441d815e4f8e9f92d680d5f49227 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 29 Apr 2019 01:59:55 -0400 Subject: [PATCH] Don't resolve IP addresses in the config except for the bind one. --- .../proxy/config/VelocityConfiguration.java | 2 +- .../proxy/network/ConnectionManager.java | 1 - .../velocitypowered/proxy/util/AddressUtil.java | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java index aa3410cee..806ea190b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java @@ -242,7 +242,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi } public InetSocketAddress getBind() { - return AddressUtil.parseAddress(bind); + return AddressUtil.parseAndResolveAddress(bind); } @Override diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java index fb0a66236..f5ef6ea81 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java @@ -51,7 +51,6 @@ public final class ConnectionManager { this.resolverGroup = new DnsAddressResolverGroup( new DnsNameResolverBuilder() .channelType(this.transportType.datagramChannelClass) - .ttl(300, 86400) .negativeTtl(15) .ndots(1) ); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/util/AddressUtil.java b/proxy/src/main/java/com/velocitypowered/proxy/util/AddressUtil.java index 06fb1cd45..8874509aa 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/util/AddressUtil.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/util/AddressUtil.java @@ -10,12 +10,26 @@ public class AddressUtil { } /** - * Attempts to parse an IP address of the form 127.0.0.1:25565. + * Attempts to parse an IP address of the form 127.0.0.1:25565. The returned + * {@link InetSocketAddress} is not resolved. * * @param ip the IP to parse * @return the parsed address */ public static InetSocketAddress parseAddress(String ip) { + Preconditions.checkNotNull(ip, "ip"); + URI uri = URI.create("tcp://" + ip); + return InetSocketAddress.createUnresolved(uri.getHost(), uri.getPort()); + } + + /** + * Attempts to parse an IP address of the form 127.0.0.1:25565. The returned + * {@link InetSocketAddress} is resolved. + * + * @param ip the IP to parse + * @return the parsed address + */ + public static InetSocketAddress parseAndResolveAddress(String ip) { Preconditions.checkNotNull(ip, "ip"); URI uri = URI.create("tcp://" + ip); return new InetSocketAddress(uri.getHost(), uri.getPort());