⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zonetransferin.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Copyright (c) 2003-2004 Brian Wellington (bwelling@xbill.org)// Parts of this are derived from lib/dns/xfrin.c from BIND 9; its copyright// notice follows./* * Copyright (C) 1999-2001  Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */package org.xbill.DNS;import java.io.*;import java.net.*;import java.util.*;/** * An incoming DNS Zone Transfer.  To use this class, first initialize an * object, then call the run() method.  If run() doesn't throw an exception * the result will either be an IXFR-style response, an AXFR-style response, * or an indication that the zone is up to date. * * @author Brian Wellington */public class ZoneTransferIn {private static final int INITIALSOA	= 0;private static final int FIRSTDATA	= 1;private static final int IXFR_DELSOA	= 2;private static final int IXFR_DEL	= 3;private static final int IXFR_ADDSOA	= 4;private static final int IXFR_ADD	= 5;private static final int AXFR		= 6;private static final int END		= 7;private Name zname;private int qtype;private int dclass;private long ixfr_serial;private boolean want_fallback;private SocketAddress address;private TCPClient client;private TSIG tsig;private TSIG.StreamVerifier verifier;private long timeout = 900 * 1000;private int state;private long end_serial;private long current_serial;private Record initialsoa;private int rtype;private List axfr;private List ixfr;public static class Delta {	/**	 * All changes between two versions of a zone in an IXFR response.	 */	/** The starting serial number of this delta. */	public long start;	/** The ending serial number of this delta. */	public long end;	/** A list of records added between the start and end versions */	public List adds;	/** A list of records deleted between the start and end versions */	public List deletes;	private	Delta() {		adds = new ArrayList();		deletes = new ArrayList();	}}privateZoneTransferIn() {}privateZoneTransferIn(Name zone, int xfrtype, long serial, boolean fallback,	       SocketAddress address, TSIG key){	this.address = address;	this.tsig = key;	if (zone.isAbsolute())		zname = zone;	else {		try {			zname = Name.concatenate(zone, Name.root);		}		catch (NameTooLongException e) {			throw new IllegalArgumentException("ZoneTransferIn: " +							   "name too long");		}	}	qtype = xfrtype;	dclass = DClass.IN;	ixfr_serial = serial;	want_fallback = fallback;	state = INITIALSOA;}/** * 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 ZoneTransferInnewAXFR(Name zone, SocketAddress address, TSIG key) {	return new ZoneTransferIn(zone, Type.AXFR, 0, false, address, key);}/** * 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 port The port to connect to on the server, or 0 for the default. * @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 ZoneTransferInnewAXFR(Name zone, String host, int port, TSIG key)throws UnknownHostException{	return newAXFR(zone, new InetSocketAddress(host, port), key);}/** * Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer). * @param zone The zone to transfer. * @param res The resolver to use when doing the transfer. * @return The ZoneTransferIn object. * * @deprecated Use newAXFR(Name, String, int, TSIG) or newAXFR(Name, * SocketAddress, TSIG) */public static ZoneTransferInnewAXFR(Name zone, SimpleResolver res) {	ZoneTransferIn xfrin = newAXFR(zone, res.getAddress(),				       res.getTSIGKey());	xfrin.timeout = res.getTimeout() * 1000L;	return xfrin;}/** * 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 ZoneTransferInnewAXFR(Name zone, String host, TSIG key)throws UnknownHostException{	return newAXFR(zone, host, 0, key);}/** * 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 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 ZoneTransferInnewIXFR(Name zone, long serial, boolean fallback, SocketAddress address,	TSIG key){	return new ZoneTransferIn(zone, Type.IXFR, serial, fallback, address,				  key);}/** * 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 port The port to connect to on the server, or 0 for the default. * @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 ZoneTransferInnewIXFR(Name zone, long serial, boolean fallback, String host, int port,	TSIG key)throws UnknownHostException{	return newIXFR(zone, serial, fallback,		       new InetSocketAddress(host, port), key);}/** * 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 res The resolver to use when doing the transfer. * @return The ZoneTransferIn object. * * @deprecated Use newIXFR(Name, long, int, String, int, TSIG) or * newIXFR((Name, long, int, SocketAddress, TSIG) */public static ZoneTransferInnewIXFR(Name zone, long serial, boolean fallback, SimpleResolver res) {	ZoneTransferIn xfrin = newIXFR(zone, serial, fallback,				       res.getAddress(), res.getTSIGKey());	xfrin.timeout = res.getTimeout() * 1000L;	return xfrin;}/** * 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 ZoneTransferInnewIXFR(Name zone, long serial, boolean fallback, String host, TSIG key)throws UnknownHostException{	return newIXFR(zone, serial, fallback, host, 0, key);}/** * Gets the name of the zone being transferred. */public NamegetName() {	return zname;}/** * Gets the type of zone transfer (either AXFR or IXFR). */public intgetType() {	return qtype;}/** * Sets a timeout on this zone transfer.  The default is 900 seconds (15 * minutes). * @param secs The maximum amount of time that this zone transfer can take. */public voidsetTimeout(int secs) {	if (secs < 0)		throw new IllegalArgumentException("timeout cannt be negative");	timeout = 1000L * secs;}/** * Sets an alternate DNS class for this zone transfer. * @param dclass The class to use instead of class IN. */public voidsetDClass(int dclass) {	DClass.check(dclass);	this.dclass = dclass;}private voidopenConnection() throws IOException {	long endTime = System.currentTimeMillis() + timeout;	client = new TCPClient(endTime);	client.connect(address);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -