/** * Returns the class of the records * @see DClass */ public int getDClass() { return first().getDClass(); }
/** * Returns the class of the records * @see DClass */ public int getDClass() { return first().getDClass(); }
/** * Returns the class of the records * @see DClass */ public int getDClass() { return first().getDClass(); }
/** * Returns the class of the records * @see DClass */ public int getDClass() { return first().getDClass(); }
public static String toString(Record record) { if (record == null) { return null; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(record.getName()); stringBuilder.append(" "); stringBuilder.append(record.getTTL()); stringBuilder.append(" "); stringBuilder.append(DClass.string(record.getDClass())); stringBuilder.append(" "); stringBuilder.append(Type.string(record.getType())); String rdata = record.rdataToString(); if (!rdata.equals("")) { stringBuilder.append(" "); stringBuilder.append(rdata); } return stringBuilder.toString(); }
protected MulticastDNSLookupBase(final Message message) throws IOException { this(); queries = new Message[] {(Message) message.clone()}; int type = -1; int dclass = -1; List list = new ArrayList(); Record[] records = MulticastDNSUtils.extractRecords(message, Section.QUESTION); for (Record r : records) { if (!list.contains(r)) { list.add(r.getName()); } type = type < 0 ? r.getType() : Type.ANY; dclass = dclass < 0 ? r.getDClass() : DClass.ANY; } if (list.size() > 0) { this.type = type; this.dclass = dclass; names = (Name[]) list.toArray(new Record[list.size()]); } }
RRset set = (RRset) sets.get(j); if (set.getType() == recs[i].getRRsetType() && set.getDClass() == recs[i].getDClass() && set.getName().equals(name))
RRset set = (RRset) sets.get(j); if (set.getType() == recs[i].getRRsetType() && set.getDClass() == recs[i].getDClass() && set.getName().equals(name))
RRset set = (RRset) sets.get(j); if (set.getType() == recs[i].getRRsetType() && set.getDClass() == recs[i].getDClass() && set.getName().equals(name))
boolean answersQuery(final Record record) { if (record != null) { for (Message query : browser.queries) { for (Record question : MulticastDNSUtils.extractRecords(query, Section.QUESTION)) { Name questionName = question.getName(); Name recordName = record.getName(); int questionType = question.getType(); int recordType = record.getType(); int questionDClass = question.getDClass(); int recordDClass = record.getDClass(); if (((questionType == Type.ANY) || (questionType == recordType)) && (questionName.equals(recordName) || questionName.subdomain(recordName) || recordName.toString().endsWith("." + questionName.toString())) && ((questionDClass == DClass.ANY) || ((questionDClass & 0x7FFF) == (recordDClass & 0x7FFF)))) { return true; } } } } return false; }
boolean answersQuery(Record record) { if (record != null) { for (Message query : queries) { for (Record question : MulticastDNSUtils.extractRecords(query, Section.QUESTION)) { Name questionName = question.getName(); Name recordName = record.getName(); int questionType = question.getType(); int recordType = record.getType(); int questionDClass = question.getDClass(); int recordDClass = record.getDClass(); if ((questionType == Type.ANY || questionType == recordType) && (questionName.equals(recordName) || questionName.subdomain(recordName) || recordName.toString().endsWith("." + questionName.toString())) && (questionDClass == DClass.ANY || (questionDClass & 0x7FFF) == (recordDClass & 0x7FFF))) { return true; } } } } return false; }
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(); } }
/** * Converts a raw wire transfer format of a record to a DNS record. * @param data The raw byte stream of a record in wire transfer format. * @return A DNSRecord converted from the wire format. * @throws IOException */ public static DNSRecord fromWire(byte[] data) throws IOException { Record rec = Record.fromWire(data, Section.ANSWER); DNSRecord retVal = new DNSRecord(); retVal.setDclass(rec.getDClass()); retVal.setName(rec.getName().toString()); retVal.setData(rec.rdataToWireCanonical()); retVal.setTtl(rec.getTTL()); retVal.setType(rec.getType()); return retVal; } }
/** * Converts a raw wire transfer format of a record to a DNS record. * @param data The raw byte stream of a record in wire transfer format. * @return A DNSRecord converted from the wire format. * @throws IOException */ public static DNSRecord fromWire(byte[] data) throws IOException { Record rec = Record.fromWire(data, Section.ANSWER); DNSRecord retVal = new DNSRecord(); retVal.setDclass(rec.getDClass()); retVal.setName(rec.getName().toString()); retVal.setData(rec.rdataToWireCanonical()); retVal.setTtl(rec.getTTL()); retVal.setType(rec.getType()); return retVal; } }
/** * Create a query to forward to the primary DNS server (if configured). * NOTE: Experimental * * @param query the inbound query. * @return the query to forward to the primary server. * @throws NameTooLongException * @throws TextParseException if query creation fails. */ private Message createPrimaryQuery(Message query) throws NameTooLongException, TextParseException { Name name = query.getQuestion().getName(); if (name.labels() > 0 && name.labels() <= 2) { // short relative or absolute name. this code may not be necessary - // OS resolution utilities probably append the search paths defined // in resolv.conf prior to the lookup int id = query.getHeader().getID(); String queryName = name.getLabelString(0); Name qualifiedName = Name.concatenate(Name.fromString(queryName), Name.fromString(domainName)); LOG.info("Received query {}. Forwarding query {}", name, qualifiedName); Record question = Record.newRecord(qualifiedName, query.getQuestion().getType(), query.getQuestion().getDClass()); query = Message.newQuery(question); query.getHeader().setID(id); } return query; }