InetAddress resolvedAddress = InetAddress.getByAddress(host, ipv4Record.getAddress().getAddress());
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); } }
/** * Creates a DNS A record. * * @param name the record name. * @param target the record target/value. * @return an A record. */ @Override public ARecord create(Name name, InetAddress target) { return new ARecord(name, DClass.IN, ttl, target); } }
public static List<ForwardLookupResult> attemptZoneTransfer(String domain, List<ForwardLookupResult> nameServers) throws TextParseException { List<ForwardLookupResult> result = new ArrayList<>(); ZoneTransferIn xfr; Iterator i = nameServers.iterator(); for (ForwardLookupResult nameServer : nameServers) { try { xfr = ZoneTransferIn.newAXFR(new Name(domain), nameServer.getIpAddress(), null); List records = xfr.run(); for (Iterator it = records.iterator(); it.hasNext();) { Record r = (Record) it.next(); if (r.getType() == 1) { ForwardLookupResult rec = new ForwardLookupResult(domain); String hostName = ((ARecord) r).getName().toString().toLowerCase(); if (hostName.endsWith(".")) { hostName = hostName.substring(0, hostName.length() - 1); } rec.setHostName(hostName); rec.setIpAddress(((ARecord) r).getAddress().getHostAddress()); rec.setLookupType("A"); result.add(rec); } } } catch (IOException ioex) { Logger.getLogger("ForwardLookupHelper.attemptZoneTransfer").log(Level.WARNING, null, ioex); } catch (ZoneTransferException zex) { Log.debug("ForwardLookupHelper.attemptZoneTransfer: Failed zonetransfer"); } } return result; }
if (a.getName().equals(service.getHost())) if (a.getTTL() > 0) service.addAddress(a.getAddress()); } else service.removeAddress(a.getAddress());
/** * Creates a DNS A type record. * @param name The record name. Generally a fully qualified domain name such as host.example.com. * @param ttl The time to live in seconds. * @param ip The ip4 address that the name will resolve. * @return A DNSRecord representing an A type record. * @throws ConfigurationStoreException */ public static DNSRecord createARecord(String name, long ttl, String ip) throws ConfigurationStoreException { if (!name.endsWith(".")) name = name + "."; try { ARecord rec = new ARecord(Name.fromString(name), DClass.IN, ttl, InetAddress.getByName(ip)); return DNSRecord.fromWire(rec.toWireCanonical()); } catch (Exception e) { throw new ConfigurationStoreException("Failed to create DNS A record: " + e.getMessage(), e); } }
/** * Creates an A Record from the given data * @param address The address that the name refers to */ public ARecord(Name name, int dclass, long ttl, InetAddress address) { super(name, Type.A, dclass, ttl); if (Address.familyOf(address) != Address.IPv4) throw new IllegalArgumentException("invalid IPv4 address"); addr = fromArray(address.getAddress()); }
/** Returns the Internet address */ public InetAddress getAddress() { try { return InetAddress.getByAddress(toArray(addr)); } catch (UnknownHostException e) { return null; } }
Record getObject() { return new ARecord(); }
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); } }
/** * Creates a DNS A type record. * @param name The record name. Generally a fully qualified domain name such as host.example.com. * @param ttl The time to live in seconds. * @param ip The ip4 address that the name will resolve. * @return A DNSRecord representing an A type record. * @throws ConfigurationStoreException */ public static DNSRecord createARecord(String name, long ttl, String ip) throws DNSRecordCreationException { if (!name.endsWith(".")) name = name + "."; try { ARecord rec = new ARecord(Name.fromString(name), DClass.IN, ttl, InetAddress.getByName(ip)); return fromWire(rec.toWireCanonical()); } catch (Exception e) { throw new DNSRecordCreationException("Failed to create DNS A record: " + e.getMessage(), e); } }
void rdataFromString(Tokenizer st, Name origin) throws IOException { InetAddress address = st.getAddress(Address.IPv4); addr = fromArray(address.getAddress()); }
/** Returns the Internet address */ public InetAddress getAddress() { try { return InetAddress.getByAddress(toArray(addr)); } catch (UnknownHostException e) { return null; } }
public List<InetAddress> resolve(String host) { List<InetAddress> hostIPs = new ArrayList<>(); try { Lookup lookup = new Lookup(host, Type.A); lookup.setResolver(resolver); Record[] records = lookup.run(); if (records == null) { return hostIPs; } for (Record record : records) { hostIPs.add(((ARecord) record).getAddress()); } } catch (TextParseException ex) { Log.e(TAG, ex.getMessage(), ex); throw new IllegalStateException(ex); } return hostIPs; }
Record getObject() { return new ARecord(); }
void rdataFromString(Tokenizer st, Name origin) throws IOException { InetAddress address = st.getAddress(Address.IPv4); addr = fromArray(address.getAddress()); }
/** * Finds A records (ip addresses) for the host name. * * @param name host name to resolve. * @return All the ip addresses found for the host name. * @throws UnknownHostException occurs when name is not available in DNS */ public InetAddress[] lookupAllHostAddr(String name) throws UnknownHostException { try { final Lookup lookup = new Lookup(name, Type.A); Record[] records = lookup.run(); if (records == null) { throw new UnknownHostException(name); } InetAddress[] array = new InetAddress[records.length]; for (int i = 0; i < records.length; i++) { ARecord a = (ARecord) records[i]; array[i] = a.getAddress(); } return array; } catch (TextParseException e) { throw new UnknownHostException(e.getMessage()); } }
Record getObject() { return new ARecord(); }
void rdataFromString(Tokenizer st, Name origin) throws IOException { InetAddress address = st.getAddress(Address.IPv4); addr = fromArray(address.getAddress()); }