org.xbill.DNS.ZoneTransferException Java Examples

The following examples show how to use org.xbill.DNS.ZoneTransferException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleDoTResolver.java    From androdns with Apache License 2.0 6 votes vote down vote up
private Message
sendAXFR(Message query) throws IOException {
    Name qname = query.getQuestion().getName();
    ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(qname, address, tsig);
    xfrin.setTimeout((int)(getTimeout() / 1000));
    xfrin.setLocalAddress(localAddress);
    try {
        xfrin.run();
    }
    catch (ZoneTransferException e) {
        throw new WireParseException(e.getMessage());
    }
    List records = xfrin.getAXFR();
    Message response = new Message(query.getHeader().getID());
    response.getHeader().setFlag(Flags.AA);
    response.getHeader().setFlag(Flags.QR);
    response.addRecord(query.getQuestion(), Section.QUESTION);
    Iterator it = records.iterator();
    while (it.hasNext())
        response.addRecord((Record)it.next(), Section.ANSWER);
    return response;
}
 
Example #2
Source File: jnamed.java    From dnsjava with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public static void main(String[] args) {
  if (args.length > 1) {
    System.out.println("usage: jnamed [conf]");
    System.exit(0);
  }

  try {
    String conf;
    if (args.length == 1) {
      conf = args[0];
    } else {
      conf = "jnamed.conf";
    }
    new jnamed(conf);
  } catch (IOException | ZoneTransferException e) {
    System.out.println(e);
  }
}
 
Example #3
Source File: ForwardLookupHelper.java    From yeti with MIT License 5 votes vote down vote up
public static List<ForwardLookupResult> attemptZoneTransfer(String domain, List<ForwardLookupResult> nameServers) throws TextParseException {
    List<ForwardLookupResult> result = new ArrayList<>();

    ZoneTransferIn xfr;
    Iterator i = nameServers.iterator();
    for (ForwardLookupResult nameServer : nameServers) {
        try {
            xfr = ZoneTransferIn.newAXFR(new Name(domain), nameServer.getIpAddress(), null);
            List records = xfr.run();
            for (Iterator it = records.iterator(); it.hasNext();) {
                Record r = (Record) it.next();
                if (r.getType() == 1) {
                    ForwardLookupResult rec = new ForwardLookupResult(domain);
                    String hostName = ((ARecord) r).getName().toString().toLowerCase();

                    if (hostName.endsWith(".")) {
                        hostName = hostName.substring(0, hostName.length() - 1);
                    }

                    rec.setHostName(hostName);
                    rec.setIpAddress(((ARecord) r).getAddress().getHostAddress());
                    rec.setLookupType("A");
                    result.add(rec);
                }
            }
        } catch (IOException ioex) {
            Logger.getLogger("ForwardLookupHelper.attemptZoneTransfer").log(Level.WARNING, null, ioex);
        } catch (ZoneTransferException zex) {
            Log.debug("ForwardLookupHelper.attemptZoneTransfer: Failed zonetransfer");
        }
    }
    return result;
}
 
Example #4
Source File: jnamed.java    From dnsjava with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void addSecondaryZone(String zone, String remote)
    throws IOException, ZoneTransferException {
  Name zname = Name.fromString(zone, Name.root);
  Zone newzone = new Zone(zname, DClass.IN, remote);
  znames.put(zname, newzone);
}