U mf0@s`dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z mZmZmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddZddZ ej!"dZ#e#r>ddl$Z%ddl&Z&e%j'Z(e%j)j*j+Z,Gd d d e(Z-Gd d d e&j.Z/nGd d d Z/e#Z0z ddl1Z1Wn$e2k rGdddZ1YnXejZ3Gdddej4j5Z6Gdddej4j7Z8Gdddej4j5Z9Gdddej4j5Z:ej;jddZ?e@edr ejAaBnejCaBdd ZDd!d"ZEd#d$ZFd%d&ZGdhd(d)ZHdid*d+ZIdd,ddd-d-dd.d'dd'dejJf ejKjLeMeeNeOeeMeOePePee eMePeeMeePeMfed/eeOejKjLd0d1d2ZQd3d4ZRd5d6ZSdje eejKjLeTfe eeNeeOeNfd7d8d9ZUdke ee eeNePePee ejVjWejXjYfeeTePePePeejKjLe d; dddd'ddddd-ejXjnf eMeejVjWeMfeejjjoeMfeejljpeMfeeNeOee ejVjWejXjYfeeejVjWeMfePeeNeeMeOeOePeejVjWeMfe d`dadbZ;GdcddddejqZrdd>dddderjsfeMejtjueejKjLeOeeNeeNeeMeOerdde dfdgZvdS)szTalk to a DNS server.N)AnyDictOptionalTupleUnioncCs,|dkr dS|t}|dkr(tjj|S)N)timedns exceptionTimeout) expirationtimeoutr7/opt/hc_python/lib/python3.8/site-packages/dns/query.py _remaining/s  rcCs|dkr dStt||SN)minr)r r rrr_expiration_for_this_attempt8srZdohcs0eZdZfddZdddZd ddZZS) _NetworkBackendcs&t||_||_||_||_dSr)super__init__ _local_port _resolver_bootstrap_address_family)selfresolver local_portbootstrap_addressfamily __class__rrrGs  z_NetworkBackend.__init__Nc Csg}t|\}}tj|r(||nP|jdk r@||jn8t|}|j} |r^tj|} |j j || |d} | }|D]} tj| } |dk s|j dkrtj ||j f| } nd} t| tj| }td|}z(t|tj | |f| |t|WStk rYq|Xq|tjdS)N)rlifetimerg@)_compute_timesr inet is_addressappendrrraf_for_addressr resolve_name addressesrlow_level_address_tuple _make_socketsocket SOCK_STREAMr_connect_CoreSyncStream ExceptionhttpcoreZ ConnectError)rhostportr local_addresssocket_optionsr)_r rZanswersaddressafsourcesockZattempt_expirationrrr connect_tcpNsH       z_NetworkBackend.connect_tcpcCstdSrNotImplementedError)rpathr r5rrrconnect_unix_socketusz#_NetworkBackend.connect_unix_socket)N)N)__name__ __module__ __qualname__rr;r? __classcell__rrr rrFs   (rcs*eZdZdddejdfdd ZZS)_HTTPTransportrN)rrrrcs>|dkrddl}|j}tj||t|||||j_dSNr)Z dns.resolverrResolverrrr_poolZ_network_backend)rrrrrargskwargsr r rrr{s  z_HTTPTransport.__init__)r@rArBr, AF_UNSPECrrCrrr rrDzs rDc@seZdZddZdS)rDcCstdSrr<)rr2r3r r4rrrr;sz_HTTPTransport.connect_tcpN)r@rArBr;rrrrrDsc@sXeZdZdZGdddeZGdddeZGdddZGdd d Ze d d Z d S) sslrc@s eZdZdS)zssl.WantReadExceptionNr@rArBrrrrWantReadExceptionsrMc@s eZdZdS)zssl.WantWriteExceptionNrLrrrrWantWriteExceptionsrNc@s eZdZdS)zssl.SSLContextNrLrrrr SSLContextsrOc@s eZdZdS)z ssl.SSLSocketNrLrrrr SSLSocketsrPcOs tddS)Nzno ssl support)r0)clsrHrIrrrcreate_default_contextszssl.create_default_contextN) r@rArB CERT_NONEr0rMrNrOrP classmethodrRrrrrrKsrKc@seZdZdZdS)UnexpectedSourcez=A DNS query response came from an unexpected address or port.Nr@rArB__doc__rrrrrUsrUc@seZdZdZdS) BadResponsez|j|d|dWS|WSWntk rd|YnXdS)NF)do_handshake_on_connectserver_hostname)socket_factory setblockingbind wrap_socketr0close)r8typer9 ssl_contextrrnrrrr+Rs    r+iFz /dns-queryzdns.resolver.Resolver)qr{r r3r9r|one_rr_per_rrsetignore_trailingsessionr>postrverifyrrreturnc Cstst|r t|tjs td|}t||||d\}}}d}ddi}|dk rtj |r|t j krxd ||| }q|t jkrd ||| }n|}|dkrd}d}n|d}|d }t|d d | || | |d }|rt|}ntjd d | |d }|f}| r*|dtt|d |j||||d}n.t|d}|}|j|||d|id}W5QRX|jdksz|jdkrtd ||j|jtjj|j|j|j ||d}|j!"|_#|$|st%|S)aReturn the response obtained after sending a query via DNS-over-HTTPS. *q*, a ``dns.message.Message``, the query to send. *where*, a ``str``, the nameserver IP address or the full URL. If an IP address is given, the URL will be constructed using the following schema: https://:/. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, a ``int``, the port to send the query to. The default is 443. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *session*, an ``httpx.Client``. If provided, the client session to use to send the queries. *path*, a ``str``. If *where* is an IP address, then *path* will be used to construct the URL to send the DNS query to. *post*, a ``bool``. If ``True``, the default, POST method will be used. *bootstrap_address*, a ``str``, the IP address to use to bypass resolution. *verify*, a ``bool`` or ``str``. If a ``True``, then TLS certificate verification of the server is done using the default CA bundle; if ``False``, then no verification is done; if a `str` then it specifies the path to a certificate file or directory which will be used for verification. *resolver*, a ``dns.resolver.Resolver`` or ``None``, the resolver to use for resolution of hostnames in URLs. If not specified, a new resolver with a default configuration will be used; note this is *not* the default resolver as that resolver might have been configured to use DoH causing a chicken-and-egg problem. This parameter only has an effect if the HTTP library is httpx. *family*, an ``int``, the address family. If socket.AF_UNSPEC (the default), both A and AAAA records will be retrieved. Returns a ``dns.message.Message``. z)session parameter must be an httpx.ClientFNacceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}rrqT)r4http1http2rrrrr)rrr transport)z content-typezcontent-length)headerscontentr =r )rr paramsi+z2{} responded with status code {} Response body: {}keyring request_macrr)&have_dohrYr\httpxZClientrzto_wirer}r r$r%r,AF_INETformatAF_INET6rD contextlib nullcontextupdatestrlenrbase64urlsafe_b64encoderstripdecodeget status_codermessage from_wirerrelapsed total_secondsr is_responserX)rr{r r3r9r|rrrr>rrrrrwirer8r6Z the_sourcerrurlr4rcmresponseZtwirerrrrhttpsfsD        rcCs2z ||WStk r*t||YqXqdS)zReads a datagram from the socket. A Timeout exception will be raised if the operation is not completed by the expiration time. N)recvfromBlockingIOErrorro)r:max_sizer rrr _udp_recvs rcCsHz"|r|||WS||WSWqtk r@t||YqXqdS)zSends the specified datagram to destination over the socket. A Timeout exception will be raised if the operation is not completed by the expiration time. N)sendtosendrrp)r:datarwr rrr _udp_sends r)r:whatrwr rcCs4t|tjjr|}t}t||||}||fS)aSend a DNS message to the specified UDP socket. *sock*, a ``socket``. *what*, a ``bytes`` or ``dns.message.Message``, the message to send. *destination*, a destination tuple appropriate for the address family of the socket, specifying where to send the query. *expiration*, a ``float`` or ``None``, the absolute time at which a timeout exception should be raised. If ``None``, no timeout will occur. Returns an ``(int, float)`` tuple of bytes sent and the sent time. )r\r rMessagerrr)r:rrwr sent_timenrrrsend_udps r) r:rwr rxrrrrraise_on_truncation ignore_errorsqueryrc  Csd} t|d|\} } t|j| ||s&qt} ztjj| |||||d}Wnjtjjk r}z*| r| dk r| |sWY qnW5d}~XYn t k r| rYqnYnX| r| dk r| |sq|r|| fS|| | fSqdS)aRead a DNS message from a UDP socket. *sock*, a ``socket``. *destination*, a destination tuple appropriate for the address family of the socket, specifying where the message is expected to arrive from. When receiving a response, this would be where the associated query was sent. *expiration*, a ``float`` or ``None``, the absolute time at which a timeout exception should be raised. If ``None``, no timeout will occur. *ignore_unexpected*, a ``bool``. If ``True``, ignore responses from unexpected sources. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *keyring*, a ``dict``, the keyring to use for TSIG. *request_mac*, a ``bytes`` or ``None``, the MAC of the request (for TSIG). *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *raise_on_truncation*, a ``bool``. If ``True``, raise an exception if the TC bit is set. Raises if the message is malformed, if network errors occur, of if there is a timeout. If *destination* is not ``None``, returns a ``(dns.message.Message, float)`` tuple of the received message and the received time. If *destination* is ``None``, returns a ``(dns.message.Message, float, tuple)`` tuple of the received message, the received time, and the address where the message arrived from. *ignore_errors*, a ``bool``. If various format errors or response mismatches occur, ignore them and keep listening for a valid response. The default is ``False``. *query*, a ``dns.message.Message`` or ``None``. If not ``None`` and *ignore_errors* is ``True``, check that the received message is a response to this query, and if not keep listening for a valid response. r)rrrrrN) rryrrr rr Truncatedrr0)r:rwr rxrrrrrrrrrv received_timererrr receive_udp2sJ>   r5) rr{r r3r9r|rxrrrr:rrc  Cs|} t||||\} }}t|\}}| r8t| }nt| tj|}|`}t|| ||t ||||||j |j || | | \}}|||_ | s| |st|W5QRSQRXdstdS)aReturn the response obtained after sending a query via UDP. *q*, a ``dns.message.Message``, the query to send *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, an ``int``, the port send the message to. The default is 53. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *ignore_unexpected*, a ``bool``. If ``True``, ignore responses from unexpected sources. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *raise_on_truncation*, a ``bool``. If ``True``, raise an exception if the TC bit is set. *sock*, a ``socket.socket``, or ``None``, the socket to use for the query. If ``None``, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking datagram socket, and the *source* and *source_port* are ignored. *ignore_errors*, a ``bool``. If various format errors or response mismatches occur, ignore them and keep listening for a valid response. The default is ``False``. Returns a ``dns.message.Message``. FN)rr}r#rrr+r, SOCK_DGRAMrrrmacrrrXAssertionError)rr{r r3r9r|rxrrrr:rrr8rw begin_timer rrnrrrrrudps@8    r) rr{r r3r9r|rxrrudp_socktcp_sockrrc Csfz(t|||||||||d| | } | dfWStjjk r`t||||||||| } | dfYSXdS)a|Return the response to the query, trying UDP first and falling back to TCP if UDP results in a truncated response. *q*, a ``dns.message.Message``, the query to send *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, an ``int``, the port send the message to. The default is 53. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *ignore_unexpected*, a ``bool``. If ``True``, ignore responses from unexpected sources. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *udp_sock*, a ``socket.socket``, or ``None``, the socket to use for the UDP query. If ``None``, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking datagram socket, and the *source* and *source_port* are ignored for the UDP query. *tcp_sock*, a ``socket.socket``, or ``None``, the connected socket to use for the TCP query. If ``None``, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking connected stream socket, and *where*, *source* and *source_port* are ignored for the TCP query. *ignore_errors*, a ``bool``. If various format errors or response mismatches occur while listening for UDP, ignore them and keep listening for a valid response. The default is ``False``. Returns a (``dns.message.Message``, tcp) tuple where tcp is ``True`` if and only if TCP was used. TFN)rr rrtcp) rr{r r3r9r|rxrrrrrrrrrudp_with_fallbacks:9  rc Csd}|dkrz.||}|dkr$t|t|8}||7}Wqttjfk r^t||Yqtjk r|t||YqXq|S)zRead the specified number of bytes from sock. Keep trying until we either get the desired amount, or we hit EOF. A Timeout exception will be raised if the operation is not completed by the expiration time. rr) recvEOFErrorrrrKSSLWantReadErrorroSSLWantWriteErrorrp)r:countr rnrrrr _net_readOs   rc Csxd}t|}||krtz||||d7}Wq ttjfk rRt||Yq tjk rpt||Yq Xq dS)zWrite the specified data to the socket. A Timeout exception will be raised if the operation is not completed by the expiration time. rN)rrrrKrrprro)r:rr currentlrrr _net_writedsr)r:rr rcCsPt|tjjr|jdd}nt|dd|}t}t|||t||fS)a{Send a DNS message to the specified TCP socket. *sock*, a ``socket``. *what*, a ``bytes`` or ``dns.message.Message``, the message to send. *expiration*, a ``float`` or ``None``, the absolute time at which a timeout exception should be raised. If ``None``, no timeout will occur. Returns an ``(int, float)`` tuple of bytes sent and the sent time. T)Zprepend_lengthbig) r\r rrrrto_bytesrr)r:rr tcpmsgrrrrsend_tcpts  r)r:r rrrrrc CsLt|d|}td|\}t|||}t} tjj|||||d} | | fS)aRead a DNS message from a TCP socket. *sock*, a ``socket``. *expiration*, a ``float`` or ``None``, the absolute time at which a timeout exception should be raised. If ``None``, no timeout will occur. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *keyring*, a ``dict``, the keyring to use for TSIG. *request_mac*, a ``bytes`` or ``None``, the MAC of the request (for TSIG). *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. Raises if the message is malformed, if network errors occur, of if there is a timeout. Returns a ``(dns.message.Message, float)`` tuple of the received message and the received time. r!Hr)rstructunpackrr rr) r:r rrrrldatarrrrrrr receive_tcps!  rcCs`||}|dkrdS|tjtjtjfkrDt|||tjtj }|dkr\t |t |dSrE) connect_exerrnoZ EINPROGRESS EWOULDBLOCKZEALREADYrp getsockoptr, SOL_SOCKETSO_ERROROSErrorosstrerror)rnr7r errrrrr.s  r.) rr{r r3r9r|rrr:rc  Cs|} t|\} } |r$t|} n"t||||\} }}t| tj|} | `}|s\t||| t || | t || ||j |j |\}}|| |_ ||st|W5QRSQRXdstdS)aReturn the response obtained after sending a query via TCP. *q*, a ``dns.message.Message``, the query to send *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, an ``int``, the port send the message to. The default is 53. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *sock*, a ``socket.socket``, or ``None``, the connected socket to use for the query. If ``None``, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking connected stream socket, and *where*, *port*, *source* and *source_port* are ignored. Returns a ``dns.message.Message``. FN)rr#rrr}r+r,r-r.rrrrrrrXr)rr{r r3r9r|rrr:rrr rr8rwrnrrrrrrs:+       rcCsTz|WdStjk r.t||Yqtjk rLt||YqXqdSr) do_handshakerKrrorrprmrrr_tls_handshakesr)rrrcCsd}d}t|tr>tj|r$|}ntj|r6|}ntdtj||d}tj j |_ |dkrdd|_ | dg|dkrtj|_|S)Nzinvalid verify string)cafilecapathFdot)r\rrr>isfileisdirrzrKrR TLSVersionTLSv1_2minimum_versioncheck_hostnameset_alpn_protocolsrS verify_mode)rrrrrrrr_make_dot_ssl_contexts      rU) rr{r r3r9r|rrr:rrrrc  Cs|rt||||||||| S|} t|\} }t||||\}}}| dkrZ|sZt| | } t|tj|| | df}t|||t ||t || |t ||||j |j |\}}|| |_||st|W5QRSQRXdstdS)akReturn the response obtained after sending a query via TLS. *q*, a ``dns.message.Message``, the query to send *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, an ``int``, the port send the message to. The default is 853. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *sock*, an ``ssl.SSLSocket``, or ``None``, the socket to use for the query. If ``None``, the default, a socket is created. Note that if a socket is provided, it must be a nonblocking connected SSL stream socket, and *where*, *port*, *source*, *source_port*, and *ssl_context* are ignored. *ssl_context*, an ``ssl.SSLContext``, the context to use when establishing a TLS connection. If ``None``, the default, creates one with the default configuration. *server_hostname*, a ``str`` containing the server's hostname. The default is ``None``, which means that no hostname is known, and if an SSL context is created, hostname checking will be disabled. *verify*, a ``bool`` or ``str``. If a ``True``, then TLS certificate verification of the server is done using the default CA bundle; if ``False``, then no verification is done; if a `str` then it specifies the path to a certificate file or directory which will be used for verification. Returns a ``dns.message.Message``. N)rrF)rrr#r}rr+r,r-r.rrrrrrrrXr)rr{r r3r9r|rrr:rrrrrr r8rwrnrrrrrtls1s^=          r) rr{r r3r9r|rr connectionrrrc  Cstjjstdd|_|} |r2td} |} ntjj| | d} | }| ^|s`| ||||} t |\}}| | }| | d| t|} W5QRXt}W5QRXtjj| |j|j||d}t||d|_||st|S)aReturn the response obtained after sending a query via DNS-over-QUIC. *q*, a ``dns.message.Message``, the query to send. *where*, a ``str``, the nameserver IP address. *timeout*, a ``float`` or ``None``, the number of seconds to wait before the query times out. If ``None``, the default, wait forever. *port*, a ``int``, the port to send the query to. The default is 853. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *one_rr_per_rrset*, a ``bool``. If ``True``, put each RR into its own RRset. *ignore_trailing*, a ``bool``. If ``True``, ignore trailing junk at end of the received message. *connection*, a ``dns.quic.SyncQuicConnection``. If provided, the connection to use to send the query. *verify*, a ``bool`` or ``str``. If a ``True``, then TLS certificate verification of the server is done using the default CA bundle; if ``False``, then no verification is done; if a `str` then it specifies the path to a certificate file or directory which will be used for verification. *server_hostname*, a ``str`` containing the server's hostname. The default is ``None``, which means that no hostname is known, and if an SSL context is created, hostname checking will be disabled. Returns a ``dns.message.Message``. zDNS-over-QUIC is not available.rN)rZ server_nameTrr)r quicZ have_quicrZidrrrZSyncQuicManagerconnectr#Z make_streamrZreceiverrrrrrmaxrrX)rr{r r3r9r|rrrrrrmanagerZthe_connectionZ the_managerstartr streamfinishrrrrrs>2     r)r{zonerdtyperdclassr r3rkeyname relativizer"r9r|serialuse_udp keyalgorithmrc' cst|trtj|}tjj|}tj |||}|tjj krdtj |dddd| }|j ||dk r||j|||d|}t||| | \}}} | r|tjj krtd| rtjntj}t||| }t| \}}t|||t|}| rt||d|ntd||}t|||d }d }d }d}|rF|}tjj}nd}|}d} |st|\}}!|!dks|dk r|!|kr|}!| rt|d |!\}}n&t|d |!}"t d|"\}t|||!}|tjj k}#tjj!||j"|j#d || d |#d }$|$$}%|%tj$j%krt&|%|$j'} d}&|dkr|$j(r<|$j(dj|krHtj)*d|$j(d}|j+tjj,krntj)*dd}&|-}|tjj krtj./|dj.| krd }nd }|$j(|&dD]}|rtj)*d|j+tjj,krX|j|krX|r|dj.| kr tj)*dd }n|tjj kr&| }||krj|tjj0ksR|tjj krj|rjd }n|rtjj0}d }q|r|j"r|$j1stj)*d|$VqRW5QRXdS)aReturn a generator for the responses to a zone transfer. *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *zone*, a ``dns.name.Name`` or ``str``, the name of the zone to transfer. *rdtype*, an ``int`` or ``str``, the type of zone transfer. The default is ``dns.rdatatype.AXFR``. ``dns.rdatatype.IXFR`` can be used to do an incremental transfer instead. *rdclass*, an ``int`` or ``str``, the class of the zone transfer. The default is ``dns.rdataclass.IN``. *timeout*, a ``float``, the number of seconds to wait for each response message. If None, the default, wait forever. *port*, an ``int``, the port send the message to. The default is 53. *keyring*, a ``dict``, the keyring to use for TSIG. *keyname*, a ``dns.name.Name`` or ``str``, the name of the TSIG key to use. *relativize*, a ``bool``. If ``True``, all names in the zone will be relativized to the zone origin. It is essential that the relativize setting matches the one specified to ``dns.zone.from_xfr()`` if using this generator to make a zone. *lifetime*, a ``float``, the total number of seconds to spend doing the transfer. If ``None``, the default, then there is no limit on the time the transfer may take. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *serial*, an ``int``, the SOA serial number to use as the base for an IXFR diff sequence (only meaningful if *rdtype* is ``dns.rdatatype.IXFR``). *use_udp*, a ``bool``. If ``True``, use UDP (only meaningful for IXFR). *keyalgorithm*, a ``dns.name.Name`` or ``str``, the TSIG algorithm to use. Raises on errors, and so does the generator. Returns a generator of ``dns.message.Message`` objects. rINSOAz. . %u 0 0 0 0N) algorithmzcannot do a UDP AXFRrFTrrrrxfrorigintsig_ctxmultirz No answer or RRset not for qnamezfirst RRset is not an SOArqzanswers after final SOAzIXFR base serial mismatch missing TSIG)2r\rr nameZ from_text rdatatype RdataTypemaker make_queryIXFRrrset authorityr&Zuse_tsigrr}rzr,rr-r+r#r.rrrpackremptyrrrrrrrcodeZNOERROR TransferErrorrZanswerr FormErrorr rcopyrZSerialAXFRhad_tsig)'r{r r rr r3rrrr"r9r|rrrrr#rr8rw sock_typernr6r rrdoneZ delete_modeZ expecting_SOAZ soa_rrsetrZonamer mexpirationris_ixfrrr'Z answer_indexrrrrsE                         rc@seZdZdZdZdZdZdS)UDPModeaHow should UDP be used in an IXFR from :py:func:`inbound_xfr()`? NEVER means "never use UDP; always use TCP" TRY_FIRST means "try to use UDP but fall back to TCP if needed" ONLY means "raise ``dns.xfr.UseTCP`` if trying UDP does not succeed" rrqrN)r@rArBrWNEVERZ TRY_FIRSTONLYrrrrr1sr1) r{ txn_managerrr3r r"r9r|udp_moderc  Cs>|dkrtj|\}} n tj|} |jdj} | tjjk} |} | } t ||||\}}}t |\}}d}|r:d}| r|t j krtj}d}n tj}d}t|||}t||||rt|| d|n tdt| | }t|||tj|| | |$}d}d}|st |\}}|dks>|dk rB||krB|}|rZt|d|\}}n&t|d|}td|\}t|||}tjj||j|jd| || | d}z| |}WnFtjj!k r|st"|t j#krނd}d}t j }YqYnX|j$}q|s$|jr$|j%s$tj&'d W5QRXW5QRXqrdS) aConduct an inbound transfer and apply it via a transaction from the txn_manager. *where*, a ``str`` containing an IPv4 or IPv6 address, where to send the message. *txn_manager*, a ``dns.transaction.TransactionManager``, the txn_manager for this transfer (typically a ``dns.zone.Zone``). *query*, the query to send. If not supplied, a default query is constructed using information from the *txn_manager*. *port*, an ``int``, the port send the message to. The default is 53. *timeout*, a ``float``, the number of seconds to wait for each response message. If None, the default, wait forever. *lifetime*, a ``float``, the total number of seconds to spend doing the transfer. If ``None``, the default, then there is no limit on the time the transfer may take. *source*, a ``str`` containing an IPv4 or IPv6 address, specifying the source address. The default is the wildcard address. *source_port*, an ``int``, the port from which to send the message. The default is 0. *udp_mode*, a ``dns.query.UDPMode``, determines how UDP is used for IXFRs. The default is ``dns.UDPMode.NEVER``, i.e. only use TCP. Other possibilities are ``dns.UDPMode.TRY_FIRST``, which means "try UDP but fallback to TCP if needed", and ``dns.UDPMode.ONLY``, which means "try UDP and raise ``dns.xfr.UseTCP`` if it does not succeed. Raises on errors. NrTFrrrrr)(r rr!Zextract_serial_from_queryquestionr rr"Zfrom_wire_originrr}r#r1r2r,rr-r+r.rrr%rrZInboundrrrrrrrZprocess_messageZUseTCPrr3rr,r r))r{r4rr3r r"r9r|r5rr r0rrr8rwr6r retryr-Zis_udprnrZinboundr.rr/Zrwirerrrrrr inbound_xfrs/                r8)T)NN)N) NNFFNrFFFN) NrNrFFFFNF) NrNrFFFNNF)N)NFNrF)NrNrFFN) NrNrFFNNNT) NrNrFFNTN)wrWrrenumrros.pathr_r,rrtypingrrrrrZ dns._featuresr Z dns.exceptionZdns.inetZ dns.messageZdns.nameZdns.quicZ dns.rcodeZdns.rdataclassZ dns.rdatatypeZ dns.serialZdns.transactionZdns.tsigZdns.xfrrrZ _featuresZhaveZ _have_httpxZhttpcore._backends.syncr1rZNetworkBackendZ_CoreNetworkBackendZ _backendssyncZ SyncStreamr/rZ HTTPTransportrDrrK ImportErrorrr Z DNSExceptionrUr)rXrYrZrr(r#rirjhasattrrkr^SelectSelectorrorprtryr}r+rJrrrfloatintboolrrrbytesrrNameZtsigKeyrrrrrrrr.rrrOrrPrrZSyncQuicConnectionrr+Z rdataclassrZdefault_algorithmrZ RdataClassIntEnumr1r2Z transactionZTransactionManagerr8rrrrs   4    ,       m ^ X  / D     n   Z ;