protected ARecord getFirstARecord(Record[] rrecordSet) { ARecord arecord = null; if (rrecordSet == null || rrecordSet.length == 0) { if (logger.isLoggable(Level.FINEST)) { logger.finest("rrecordSet is null or zero length: " + rrecordSet); } return arecord; } for (int i = 0; i < rrecordSet.length; i++) { if (rrecordSet[i].getType() != Type.A) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Record " + Integer.toString(i) + " is not A type but " + rrecordSet[i].getType()); } continue; } arecord = (ARecord) rrecordSet[i]; break; } return arecord; } }
private int convertRecordTypeToInt(Record record) { if (record == null) return -1; return record.getType(); }
private List<InetAddress> resolve(String key) throws UnknownHostException { List<InetAddress> result = new ArrayList<InetAddress>(); List<Record> list = m_records.get(key); if (list != null) for (Record r : list) if (r.getType() == Type.A) result.add(InetAddress.getByName(r.rdataToString())); else if ((r.getType() == Type.CNAME)) { List<Record> cnamelist = m_records.get(r.rdataToString()); for (Record r1 : cnamelist) { result.add(InetAddress.getByName(r1.rdataToString())); } } return result; } }
/** * Determines if an RRset with the given name and type is already * present in the given section. * @see RRset * @see Section */ public boolean findRRset(Name name, int type, int section) { if (sections[section] == null) return false; for (int i = 0; i < sections[section].size(); i++) { Record r = (Record) sections[section].get(i); if (r.getType() == type && name.equals(r.getName())) return true; } return false; }
/** * Determines if an RRset with the given name and type is already * present in the given section. * @see RRset * @see Section */ public boolean findRRset(Name name, int type, int section) { if (sections[section] == null) return false; for (int i = 0; i < sections[section].size(); i++) { Record r = (Record) sections[section].get(i); if (r.getType() == type && name.equals(r.getName())) return true; } return false; }
/** * Determines if an RRset with the given name and type is already * present in the given section. * @see RRset * @see Section */ public boolean findRRset(Name name, int type, int section) { if (sections[section] == null) return false; for (int i = 0; i < sections[section].size(); i++) { Record r = (Record) sections[section].get(i); if (r.getType() == type && name.equals(r.getName())) return true; } return false; }
public String getTXT(String key) throws ConfigException { String qkey = fullyQualify(key); List<Record> list = m_records.get(makeHostKey(qkey)); if (list == null || list.get(0).getType() != Type.TXT) { throw new NotFoundException("No such record: " + makeHostKey(qkey)); } TXTRecord trec = (TXTRecord) list.get(0); String sdata = trec.rdataToString(); if (sdata.charAt(0) == '"') { sdata = sdata.substring(1, sdata.length() - 1); } return sdata; }
private Optional<RemoteAddress> lookupSrv(String domain) { try { Record[] records = new Lookup(prefix + domain, Type.SRV).run(); if (records == null) { return Optional.empty(); } return Stream.of(records) .filter(record -> record.getType() == Type.SRV && record instanceof SRVRecord) .map(record -> (SRVRecord) record) .min(Comparator.comparingInt(SRVRecord::getPriority)) .map(record -> new RemoteAddress(record.getTarget().toString(true), record.getPort())); } catch (TextParseException e) { return Optional.empty(); } }
private static boolean resolve(final Name name, final Resolver resolver, final int type) { final Lookup lookup = new Lookup(name, type); // NMS-9238: Do not use a cache when looking up the record, // that kind of defeats the purpose of this monitor :) lookup.setCache(null); lookup.setResolver(resolver); final Record[] records = lookup.run(); if (records == null) { return false; } return Arrays.stream(records) .filter(r -> r.getType() == type) .count() > 0; } }
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
/** * Indicates that the record should be inserted into the zone replacing any * other records with the same name and type. */ public void replace(Record record) { delete(record.getName(), record.getType()); add(record); }
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
/** * Indicates that the record should be inserted into the zone replacing any * other records with the same name and type. */ public void replace(Record record) { delete(record.getName(), record.getType()); add(record); }
public DNSServiceRecord getSRV(String key) throws ConfigException { String qkey = fullyQualify(key); List<Record> list = m_records.get(makeHostKey(qkey)); if (list == null || list.get(0).getType() != Type.SRV) { throw new NotFoundException("No such record: " + makeHostKey(qkey)); } SRVRecord srec = (SRVRecord) list.get(0); return new DNSServiceRecord(srec.rdataToString()); }
private final void maybeAddRecord(Record record) throws IOException { int rtype = record.getType(); Name name = record.getName(); if (rtype == Type.SOA && !name.equals(origin)) { throw new IOException("SOA owner " + name + " does not match zone origin " + origin); } if (name.subdomain(origin)) addRecord(record); }
/** * Indicates that the record should be inserted into the zone replacing any * other records with the same name and type. */ public void replace(Record record) { delete(record.getName(), record.getType()); add(record); }
/** * Indicates that the record should be inserted into the zone replacing any * other records with the same name and type. */ public void replace(Record record) { delete(record.getName(), record.getType()); add(record); }
public List<DNSServiceRecord> getMultiSRV(String key) throws ConfigException { String qkey = fullyQualify(key); List<DNSServiceRecord> result = new ArrayList<DNSServiceRecord>(); List<Record> list = m_records.get(makeHostKey(qkey)); if (list == null) { throw new NotFoundException("No such record: " + makeHostKey(qkey)); } for (Record r : list) { if (r.getType() != Type.SRV) { continue; } result.add(new DNSServiceRecord(((SRVRecord) r).rdataToString())); } return result; }
public DBRecord(Record record, Name origin, long zoneTTL) { this.name = record.getName().relativize(origin).toString(); this.type = Type.string(record.getType()); this.dclass = DClass.string(record.getDClass()); this.content = record.rdataToString(); if(record.getTTL() == zoneTTL){ this.ttl = null; }else{ this.ttl = record.getTTL(); } }