Пример #1
0
  private final void maybeAddRecord(Record record, Cache cache, Object source) throws IOException {
    int type = record.getType();
    Name name = record.getName();

    if (type == Type.SOA) {
      if (!name.equals(origin))
        throw new IOException("SOA owner " + name + " does not match zone origin " + origin);
      else {
        setOrigin(origin);
        dclass = record.getDClass();
      }
    }
    if (origin == null && type != Type.SOA)
      throw new IOException("non-SOA record seen at " + name + " with no origin set");
    if (name.subdomain(origin)) addRecord(record);
    else if (cache != null) cache.addRecord(record, Credibility.GLUE, source);
  }
Пример #2
0
 /**
  * Creates a Zone by performing a zone transfer to the specified host. All records that do not
  * belong in the Zone are added to the specified Cache.
  *
  * @see Cache
  * @see Master
  */
 public Zone(Name zone, short dclass, String remote, Cache cache) throws IOException {
   super(false);
   origin = zone;
   this.dclass = dclass;
   type = SECONDARY;
   Resolver res = new SimpleResolver(remote);
   Record rec = Record.newRecord(zone, Type.AXFR, dclass);
   Message query = Message.newQuery(rec);
   Message response = res.send(query);
   Record[] recs = response.getSectionArray(Section.ANSWER);
   for (int i = 0; i < recs.length; i++) {
     if (!recs[i].getName().subdomain(origin)) {
       if (Options.check("verbose"))
         System.err.println(recs[i].getName() + "is not in zone " + origin);
       continue;
     }
     addRecord(recs[i]);
   }
   if (cache != null) {
     recs = response.getSectionArray(Section.ADDITIONAL);
     for (int i = 0; i < recs.length; i++) cache.addRecord(recs[i], Credibility.GLUE, recs);
   }
   validate();
 }