Search in sources :

Example 1 with ZoneTransferIn

use of org.xbill.DNS.ZoneTransferIn in project opennms by OpenNMS.

the class DnsRequisitionProvider method getRequisitionFor.

@Override
public Requisition getRequisitionFor(DnsRequisitionRequest request) {
    ZoneTransferIn xfer = null;
    List<Record> records = null;
    LOG.debug("connecting to host {}:{}", request.getHost(), request.getPort());
    try {
        try {
            xfer = ZoneTransferIn.newIXFR(new Name(request.getZone()), request.getSerial(), request.getFallback(), request.getHost(), request.getPort(), null);
            records = getRecords(xfer);
        } catch (ZoneTransferException e) {
            // Fallback to AXFR
            String message = "IXFR not supported trying AXFR: " + e;
            LOG.warn(message, e);
            xfer = ZoneTransferIn.newAXFR(new Name(request.getZone()), request.getHost(), null);
            records = getRecords(xfer);
        }
    } catch (IOException | ZoneTransferException e) {
        throw new RuntimeException(e);
    }
    if (records.size() > 0) {
        // for now, set the foreign source to the specified dns zone
        final Requisition r = new Requisition(request.getForeignSource());
        for (Record rec : records) {
            if (matchingRecord(request, rec)) {
                r.insertNode(createRequisitionNode(request, rec));
            }
        }
        return r;
    }
    return null;
}
Also used : ZoneTransferException(org.xbill.DNS.ZoneTransferException) ZoneTransferIn(org.xbill.DNS.ZoneTransferIn) ARecord(org.xbill.DNS.ARecord) AAAARecord(org.xbill.DNS.AAAARecord) Record(org.xbill.DNS.Record) IOException(java.io.IOException) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Name(org.xbill.DNS.Name)

Aggregations

IOException (java.io.IOException)1 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)1 AAAARecord (org.xbill.DNS.AAAARecord)1 ARecord (org.xbill.DNS.ARecord)1 Name (org.xbill.DNS.Name)1 Record (org.xbill.DNS.Record)1 ZoneTransferException (org.xbill.DNS.ZoneTransferException)1 ZoneTransferIn (org.xbill.DNS.ZoneTransferIn)1