a Me0@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"e2y~GdddZ1Yn0ejZ3Gdddej4j5Z6Gdddej4j7Z8Gdddej4j5Z9Gdddej4j5Z: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,|dur dS|t}|dkr(tjj|S)N)timedns exceptionTimeout) expirationtimeoutr-/usr/lib/python3.9/site-packages/dns/query.py _remaining/s  rcCs|dur 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|jdur@||jn8t|}|j} |r^tj|} |j j || |d} | }|D]} tj| } |dus|j dkrtj ||j f| } nd} t| tj| }td|}z(t|tj | |f| |t|WSty Yq|0q|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_tcpNsB        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)rrrrcsB|durddl}|j}tj|i|t|||||j_dSNr)Z dns.resolverrZResolverrrrZ_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@rArBrrrrWantReadExceptionsrKc@s eZdZdS)zssl.WantWriteExceptionNrJrrrrWantWriteExceptionsrLc@s eZdZdS)zssl.SSLContextNrJrrrr SSLContextsrMc@s eZdZdS)z ssl.SSLSocketNrJrrrr SSLSocketsrNcOs tddS)Nzno ssl support)r0)clsrFrGrrrcreate_default_contextszssl.create_default_contextN) r@rArB CERT_NONEr0rKrLrMrN classmethodrPrrrrrIsrIc@seZdZdZdS)UnexpectedSourcez=A DNS query response came from an unexpected address or port.Nr@rArB__doc__rrrrrSsrSc@seZdZdZdS) BadResponsez|j|d|dWS|WSWntyb|Yn0dS)NF)Zdo_handshake_on_connectserver_hostname)socket_factoryZ setblockingZbindZ wrap_socketr0close)r8typer9 ssl_contextrtrfrrrr+Rs     r+iFz /dns-queryzdns.resolver.Resolver)qrqr r3r9rrone_rr_per_rrsetignore_trailingsessionr>postrverifyrrreturnc Cstst|r t|tjs td|}t||||d\}}}d}ddi}|durtj |r|t j krxd ||| }q|t jkrd ||| }n|}|durd}d}n|d}|d }t|d d | || | |d }|rt|}ntjd d | |d }|p}| r*|dtt|d |j||||d}n.t|d}|}|j|||d|id}Wdn1sn0Y|jdks|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.ClientFNZacceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}rriT)r4http1http2r~rrrr)rrr~ transport)z content-typezcontent-length)headerscontentr =r )rr paramsi+z2{} responded with status code {} Response body: {}keyring request_macrzr{)&have_dohrWrYhttpxZClientrpto_wirersr r$r%r,ZAF_INETformatZAF_INET6rD contextlib nullcontextupdatestrlenr}base64Zurlsafe_b64encoderstripdecodegetZ status_codermessage from_wirerrelapsedZ total_secondsr is_responserV)ryrqr r3r9rrrzr{r|r>r}rr~rrwirer8r6Z the_sourcerrurlr4rcmresponseZtwirerrrrhttpsfsD       &   rcCs0z ||WSty(t||Yq0qdS)zReads a datagram from the socket. A Timeout exception will be raised if the operation is not completed by the expiration time. N)ZrecvfromBlockingIOErrorrg)r:Zmax_sizer rrr _udp_recvs  rcCsFz"|r|||WS||WSWqty>t||Yq0qdS)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)Zsendtosendrrh)r:datarmr rrr _udp_sends  r)r:whatrmr 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. )rYr rMessagerrr)r:rrmr sent_timenrrrsend_udps r) r:rmr rnrzrrr{raise_on_truncation ignore_errorsqueryrc  Csd} t|d|\} } t|j| ||s&qt} ztjj| |||||d}Wnntjjy}z6| r| dur| |sWYd}~qnWYd}~n&d}~0t y| rYqnYn0| r| dur| |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)rrrzr{rN) rrorrr rr Truncatedrr0)r:rmr rnrzrrr{rrrrrl received_timererrr receive_udp2sD>    r5) ryrqr r3r9rrrnrzr{rr:rrc  Cs|} t||||\} }}t|\}}| r8t| }nt| tj|}|b}t|| ||t ||||||j |j || | | \}}|||_ | s| |st|WdS1s0YdsJdS)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``. NF)rrsr#rrr+r, SOCK_DGRAMrrrmacrrrV)ryrqr r3r9rrrnrzr{rr:rrr8rm begin_timer rrfrrrrrudps:8    "r) ryrqr r3r9rrrnrzr{udp_socktcp_sockrrc Csdz(t|||||||||d| | } | dfWStjjy^t||||||||| } | dfYS0dS)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) ryrqr r3r9rrrnrzr{rrrrrrrudp_with_fallbacks:9  rc Csd}|dkr|z.||}|dkr$t|t|8}||7}Wqttjfy\t||Yqtjyxt||Yq0q|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) ZrecvEOFErrorrrrISSLWantReadErrorrgSSLWantWriteErrorrh)r:countr rfrrrr _net_readOs   rc Cstd}t|}||krpz||||d7}Wq ttjfyPt||Yq tjylt||Yq 0q 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)rrrrIrrhrrg)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_lengthZbig) rYr rrrrto_bytesrr)r:rr tcpmsgrrrrsend_tcpts  r)r:r rzrrr{rc 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 rzrrr{ldatarrrrrrr receive_tcps!  rcCs`||}|dkrdS|tjtjtjfvrDt|||tjtj }|dkr\t |t |dSrE) Z connect_exerrnoZ EINPROGRESSZ EWOULDBLOCKZEALREADYrhZ getsockoptr,Z SOL_SOCKETZSO_ERROROSErrorosstrerror)rfr7r errrrrr.s  r.) ryrqr r3r9rrrzr{r:rc Cs|} t|\} } |r$t|} n"t||||\} }}t| tj|} | b}|s\t||| t || | t || ||j |j |\}}|| |_ ||st|WdS1s0YdsJdS)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``. NF)rr#rrrsr+r,r-r.rrrrrrrV)ryrqr r3r9rrrzr{r:rrr rr8rmrfrrrrrrs*+       "rcCsPz|WdStjy,t||YqtjyHt||Yq0qdSr)Z do_handshakerIrrgrrhrerrr_tls_handshakesr)rtr~rcCsd}d}t|tr>tj|r$|}ntj|r6|}ntdtj||d}tj j |_ |durdd|_ | dg|durtj|_|S)Nzinvalid verify string)cafilecapathFdot)rYrrr>isfileisdirrprIrPZ TLSVersionZTLSv1_2Zminimum_versionZcheck_hostnameZset_alpn_protocolsrQ verify_mode)rtr~rrrxrrr_make_dot_ssl_contexts      rU) ryrqr r3r9rrrzr{r:rxrtr~rc  Cs|rt||||||||| S|} t|\} }t||||\}}}| durZ|sZt| | } t|tj|| | dh}t|||t ||t || |t ||||j |j |\}}|| |_||st|WdS1s0YdsJdS)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)rxrtF)rrr#rsrr+r,r-r.rrrrrrrrV)ryrqr r3r9rrrzr{r:rxrtr~rrr r8rmrfrrrrrtls1sN=          "r) ryrqr r3r9rrrzr{ connectionr~rtrc  Cstjjstdd|_|} |r2td} |} ntjj| | d} | }| ||s`| ||||} t |\}}| |*}| | d| t|} Wdn1s0Yt}Wdn1s0Ytjj| |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_quicrXidrrrZSyncQuicManagerZconnectr#Z make_streamrZreceiverrrrrrmaxrrV)ryrqr r3r9rrrzr{rr~rtrZmanagerZthe_connectionZ the_managerstartr streamZfinishrrrrrs<2    ,& r)rqzonerdtyperdclassr r3rkeyname relativizer"r9rrserialuse_udp keyalgorithmrc' cst|trtj|}tjj|}tj |||}|tjj krdtj |dddd| }|j ||dur||j|||d|}t||| | \}}} | r|tjj krtd| rtjntj}t||| }t| \}}t|||t|}| rt||d|ntd||}t|||d }d }d }d}|rF|}tjj}nd}|}d} |st|\}}!|!dus|dur|!|kr|}!| rt|d |!\}}n&t|d |!}"t d|"\}t|||!}|tjj k}#tjj!||j"|j#d || d |#d }$|$$}%|%tj$j%krt&|%|$j'} d}&|dur|$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|$VqRWdn1s0YdS)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_ctxZmultirzz No answer or RRset not for qnamezfirst RRset is not an SOArizanswers after final SOAzIXFR base serial mismatch missing TSIG)2rYrr nameZ from_text rdatatype RdataTypeZmaker make_queryIXFRrrsetZ authorityr&Zuse_tsigrrsrpr,rr-r+r#r.rrrpackremptyrrrrrrrcodeZNOERROR TransferErrorrZanswerr FormErrorrrcopyrZSerialAXFRhad_tsig)'rqrrrr r3rrrr"r9rrrrrryrrr8rm sock_typerfr6r rrdoneZ delete_modeZ expecting_SOAZ soa_rrsetrZonamer mexpirationris_ixfrrrZ 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" rrirN)r@rArBrUNEVERZ TRY_FIRSTONLYrrrrrsr) rq txn_managerrr3r r"r9rrudp_moderc  Csh|durtj|\}} n tj|} |jdj} | tjjk} |} | } t ||||\}}}t |\}}d}|rdd}| r|t j krtj}d}n tj}d}t|||}t||||rt|| d|n tdt| | }t|||tj|| | |,}d}d}|st |\}}|dus>|durB||krB|}|rZt|d|\}}n&t|d|}td|\}t|||}tjj||j|jd| || | d}z| |}WnDtjj!y|sJ|t j"kr܂d}d}t j }YqYn0|j#}q|s"|jr"|j$s"tj%&d Wdn1s80YWdqr1sX0YqrdS) 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 rrZextract_serial_from_queryZquestionrrrZfrom_wire_originrrsr#rrr,rr-r+r.rrrrrZInboundrrrrrrrZprocess_messageZUseTCPrrrr r)rqr rr3r r"r9rrr rrrrrr8rmr6r ZretryrZis_udprfrZinboundrrrZrwirerrrrrr inbound_xfrs/                r )T)NN)N) NNFFNrFFFN) NrNrFFFFNF) NrNrFFFNNF)N)NFNrF)NrNrFFN) NrNrFFNNNT) NrNrFFNTN)wrUrrenumrrZos.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 HTTPTransportrDrrI ImportErrorrur Z DNSExceptionrSrrVrWrXrrr#rarbhasattrrcr[ZSelectSelectorrgrhrkrorsr+rHrrrfloatintboolrrrbytesrrNameZtsigZKeyrrrrrrrr.rrrMrrNrrZSyncQuicConnectionrrZ rdataclassrZdefault_algorithmrZ RdataClassIntEnumrrZ transactionZTransactionManagerr rrrrs   4    ,       m ^ X  / D    n   Z ;