Package org.xbill.DNS

Class ZoneTransferIn

java.lang.Object
org.xbill.DNS.ZoneTransferIn

public class ZoneTransferIn extends Object
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.
  • Field Details

  • Constructor Details

    • ZoneTransferIn

      ZoneTransferIn(Name zone, int xfrtype, long serial, boolean fallback, SocketAddress address, TSIG key)
  • Method Details

    • newAXFR

      public static ZoneTransferIn newAXFR(Name zone, SocketAddress address, TSIG key)
      Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer).
      Parameters:
      zone - The zone to transfer.
      address - The host/port from which to transfer the zone.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • newAXFR

      public static ZoneTransferIn newAXFR(Name zone, String host, int port, TSIG key)
      Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer).
      Parameters:
      zone - The zone to transfer.
      host - The host from which to transfer the zone.
      port - The port to connect to on the server, or 0 for the default.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • newAXFR

      public static ZoneTransferIn newAXFR(Name zone, String host, TSIG key)
      Instantiates a ZoneTransferIn object to do an AXFR (full zone transfer).
      Parameters:
      zone - The zone to transfer.
      host - The host from which to transfer the zone.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • newIXFR

      public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, SocketAddress address, TSIG key)
      Instantiates a ZoneTransferIn object to do an IXFR (incremental zone transfer).
      Parameters:
      zone - The zone to transfer.
      serial - The existing serial number.
      fallback - If true, fall back to AXFR if IXFR is not supported.
      address - The host/port from which to transfer the zone.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • newIXFR

      public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, int port, TSIG key)
      Instantiates a ZoneTransferIn object to do an IXFR (incremental zone transfer).
      Parameters:
      zone - The zone to transfer.
      serial - The existing serial number.
      fallback - If true, fall back to AXFR if IXFR is not supported.
      host - The host from which to transfer the zone.
      port - The port to connect to on the server, or 0 for the default.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • newIXFR

      public static ZoneTransferIn newIXFR(Name zone, long serial, boolean fallback, String host, TSIG key)
      Instantiates a ZoneTransferIn object to do an IXFR (incremental zone transfer).
      Parameters:
      zone - The zone to transfer.
      serial - The existing serial number.
      fallback - If true, fall back to AXFR if IXFR is not supported.
      host - The host from which to transfer the zone.
      key - The TSIG key used to authenticate the transfer, or null.
      Returns:
      The ZoneTransferIn object.
    • getName

      public Name getName()
      Gets the name of the zone being transferred.
    • getType

      public int getType()
      Gets the type of zone transfer (either AXFR or IXFR).
    • setTimeout

      @Deprecated public void setTimeout(int secs)
      Deprecated.
      Sets a timeout on this zone transfer. The default is 900 seconds (15 minutes).
      Parameters:
      secs - The maximum amount of time that this zone transfer can take.
    • setTimeout

      public void setTimeout(Duration t)
      Sets a timeout on this zone transfer. The default is 900 seconds (15 minutes).
      Parameters:
      t - The maximum amount of time that this zone transfer can take.
    • setDClass

      public void setDClass(int dclass)
      Sets an alternate DNS class for this zone transfer.
      Parameters:
      dclass - The class to use instead of class IN.
    • setLocalAddress

      public void setLocalAddress(SocketAddress addr)
      Sets the local address to bind to when sending messages.
      Parameters:
      addr - The local address to send messages from.
    • openConnection

      private void openConnection() throws IOException
      Throws:
      IOException
    • createTcpClient

      TCPClient createTcpClient(Duration timeout) throws IOException
      Throws:
      IOException
    • sendQuery

      private void sendQuery() throws IOException
      Throws:
      IOException
    • getSOASerial

      private static long getSOASerial(Record rec)
    • logxfr

      private void logxfr(String s)
    • fail

      private void fail(String s) throws ZoneTransferException
      Throws:
      ZoneTransferException
    • fallback

      private void fallback() throws ZoneTransferException
      Throws:
      ZoneTransferException
    • parseRR

      private void parseRR(Record rec) throws ZoneTransferException
      Throws:
      ZoneTransferException
    • closeConnection

      private void closeConnection()
    • parseMessage

      private Message parseMessage(byte[] b) throws WireParseException
      Throws:
      WireParseException
    • doxfr

      private void doxfr() throws IOException, ZoneTransferException
      Throws:
      IOException
      ZoneTransferException
    • run

      Does the zone transfer.
      Parameters:
      handler - The callback object that handles the zone transfer data.
      Throws:
      IOException - The zone transfer failed to due an IO problem.
      ZoneTransferException - The zone transfer failed to due a problem with the zone transfer itself.
    • run

      public void run() throws IOException, ZoneTransferException
      Does the zone transfer using an internal handler. Results can be obtained by calling getAXFR() or getIXFR
      Throws:
      IOException - The zone transfer failed to due an IO problem.
      ZoneTransferException - The zone transfer failed to due a problem with the zone transfer itself.
    • getBasicHandler

      private ZoneTransferIn.BasicHandler getBasicHandler() throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • isAXFR

      public boolean isAXFR()
      Returns true if the response is an AXFR-style response (List of Records). This will be true if either an IXFR was performed, an IXFR was performed and the server provided a full zone transfer, or an IXFR failed and fallback to AXFR occurred.
    • getAXFR

      public List<Record> getAXFR()
      Gets the AXFR-style response.
      Throws:
      IllegalArgumentException - The transfer used the callback interface, so the response was not stored.
    • isIXFR

      public boolean isIXFR()
      Returns true if the response is an IXFR-style response (List of Deltas). This will be true only if an IXFR was performed and the server provided an incremental zone transfer.
    • getIXFR

      public List<ZoneTransferIn.Delta> getIXFR()
      Gets the IXFR-style response.
      Throws:
      IllegalArgumentException - The transfer used the callback interface, so the response was not stored.
    • isCurrent

      public boolean isCurrent()
      Returns true if the response indicates that the zone is up to date. This will be true only if an IXFR was performed.
      Throws:
      IllegalArgumentException - The transfer used the callback interface, so the response was not stored.