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); }
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(); }
protected void storeDNSRecord(final CrawlURI curi, final String dnsName, final CrawlHost targetHost, final Record[] rrecordSet) { // Get TTL and IP info from the first A record (there may be // multiple, e.g. www.washington.edu) then update the CrawlServer ARecord arecord = getFirstARecord(rrecordSet); if (arecord == null) { throw new NullPointerException("Got null arecord for " + dnsName); } targetHost.setIP(arecord.getAddress(), arecord.getTTL()); try { recordDNS(curi, rrecordSet); curi.setFetchStatus(S_DNS_SUCCESS); curi.setDNSServerIPLabel(ResolverConfig.getCurrentConfig().server()); } catch (IOException e) { logger.log(Level.SEVERE, "Failed store of DNS Record for " + curi.toString(), e); setUnresolvable(curi, targetHost); } }
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); defaultNdots = ResolverConfig.getCurrentConfig().ndots(); }
/** * Constructor */ public LdapPublicCertUtilImpl(){ String[] configedServers = ResolverConfig.getCurrentConfig().servers(); if (configedServers != null) { this.servers.addAll(Arrays.asList(configedServers)); } }
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); defaultNdots = ResolverConfig.getCurrentConfig().ndots(); }
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); defaultNdots = ResolverConfig.getCurrentConfig().ndots(); }
public static void setServers(String[] servers) { if (servers == null || servers.length == 0) { String[] configedServers = ResolverConfig.getCurrentConfig().servers(); if (configedServers != null) { dnsServers.addAll(Arrays.asList(configedServers)); } } else { dnsServers.clear(); dnsServers.addAll(Arrays.asList(servers)); } }
/** * Creates a SimpleResolver that will query the specified host * @exception UnknownHostException Failure occurred while finding the host */ public SimpleResolver(String hostname) throws UnknownHostException { if (hostname == null) { hostname = ResolverConfig.getCurrentConfig().server(); if (hostname == null) hostname = defaultResolver; } InetAddress addr; if (hostname.equals("0")) addr = InetAddress.getLocalHost(); else addr = InetAddress.getByName(hostname); address = new InetSocketAddress(addr, DEFAULT_PORT); }
public static synchronized void refreshDefault() { try { defaultResolver = new ExtendedResolver(); } catch (UnknownHostException e) { throw new RuntimeException("Failed to initialize resolver"); } defaultSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultCaches = new HashMap(); }
/** * Creates a SimpleResolver that will query the specified host * @exception UnknownHostException Failure occurred while finding the host */ public SimpleResolver(String hostname) throws UnknownHostException { if (hostname == null) { hostname = ResolverConfig.getCurrentConfig().server(); if (hostname == null) hostname = defaultResolver; } InetAddress addr; if (hostname.equals("0")) addr = InetAddress.getLocalHost(); else addr = InetAddress.getByName(hostname); address = new InetSocketAddress(addr, DEFAULT_PORT); }
/** * Creates a SimpleResolver that will query the specified host * @exception UnknownHostException Failure occurred while finding the host */ public SimpleResolver(String hostname) throws UnknownHostException { if (hostname == null) { hostname = ResolverConfig.getCurrentConfig().server(); if (hostname == null) hostname = defaultResolver; } InetAddress addr; if (hostname.equals("0")) addr = InetAddress.getLocalHost(); else addr = InetAddress.getByName(hostname); address = new InetSocketAddress(addr, DEFAULT_PORT); }
/** * Creates a SimpleResolver that will query the specified host * @exception UnknownHostException Failure occurred while finding the host */ public SimpleResolver(String hostname) throws UnknownHostException { if (hostname == null) { hostname = ResolverConfig.getCurrentConfig().server(); if (hostname == null) hostname = defaultResolver; } InetAddress addr; if (hostname.equals("0")) addr = InetAddress.getLocalHost(); else addr = InetAddress.getByName(hostname); address = new InetSocketAddress(addr, DEFAULT_PORT); }
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); }
/** * Creates a new Extended Resolver. The default ResolverConfig is used to * determine the servers for which SimpleResolver contexts should be * initialized. * @see SimpleResolver * @see ResolverConfig * @exception UnknownHostException Failure occured initializing SimpleResolvers */ public ExtendedResolver() throws UnknownHostException { init(); String [] servers = ResolverConfig.getCurrentConfig().servers(); if (servers != null) { for (int i = 0; i < servers.length; i++) { Resolver r = new SimpleResolver(servers[i]); r.setTimeout(quantum); resolvers.add(r); } } else resolvers.add(new SimpleResolver()); }
/** * Creates a new Extended Resolver. The default ResolverConfig is used to * determine the servers for which SimpleResolver contexts should be * initialized. * @see SimpleResolver * @see ResolverConfig * @exception UnknownHostException Failure occured initializing SimpleResolvers */ public ExtendedResolver() throws UnknownHostException { init(); String [] servers = ResolverConfig.getCurrentConfig().servers(); if (servers != null) { for (int i = 0; i < servers.length; i++) { Resolver r = new SimpleResolver(servers[i]); r.setTimeout(quantum); resolvers.add(r); } } else resolvers.add(new SimpleResolver()); }
/** * Creates a new Extended Resolver. The default ResolverConfig is used to * determine the servers for which SimpleResolver contexts should be * initialized. * @see SimpleResolver * @see ResolverConfig * @exception UnknownHostException Failure occured initializing SimpleResolvers */ public ExtendedResolver() throws UnknownHostException { init(); String [] servers = ResolverConfig.getCurrentConfig().servers(); if (servers != null) { for (int i = 0; i < servers.length; i++) { Resolver r = new SimpleResolver(servers[i]); r.setTimeout(quantum); resolvers.add(r); } } else resolvers.add(new SimpleResolver()); }
/** * Gets the search path that will be used as the default by future Lookups. * * @return The default search path. */ public static synchronized Name[] getDefaultSearchPath() { if (defaultSearchPath == null) { Name[] configuredSearchPath = ResolverConfig.getCurrentConfig().searchPath(); defaultSearchPath = new Name[(configuredSearchPath != null ? configuredSearchPath.length : 0) + defaultQuerier.getMulticastDomains().length]; int startPos = 0; if (configuredSearchPath != null) { defaultSearchPath = new Name[configuredSearchPath.length + defaultQuerier.getMulticastDomains().length]; System.arraycopy(configuredSearchPath, 0, defaultSearchPath, startPos, configuredSearchPath.length); startPos = configuredSearchPath.length; } else { defaultSearchPath = new Name[defaultQuerier.getMulticastDomains().length]; } System.arraycopy(defaultQuerier.getMulticastDomains(), 0, defaultSearchPath, startPos, defaultQuerier.getMulticastDomains().length); } return defaultSearchPath; }
protected void storeDNSRecord(final CrawlURI curi, final String dnsName, final CrawlHost targetHost, final Record[] rrecordSet) { // Get TTL and IP info from the first A record (there may be // multiple, e.g. www.washington.edu) then update the CrawlServer ARecord arecord = getFirstARecord(rrecordSet); if (arecord == null) { throw new NullPointerException("Got null arecord for " + dnsName); } targetHost.setIP(arecord.getAddress(), arecord.getTTL()); try { recordDNS(curi, rrecordSet); curi.setFetchStatus(S_DNS_SUCCESS); curi.setDNSServerIPLabel(ResolverConfig.getCurrentConfig().server()); } catch (IOException e) { logger.log(Level.SEVERE, "Failed store of DNS Record for " + curi.toString(), e); setUnresolvable(curi, targetHost); } }
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 (Name domain : searchPath) { if (hostname.subdomain(domain)) { return hostname.relativize(domain).toString(); } } } } return hostname.toString(); }