Don't resolve IP addresses in the config except for the bind one.

This commit is contained in:
Andrew Steinborn 2019-04-29 01:59:55 -04:00
parent de51ea18cc
commit 472f45df08
3 changed files with 16 additions and 3 deletions

View File

@ -242,7 +242,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
}
public InetSocketAddress getBind() {
return AddressUtil.parseAddress(bind);
return AddressUtil.parseAndResolveAddress(bind);
}
@Override

View File

@ -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)
);

View File

@ -10,12 +10,26 @@ public class AddressUtil {
}
/**
* Attempts to parse an IP address of the form <code>127.0.0.1:25565</code>.
* Attempts to parse an IP address of the form <code>127.0.0.1:25565</code>. 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 <code>127.0.0.1:25565</code>. 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());