Package org.xbill.DNS

Examples of org.xbill.DNS.Zone


        log.warn("Unable to transfer zone " + this.secondaryZone.getZoneName() + " from server " + this.secondaryZone.getRemoteServerAddress() + ", response is not a valid AXFR!");

        return;
      }

      Zone axfrZone = new Zone(this.secondaryZone.getZoneName(),records.toArray(new Record[records.size()]));

      log.debug("Zone " + this.secondaryZone.getZoneName() + " successfully transfered from server " + this.secondaryZone.getRemoteServerAddress());

      if(!axfrZone.getSOA().getName().equals(this.secondaryZone.getZoneName())){

        log.warn("Invalid AXFR zone name in response when updating secondary zone " + this.secondaryZone.getZoneName() + ". Got zone name " + axfrZone.getSOA().getName() + " in respons.");
      }

      if(this.secondaryZone.getZoneCopy() == null || this.secondaryZone.getZoneCopy().getSOA().getSerial() != axfrZone.getSOA().getSerial()){

        this.secondaryZone.setZoneCopy(axfrZone);
        this.secondaryZone.setDownloaded(new Timestamp(System.currentTimeMillis()));
        this.zoneProvider.zoneUpdated(this.secondaryZone);

        log.info("Zone " + this.secondaryZone.getZoneName() + " successfully updated from server " + this.secondaryZone.getRemoteServerAddress());
      }else{

        log.info("Zone " + this.secondaryZone.getZoneName() + " is already up to date with serial " + axfrZone.getSOA().getSerial());
        this.zoneProvider.zoneChecked(secondaryZone);
      }

    } catch (IOException e) {
View Full Code Here


    TSIGs.put(name, new TSIG(algstr, namestr, key));
  }

  private Zone findBestZone(Name name) {

    Zone foundzone = getZone(name);

    if (foundzone != null) {
      return foundzone;
    }
View Full Code Here

    return null;
  }

  private RRset findExactMatch(Name name, int type, int dclass, boolean glue) {
    Zone zone = findBestZone(name);

    if (zone != null) {
      return zone.findExactMatch(name, type);
    }

    return null;
  }
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);

      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

                                    "getRecord found an unexpected data");
                        }
                    }
            }

            zone = new Zone(Name.root, (Record[]) records
                    .toArray(new Record[] {}));
           
        } catch (TextParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

                                    "getRecord found an unexpected data");
                        }
                    }
            }

            zone = new Zone(Name.root, (Record[]) records
                    .toArray(new Record[] {}));
           
        } catch (TextParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

    private Zone loadZone(String zoneName) throws IOException {
        String zoneFilename = zoneName + "zone";
        URL zoneResource = getClass().getResource(zoneFilename);
        assertNotNull("test resource for zone could not be loaded: " + zoneFilename, zoneResource);
        String zoneFile = zoneResource.getFile();
        Zone zone = new Zone(Name.fromString(zoneName),zoneFile);
        return zone;
    }
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.