本文整理了Java中org.xbill.DNS.ZoneTransferIn
类的一些代码示例,展示了ZoneTransferIn
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoneTransferIn
类的具体详情如下:
包路径:org.xbill.DNS.ZoneTransferIn
类名称:ZoneTransferIn
暂无
代码示例来源:origin: dnsjava/dnsjava
/**
* Creates a Zone by performing a zone transfer to the specified host.
* @see ZoneTransferIn
*/
public
Zone(Name zone, int dclass, String remote)
throws IOException, ZoneTransferException
{
ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(zone, remote, null);
xfrin.setDClass(dclass);
fromXFR(xfrin);
}
代码示例来源:origin: OpenNMS/opennms
@SuppressWarnings("unchecked")
private static List<Record> getRecords(ZoneTransferIn xfer) throws IOException, ZoneTransferException {
return (List<Record>) xfer.run();
}
代码示例来源:origin: org.littleshoot/dnsjava
/**
* Instantiates a ZoneTransferIn object to do an IXFR (incremental zone
* transfer).
* @param zone The zone to transfer.
* @param serial The existing serial number.
* @param fallback If true, fall back to AXFR if IXFR is not supported.
* @param host The host from which to transfer the zone.
* @param key The TSIG key used to authenticate the transfer, or null.
* @return The ZoneTransferIn object.
* @throws UnknownHostException The host does not exist.
*/
public static ZoneTransferIn
newIXFR(Name zone, long serial, boolean fallback, String host, TSIG key)
throws UnknownHostException
{
return newIXFR(zone, serial, fallback, host, 0, key);
}
代码示例来源:origin: dnsjava/dnsjava
private void
fallback() throws ZoneTransferException {
if (!want_fallback)
fail("server doesn't support IXFR");
logxfr("falling back to AXFR");
qtype = Type.AXFR;
state = INITIALSOA;
}
代码示例来源:origin: dnsjava/dnsjava
/**
* Does the zone transfer.
* @param handler The callback object that handles the zone transfer data.
* @throws IOException The zone transfer failed to due an IO problem.
* @throws ZoneTransferException The zone transfer failed to due a problem
* with the zone transfer itself.
*/
public void
run(ZoneTransferHandler handler) throws IOException, ZoneTransferException {
this.handler = handler;
try {
openConnection();
doxfr();
}
finally {
closeConnection();
}
}
代码示例来源:origin: dnsjava/dnsjava
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;
}
代码示例来源:origin: org.littleshoot/dnsjava
xfrin = ZoneTransferIn.newIXFR(zname, ixfr_serial, fallback,
server, port, key);
else
xfrin = ZoneTransferIn.newAXFR(zname, server, port, key);
List response = xfrin.run();
if (xfrin.isAXFR()) {
if (ixfr_serial >= 0)
System.out.println("AXFR-like IXFR response");
while (it.hasNext())
System.out.println(it.next());
} else if (xfrin.isIXFR()) {
System.out.println("IXFR response");
Iterator it = response.iterator();
System.out.println(it2.next());
} else if (xfrin.isCurrent()) {
System.out.println("up to date");
代码示例来源:origin: dnsjava/dnsjava
private void
doxfr() throws IOException, ZoneTransferException {
sendQuery();
while (state != END) {
byte [] in = client.recv();
Message response = parseMessage(in);
if (response.getHeader().getRcode() == Rcode.NOERROR &&
verifier != null)
fail("TSIG failure");
rcode == Rcode.NOTIMP)
fallback();
doxfr();
return;
fail(Rcode.string(rcode));
fail("invalid question section");
fallback();
doxfr();
return;
parseRR(answers[i]);
fail("last message must be signed");
代码示例来源:origin: org.jboss.resteasy/resteasy-eagledns-fork
ZoneTransferIn xfrin = ZoneTransferIn.newAXFR(this.secondaryZone.getZoneName(), this.secondaryZone.getRemoteServerAddress(), null);
xfrin.setDClass(DClass.value(this.secondaryZone.getDclass()));
xfrin.setTimeout(axfrTimeout);
List<?> records = xfrin.run();
if (!xfrin.isAXFR()) {
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
private void
fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException {
data = new HashMap();
type = SECONDARY;
if (!xfrin.isAXFR())
throw new IllegalArgumentException("zones can only be " +
"created from AXFRs");
origin = xfrin.getName();
List records = xfrin.run();
for (Iterator it = records.iterator(); it.hasNext(); ) {
Record record = (Record) it.next();
maybeAddRecord(record);
}
validate();
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
case INITIALSOA:
if (type != Type.SOA)
fail("missing initial SOA");
initialsoa = rec;
end_serial = getSOASerial(rec);
if (qtype == Type.IXFR && end_serial <= ixfr_serial) {
logxfr("up to date");
state = END;
break;
getSOASerial(rec) == ixfr_serial)
logxfr("got incremental response");
state = IXFR_DELSOA;
} else {
axfr = new ArrayList();
axfr.add(initialsoa);
logxfr("got nonincremental response");
state = AXFR;
parseRR(rec); // Restart...
return;
delta = new Delta();
ixfr.add(delta);
delta.start = getSOASerial(rec);
delta.deletes.add(rec);
代码示例来源:origin: LendingClub/mercator
public Optional<List> getRecordsbyZone(String zone) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(zone), "Zone name can not be empty");
ZoneTransferIn xfrin;
try {
xfrin = ZoneTransferIn.newAXFR(new Name(zone), dnsServer, getTSIGKey());
logger.info("Trying a zone transfer from {} for {} zone with {} key", dnsServer, zone, keyName);
return Optional.of(xfrin.run());
} catch (IOException | ZoneTransferException e) {
logger.error("Failed to extract the records for {} zone", zone);
}
return Optional.empty();
}
代码示例来源:origin: dnsjava/dnsjava
/**
* Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer).
* @param zone The zone to transfer.
* @param host The host from which to transfer the zone.
* @param key The TSIG key used to authenticate the transfer, or null.
* @return The ZoneTransferIn object.
* @throws UnknownHostException The host does not exist.
*/
public static ZoneTransferIn
newAXFR(Name zone, String host, TSIG key)
throws UnknownHostException
{
return newAXFR(zone, host, 0, key);
}
代码示例来源:origin: OpenNMS/opennms
try {
try {
xfer = ZoneTransferIn.newIXFR(new Name(request.getZone()), request.getSerial(),
request.getFallback(), request.getHost(), request.getPort(), null);
records = getRecords(xfer);
xfer = ZoneTransferIn.newAXFR(new Name(request.getZone()), request.getHost(), null);
records = getRecords(xfer);
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
/**
* Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer).
* @param zone The zone to transfer.
* @param address The host/port from which to transfer the zone.
* @param key The TSIG key used to authenticate the transfer, or null.
* @return The ZoneTransferIn object.
* @throws UnknownHostException The host does not exist.
*/
public static ZoneTransferIn
newAXFR(Name zone, SocketAddress address, TSIG key) {
return new ZoneTransferIn(zone, Type.AXFR, 0, false, address, key);
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
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;
}
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
xfrin = ZoneTransferIn.newIXFR(zname, ixfr_serial, fallback,
server, port, key);
else
xfrin = ZoneTransferIn.newAXFR(zname, server, port, key);
List response = xfrin.run();
if (xfrin.isAXFR()) {
if (ixfr_serial >= 0)
System.out.println("AXFR-like IXFR response");
while (it.hasNext())
System.out.println(it.next());
} else if (xfrin.isIXFR()) {
System.out.println("IXFR response");
Iterator it = response.iterator();
System.out.println(it2.next());
} else if (xfrin.isCurrent()) {
System.out.println("up to date");
代码示例来源:origin: net.sf.dnsjava-osgi/dnsjava-osgi
private void
doxfr() throws IOException, ZoneTransferException {
sendQuery();
while (state != END) {
byte [] in = client.recv();
Message response = parseMessage(in);
if (response.getHeader().getRcode() == Rcode.NOERROR &&
verifier != null)
response.tsigState = Message.TSIG_INTERMEDIATE;
else
fail("TSIG failure");
fallback();
doxfr();
return;
fail(Rcode.string(rcode));
fail("invalid question section");
fallback();
doxfr();
return;
parseRR(answers[i]);
fail("last message must be signed");
代码示例来源:origin: tiandawu/IotXmpp
private void
fromXFR(ZoneTransferIn xfrin) throws IOException, ZoneTransferException {
data = new TreeMap();
origin = xfrin.getName();
List records = xfrin.run();
for (Iterator it = records.iterator(); it.hasNext(); ) {
Record record = (Record) it.next();
maybeAddRecord(record);
}
if (!xfrin.isAXFR())
throw new IllegalArgumentException("zones can only be " +
"created from AXFRs");
validate();
}
代码示例来源:origin: org.littleshoot/dnsjava
case INITIALSOA:
if (type != Type.SOA)
fail("missing initial SOA");
initialsoa = rec;
end_serial = getSOASerial(rec);
if (qtype == Type.IXFR &&
Serial.compare(end_serial, ixfr_serial) <= 0)
logxfr("up to date");
state = END;
break;
getSOASerial(rec) == ixfr_serial)
logxfr("got incremental response");
state = IXFR_DELSOA;
} else {
handler.startAXFR();
handler.handleRecord(initialsoa);
logxfr("got nonincremental response");
state = AXFR;
parseRR(rec); // Restart...
return;
current_serial = getSOASerial(rec);
state = IXFR_ADDSOA;
内容来源于网络,如有侵权,请联系作者删除!