The dns.xfr.Inbound Class and make_query() function

The Inbound class provides support for inbound DNS zone transfers, both AXFR and IXFR. It is invoked by I/O code, i.e. dns.query.inbound_xfr() or dns.asyncquery.inbound_xfr(). When a message related to the transfer arrives, the I/O code calls the process_message() method which adds the content to the pending transaction.

The make_query() function is used to making the query message for the query methods to use in more complex situations, e.g. with TSIG or EDNS.

class dns.xfr.Inbound(txn_manager: TransactionManager, rdtype: RdataType = RdataType.AXFR, serial: int | None = None, is_udp: bool = False)[source]

State machine for zone transfers.

Initialize an inbound zone transfer.

txn_manager is a dns.transaction.TransactionManager.

rdtype can be dns.rdatatype.AXFR or dns.rdatatype.IXFR

serial is the base serial number for IXFRs, and is required in that case.

is_udp, a bool indidicates if UDP is being used for this XFR.

process_message(message: Message) bool[source]

Process one message in the transfer.

The message should have the same relativization as was specified when the dns.xfr.Inbound was created. The message should also have been created with one_rr_per_rrset=True because order matters.

Returns True if the transfer is complete, and False otherwise.

dns.xfr.make_query(txn_manager: ~dns.transaction.TransactionManager, serial: int | None = 0, use_edns: int | bool | None = None, ednsflags: int | None = None, payload: int | None = None, request_payload: int | None = None, options: ~typing.List[~dns.edns.Option] | None = None, keyring: ~typing.Any = None, keyname: ~dns.name.Name | None = None, keyalgorithm: ~dns.name.Name | str = <DNS name hmac-sha256.>) Tuple[QueryMessage, int | None][source]

Make an AXFR or IXFR query.

txn_manager is a dns.transaction.TransactionManager, typically a dns.zone.Zone.

serial is an int or None. If 0, then IXFR will be attempted using the most recent serial number from the txn_manager; it is the caller’s responsibility to ensure there are no write transactions active that could invalidate the retrieved serial. If a serial cannot be determined, AXFR will be forced. Other integer values are the starting serial to use. None forces an AXFR.

Please see the documentation for dns.message.make_query() and dns.message.Message.use_tsig() for details on the other parameters to this function.

Returns a (query, serial) tuple.