a
    sd_:                     @   sp  d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z
ddlZddlZddlZddlZddlZddlZddlZddlZz(ddlZddlmZ ddlmZ dZW n ey   dZY n0 zddlZW n  ey   G dd dZY n0 ejZG d	d
 d
ejjZG dd dejj Z!G dd dejjZ"G dd dejjZ#dd Z$dd Z%dd Z&dd Z'dd Z(e)edre%a*ne&a*dd Z+dd Z,d d! Z-d"d# Z.dId$d%Z/dJd&d'Z0dKd*d+Z1dLd,d-Z2dMd/d0Z3dNd2d3Z4dOd4d5Z5d6d7 Z6d8d9 Z7dPd:d;Z8dQd<d=Z9d>d? Z:dRd@dAZ;dBdC Z<dSdEdFZ=ej>j?ej@jAdd1ddddddddejBjCfdGdHZDdS )TzTalk to a DNS server.    N)SourceAddressAdapter)HostHeaderSSLAdapterTFc                   @   sB   e Zd ZG dd deZG dd deZG dd dZdd Zd	S )
sslc                   @   s   e Zd ZdS )zssl.WantReadExceptionN__name__
__module____qualname__ r	   r	   +/usr/lib/python3/dist-packages/dns/query.pyWantReadException4   s   r   c                   @   s   e Zd ZdS )zssl.WantWriteExceptionNr   r	   r	   r	   r
   WantWriteException7   s   r   c                   @   s   e Zd ZdS )zssl.SSLSocketNr   r	   r	   r	   r
   	SSLSocket:   s   r   c                 O   s   t dd S )Nzno ssl support)	Exception)selfargskwargsr	   r	   r
   create_default_context=   s    zssl.create_default_contextN)r   r   r   r   r   r   r   r   r	   r	   r	   r
   r   2   s   r   c                   @   s   e Zd ZdZdS )UnexpectedSourcez=A DNS query response came from an unexpected address or port.Nr   r   r   __doc__r	   r	   r	   r
   r   D   s   r   c                   @   s   e Zd ZdZdS )BadResponsez<A DNS query response does not respond to the question asked.Nr   r	   r	   r	   r
   r   H   s   r   c                       s    e Zd ZdZ fddZ  ZS )TransferErrorz.A zone transfer response got a non-zero rcode.c                    s&   dt j| }t | || _d S )NzZone transfer error: %s)dnsrcodeZto_textsuper__init__)r   r   message	__class__r	   r
   r   O   s    zTransferError.__init__)r   r   r   r   r   __classcell__r	   r	   r   r
   r   L   s   r   c                   @   s   e Zd ZdZdS )NoDOHzPDNS over HTTPS (DOH) was requested but the requests module is not
    available.Nr   r	   r	   r	   r
   r    U   s   r    c                 C   s(   t   }| d u r|d fS |||  fS d S N)time)timeoutZnowr	   r	   r
   _compute_timesZ   s    r$   c                 C   sf   d}|r|t jO }|r |t jO }|r.|t jO }t  }|| | |rV||d }n| }t|S )zPoll polling backend.r   i  )selectZPOLLINZPOLLOUTZPOLLERRpollregisterbool)fdreadablewritableerrorr#   Z
event_maskZpollableZ
event_listr	   r	   r
   	_poll_forf   s    


r-   c                 C   sr   g g g   }}}|r| g}|r$| g}|r.| g}|du rLt  |||\}}	}
nt  ||||\}}	}
t|pn|	pn|
S )zSelect polling backend.N)r%   r(   )r)   r*   r+   r,   r#   ZrsetZwsetZxsetZrcountZwcountZxcountr	   r	   r
   _select_for|   s    r.   c              
   C   s   d}|s|d u rd }n|t    }|dkr2tjjz>t| tjrV|rV|  dkrVW dS t| ||||sntjjW n8 t	y } z |j
d tjkr|W Y d }~n
d }~0 0 d}qd S )NFg        r   T)r"   r   	exceptionZTimeout
isinstancer   r   pending_polling_backendOSErrorr   errnoZEINTR)r)   r*   r+   r,   
expirationdoner#   er	   r	   r
   	_wait_for   s     r8   c                 C   s   | a d S r!   )r2   )fnr	   r	   r
   _set_polling_backend   s    r:   r&   c                 C   s   t | ddd| d S )NTFr8   sr5   r	   r	   r
   _wait_for_readable   s    r>   c                 C   s   t | ddd| d S )NFTr;   r<   r	   r	   r
   _wait_for_writable   s    r?   c                 C   sb   z(t j| |d }t j| |d }W n t jjy@   Y dS 0 ||ko`|dd  |dd  kS )Nr   F   )r   inetZ	inet_ptonr/   SyntaxError)afZa1Za2Zn1Zn2r	   r	   r
   _addresses_equal   s    rD   c                 C   s`   |sdS t | ||s<tj|d r@|dd  |dd  kr@dS |rHdS td| d| d S )NTr   r@   Fzgot a response from z instead of )rD   r   rA   Zis_multicastr   )rC   from_addressdestinationignore_unexpectedr	   r	   r
   _matches_destination   s    
rH   c                 C   s   d }d }zt j| }| }W n ty4   |r0 Y n0 |r`t j|}|r\||kr`tdn|}|r|s|tjkrxd}n|tjkrd}ntd|rt j||f|}|rt j||f|}|||fS )Nz5different address families for source and destinationz0.0.0.0z::z3source_port specified but address family is unknown)	r   rA   af_for_addressr   
ValueErrorsocketAF_INETAF_INET6Zlow_level_address_tuple)whereportsourcesource_portZwhere_must_be_addressrC   rF   Zsafr	   r	   r
   _destination_and_source   s2    


rR   c                 C   sh   t | |}z<|d |d ur(|| |r>|j|d|dW S |W S W n tyb   |   Y n0 d S )NF)Zdo_handshake_on_connectserver_hostname)socket_factoryZsetblockingZbindZwrap_socketr   close)rC   typerP   ssl_contextrS   r=   r	   r	   r
   _make_socket  s    



rX     
/dns-queryc                 C   s  t st|  }t||||d\}}}d}ddi}zBtj|}|tjkrZd	|||	}n|tj
krrd	|||	}W nJ ty   |durtj|}|j|d< ||j|}t }n|}Y n0 |durt|}t }|s|tj }|r||| |
r2|dtt|d |j|||||d	}n(t| d
}|j!||||d|id}W d   n1 sp0    Y  |j"dk s|j"dkrtd	||j"|j#tj$j%|j#| j&| j'||d}|j(|_)| *|st+|S )a  Return 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://<IP-address>:<port>/<path>.

    *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*, a ``requests.session.Session``.  If provided, the 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 the
    system's DNS resolver.

    *verify*, a ``str``, containing a path to a certificate file or directory.

    Returns a ``dns.message.Message``.
    FNZacceptzapplication/dns-messagezhttps://{}:{}{}zhttps://[{}]:{}{}ZHost)zcontent-typezcontent-length)headersdatar#   verify   =r   )r[   r#   r]   params   i+  z2{} responded with status code {}
Response body: {}keyringrequest_macone_rr_per_rrsetignore_trailing),have_dohr    to_wirerR   r   rA   rI   rK   rL   formatrM   rJ   urllibparseZurlsplitZhostnamereplacer   r   
contextlib	ExitStackenter_contextrequestsZsessionsZSessionZmountupdatestrlenpostbase64Zurlsafe_b64encoderstripgetZstatus_codeZcontentr   	from_wirerb   rc   elapsedr"   is_responser   )qrN   r#   rO   rP   rQ   rd   re   Zsessionpathrs   Zbootstrap_addressr]   wirerC   rF   Ztransport_adapterr[   Zwhere_afZurlZ	split_urlstackresponserr	   r	   r
   https  sv    -







&
r   c                 C   s<   t |tjjr| }t| | t }| ||}||fS )a  Send 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.
    )r0   r   r   Messagerg   r?   r"   Zsendto)sockwhatrF   r5   	sent_timenr	   r	   r
   send_udp  s    
r       c	                 C   sj   d}	t | | | d\}	}
t| j|
||rq0qt }tjj|	|||||d}|r\||fS |||
fS dS )a~  Read 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``, 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.
    r     )rb   rc   rd   re   raise_on_truncationN)r>   recvfromrH   Zfamilyr"   r   r   rw   )r   rF   r5   rG   rd   rb   rc   re   r   r|   rE   received_timer   r	   r	   r
   receive_udp  s     -

r   5   c                 C   s   |   }t||||\}}}t|\}}t x}|
r<|
}n|t|tj|}t	|||| t
|||||| j| j||		\}}|| |_| |st|W  d   S 1 s0    Y  dS )aL  Return 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.

    Returns a ``dns.message.Message``.
    N)rg   rR   r$   rl   rm   rn   rX   rK   
SOCK_DGRAMr   r   rb   macr"   ry   r   )rz   rN   r#   rO   rP   rQ   rG   rd   re   r   r   r|   rC   rF   
begin_timer5   r}   r=   r   r   r	   r	   r
   udp  s&    )




r   c                 C   sb   z&t | ||||||||d|	}|dfW S  tjjy\   t| ||||||||
	}|df Y S 0 dS )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 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.

    Returns a (``dns.message.Message``, tcp) tuple where tcp is ``True``
    if and only if TCP was used.
    TFN)r   r   r   Z	Truncatedtcp)rz   rN   r#   rO   rP   rQ   rG   rd   re   Zudp_sockZtcp_sockr~   r	   r	   r
   udp_with_fallback  s    .
r   c                 C   s   d}|dkrt | | z| |}W n8 tjy<   Y qY n" tjy\   t| | Y qY n0 |dkrjt|t| }|| }q|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.
    r   r   )r>   Zrecvr   SSLWantReadErrorSSLWantWriteErrorr?   EOFErrorrr   )r   countr5   r=   r   r	   r	   r
   	_net_readQ  s    



r   c                 C   sx   d}t |}||k rtt| | z|| ||d 7 }W q tjyZ   t| | Y qY q tjyp   Y qY q0 qdS )zWrite the specified data to the socket.
    A Timeout exception will be raised if the operation is not completed
    by the expiration time.
    r   N)rr   r?   sendr   r   r>   r   )r   r\   r5   Zcurrentlr	   r	   r
   
_net_writeh  s    

r   c                 C   sX   t |tjjr| }t|}td|| }t| | t		 }t
| || t||fS )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.
    !H)r0   r   r   r   rg   rr   structpackr?   r"   r   )r   r   r5   r   tcpmsgr   r	   r	   r
   send_tcpz  s    
r   c                 C   sL   t | d|}td|\}t | ||}t }	tjj|||||d}
|
|	fS )a  Read 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``, 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   ra   )r   r   unpackr"   r   r   rw   )r   r5   rd   rb   rc   re   ldatar   r|   r   r   r	   r	   r
   receive_tcp  s    r   c                 C   s`   |  |}|dkrd S |tjtjtjfv rDt| | | tjtj	}|dkr\t
|t|d S )Nr   )Z
connect_exr4   ZEINPROGRESSZEWOULDBLOCKZEALREADYr?   Z
getsockoptrK   Z
SOL_SOCKETZSO_ERRORr3   osstrerror)r=   Zaddressr5   errr	   r	   r
   _connect  s    

r   c	                 C   s   |   }	t|\}
}t }|r0|  |}n4t||||\}}}|t|tj	|}t
||| t||	| t|||| j| j|\}}||
 |_| |st|W  d   S 1 s0    Y  dS )a  Return 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 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``.
    N)rg   r$   rl   rm   ZgetpeernamerR   rn   rX   rK   SOCK_STREAMr   r   r   rb   r   r"   ry   r   )rz   rN   r#   rO   rP   rQ   rd   re   r   r|   r   r5   r}   r=   rC   rF   r   r   r	   r	   r
   r     s,    "




r   c                 C   sP   z|    W d S  tjy,   t| | Y q  tjyH   t| | Y q 0 q d S r!   )Zdo_handshaker   r   r>   r   r?   r<   r	   r	   r
   _tls_handshake  s    r   U  c              
   C   s   |rt | ||||||||	S |  }t|\}}t||||\}}}|	du rf|sft }	|
du rfd|	_t|tj	||	|
dh}t
||| t|| t||| t|||| j| j|\}}|| |_| |st|W  d   S 1 s0    Y  dS )a:  Return 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.

    Returns a ``dns.message.Message``.

    NF)rW   rS   )r   rg   r$   rR   r   r   Zcheck_hostnamerX   rK   r   r   r   r   r   rb   r   r"   ry   r   )rz   rN   r#   rO   rP   rQ   rd   re   r   rW   rS   r|   r   r5   rC   rF   r=   r   r   r	   r	   r
   tls
  s6    -




r   c           (      c   s  t |trtj|}tjj|}tj	|||}|tjj
krdtj|dddd| }|j| |dur||j|||d | }t| ||
|\}}}
|r|tjj
krtd|rtjntj}t|||
}t|	\}}t||| t|}|rt|| || ntd|| }t||| d	}d
}d	}d}|rL|}tjj}nd}|}d} |st|\}}!|!du s|dur|!|kr|}!|rt|| | d\}}"n&t!|d|!}#t"d|#\}t!|||!}|tjj
k}$tjj#||j$|j%d
|| d
|$d}%|%& }&|&tj&j'krt(|&|%j)} d}'|du r|%j*rJ|%j*d j|krVtj+,d|%j*d }|j-tjj.kr|tj+,dd}'|/ }|tjj
krtj01|d j0|krd
}nd
}|%j*|'d D ]}|rtj+,d|j-tjj.krf|j|krf|r |d j0|krtj+,dd	}n|tjj
kr4| }||krx|tjj2ks`|tjj
krx|rxd
}n|rtjj2}d	}q|r|j$r|%j3stj+,d|%V  qXW d   n1 s0    Y  dS )a  Return 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.
    r   INSOAz. . %u 0 0 0 0N)	algorithmzcannot do a UDP AXFRr   FTr   r   )rb   rc   xfrorigintsig_ctxZmultird   z No answer or RRset not for qnamezfirst RRset is not an SOAr@   zanswers after final SOAzIXFR base serial mismatchzmissing TSIG)4r0   rq   r   nameZ	from_text	rdatatypeZ	RdataTypeZmaker   Z
make_queryZIXFRrrsetZ	authorityappendZuse_tsigrg   rR   rJ   rK   r   r   rX   r$   r   rr   r?   r   r   r   r   emptyr>   r   r   r   rw   rb   r   r   ZNOERRORr   r   Zanswerr/   	FormErrorrdtyper   copyserialZSerialAXFRZhad_tsig)(rN   Zzoner   Zrdclassr#   rO   rb   ZkeynameZ
relativizeZlifetimerP   rQ   r   Zuse_udpZkeyalgorithmrz   r   r|   rC   rF   Z	sock_typer=   _r5   r   r   r6   Zdelete_modeZexpecting_SOAZ	soa_rrsetr   Zonamer   ZmexpirationrE   r   Zis_ixfrr   r   Zanswer_indexr	   r	   r
   r   T  s    8










r   )T)NN)NrY   Nr   FFNrZ   TNT)N)NNFFNr   FF)	Nr   Nr   FFFFN)	Nr   Nr   FFFNN)N)NFNr   F)Nr   Nr   FFN)	Nr   Nr   FFNNN)Er   rl   r4   r   r%   rK   r   r"   rt   Zurllib.parseri   Zdns.exceptionr   Zdns.inetZdns.nameZdns.messageZ	dns.rcodeZdns.rdataclassZdns.rdatatypeZ
dns.serialro   Z!requests_toolbelt.adapters.sourcer   Z*requests_toolbelt.adapters.host_header_sslr   rf   ImportErrorr   rT   r/   ZDNSExceptionr   r   r   r   r    r$   r-   r.   r8   r:   hasattrr2   r>   r?   rD   rH   rR   rX   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Z
rdataclassr   ZtsigZdefault_algorithmr   r	   r	   r	   r
   <module>   s   
	 
+
    
q
    
>   
<    
8
  
$  
<   
J
