use of org.xbill.DNS.ResolverConfig in project helios by spotify.
the class HostResolver method create.
static HostResolver create(HeliosClient client) throws InterruptedException, ExecutionException {
final ResolverConfig currentConfig = ResolverConfig.getCurrentConfig();
final Name[] path;
if (currentConfig != null) {
final Name[] possiblePath = currentConfig.searchPath();
if (possiblePath != null) {
path = possiblePath;
} else {
path = EMPTY_PATH;
}
} else {
path = EMPTY_PATH;
}
return new HostResolver(Sets.newHashSet(client.listHosts().get()), path);
}
use of org.xbill.DNS.ResolverConfig in project helios by spotify.
the class Output method shortHostname.
public static String shortHostname(final String host) {
final Name root = Name.fromConstantString(".");
final Name hostname;
try {
hostname = Name.fromString(host, root);
} catch (TextParseException e) {
throw new IllegalArgumentException("Invalid hostname '" + host + "'");
}
final ResolverConfig currentConfig = ResolverConfig.getCurrentConfig();
if (currentConfig != null) {
final Name[] searchPath = currentConfig.searchPath();
if (searchPath != null) {
for (final Name domain : searchPath) {
if (hostname.subdomain(domain)) {
return hostname.relativize(domain).toString();
}
}
}
}
return hostname.toString();
}
Aggregations