Package org.xbill.DNS

Examples of org.xbill.DNS.Zone


    if (type == Type.SIG || type == Type.RRSIG) {
      type = Type.ANY;
      flags |= FLAG_SIGONLY;
    }

    Zone zone = findBestZone(name);
    if (zone != null) {
      sr = zone.findRecords(name, type);

      if (sr.isNXDOMAIN()) {
        response.getHeader().setRcode(Rcode.NXDOMAIN);
        if (zone != null) {
          addSOA(response, zone);
View Full Code Here


  private byte[] doAXFR(Name name, Message query, TSIG tsig, TSIGRecord qtsig, Socket s) {

    boolean first = true;

    Zone zone = this.findBestZone(name);

    if (zone == null) {

      return errorMessage(query, Rcode.REFUSED);

    }

    // Check that the IP requesting the AXFR is present as a NS in this zone
    boolean axfrAllowed = false;

    Iterator<?> nsIterator = zone.getNS().rrs();

    while (nsIterator.hasNext()) {

      NSRecord record = (NSRecord) nsIterator.next();

      try {
        String nsIP = InetAddress.getByName(record.getTarget().toString()).getHostAddress();

        if (s.getInetAddress().getHostAddress().equals(nsIP)) {

          axfrAllowed = true;
          break;
        }

      } catch (UnknownHostException e) {

        log.warn("Unable to resolve hostname of nameserver " + record.getTarget() + " in zone " + zone.getOrigin() + " while processing AXFR request from " + s.getRemoteSocketAddress());
      }
    }

    if (!axfrAllowed) {
      log.warn("AXFR request of zone " + zone.getOrigin() + " from " + s.getRemoteSocketAddress() + " refused!");
      return errorMessage(query, Rcode.REFUSED);
    }

    Iterator<?> it = zone.AXFR();

    try {
      DataOutputStream dataOut;
      dataOut = new DataOutputStream(s.getOutputStream());
      int id = query.getHeader().getID();
View Full Code Here

        pos++;
      }
    }

    return new Zone(zoneName,recordArray);
  }
View Full Code Here

      Name origin;
      try {

        origin = Name.fromString(zoneFile.getName(), Name.root);
        Zone zone = new Zone(origin, zoneFile.getPath());

        log.debug("FileZoneProvider " + name + " successfully parsed zone file " + zoneFile.getName());

        zones.add(zone);
View Full Code Here

    private static Zone loadZone(String zoneName) throws IOException {
        String zoneFilename = zoneName + "zone";
        URL zoneResource = Resources.getResource(DNSJavaServiceTest.class, zoneFilename);
        assertNotNull("test resource for zone could not be loaded: " + zoneFilename, zoneResource);
        return new Zone(Name.fromString(zoneName), zoneResource.getFile());
    }
View Full Code Here

        FabricService service = fabricService.get();
        List<Record> records = new ArrayList<>();
        //TODO: At some point we need to manage the serial number.
        records.add(new SOARecord(domainRoot, DClass.IN, DAY, ns, admin, 1, refresh, retry, expire, minimumTtl));
        records.add(new NSRecord(domainRoot, DClass.IN, DAY, ns));
        return new Zone(domainRoot, records.toArray(new Record[records.size()]));
    }
View Full Code Here

        }
        return c;
    }

    public Zone findBestZone(Name name) {
        Zone foundzone = null;
        foundzone = (Zone) znames.get(name);
        if (foundzone != null)
            return foundzone;
        int labels = name.labels();
        for (int i = 1; i < labels; i++) {
View Full Code Here

        }
        return null;
    }

    public RRset findExactMatch(Name name, int type, int dclass, boolean glue) {
        Zone zone = findBestZone(name);
        if (zone != null)
            return zone.findExactMatch(name, type);
        else {
            RRset[] rrsets;
            Cache cache = getCache(dclass);
            if (glue)
                rrsets = cache.findAnyRecords(name, type);
View Full Code Here

        if (type == Type.SIG || type == Type.RRSIG) {
            type = Type.ANY;
            flags |= FLAG_SIGONLY;
        }

        Zone zone = findBestZone(name);
        if (zone != null)
            sr = zone.findRecords(name, type);
        else {
            Cache cache = getCache(dclass);
            sr = cache.lookupRecords(name, type, Credibility.NORMAL);
        }
View Full Code Here

        }
        return rcode;
    }

    byte[] doAXFR(Name name, Message query, TSIG tsig, TSIGRecord qtsig, Socket s) {
        Zone zone = (Zone) znames.get(name);
        boolean first = true;
        if (zone == null)
            return errorMessage(query, Rcode.REFUSED);
        Iterator it = zone.AXFR();
        try {
            DataOutputStream dataOut;
            dataOut = new DataOutputStream(s.getOutputStream());
            int id = query.getHeader().getID();
            while (it.hasNext()) {
View Full Code Here

TOP

Related Classes of org.xbill.DNS.Zone

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.