Ejemplo n.º 1
0
 /** Removes the given set with the name and type. The data contained in the set is abstract. */
 protected void removeSet(Name name, short type, TypedObject set) {
   TypeMap nameInfo = findName(name);
   if (nameInfo == null) return;
   Object o = nameInfo.get(type);
   if (o != set && type != Type.CNAME) {
     type = Type.CNAME;
     o = nameInfo.get(type);
   }
   if (o == set) {
     synchronized (nameInfo) {
       nameInfo.remove(type);
     }
     if (nameInfo.isEmpty()) data.remove(name);
   }
 }
Ejemplo n.º 2
0
  /** Finds all matching sets or something that causes the lookup to stop. */
  protected Object findSets(Name name, short type) {
    Object bestns = null;
    Object o;
    Name tname;
    int labels;
    int olabels;
    int tlabels;

    if (!name.subdomain(origin)) return null;
    labels = name.labels();
    olabels = origin.labels();

    for (tlabels = olabels; tlabels <= labels; tlabels++) {
      if (tlabels == olabels) tname = origin;
      else if (tlabels == labels) tname = name;
      else tname = new Name(name, labels - tlabels);
      TypeMap nameInfo = findName(tname);
      if (nameInfo == null) continue;

      /* If this is an ANY lookup, return everything. */
      if (tlabels == labels && type == Type.ANY) return nameInfo.getAll();

      /* Look for an NS */
      if (tlabels > olabels || isCache) {
        o = nameInfo.get(Type.NS);
        if (o != null) {
          if (isCache) bestns = o;
          else return o;
        }
      }

      /* If this is the name, look for the actual type. */
      if (tlabels == labels) {
        o = nameInfo.get(type);
        if (o != null) return o;
      }

      /* If this is the name, look for a CNAME */
      if (tlabels == labels) {
        o = nameInfo.get(Type.CNAME);
        if (o != null) return o;
      }

      /* Look for a DNAME, unless this is the actual name */
      if (tlabels < labels) {
        o = nameInfo.get(Type.DNAME);
        if (o != null) return o;
      }

      /*
       * If this is the name and this is a cache, look for an
       * NXDOMAIN entry.
       */
      if (tlabels == labels && isCache) {
        o = nameInfo.get((short) 0);
        if (o != null) return o;
      }

      /*
       * If this is the name and we haven't matched anything,
       * just return the name.
       */
      if (tlabels == labels) return nameInfo;
    }
    if (bestns == null) return null;
    else return bestns;
  }
Ejemplo n.º 3
0
 /**
  * Finds all sets that exactly match. This does not traverse CNAMEs or handle Type ANY queries.
  */
 protected Object findExactSet(Name name, short type) {
   TypeMap nameInfo = findName(name);
   if (nameInfo == null) return null;
   return nameInfo.get(type);
 }