
    |;i<Q                       d Z ddlmZ ddlZddlZddlmZmZmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZmZmZmZmZ dZd
ZdZeez   ez   ez   Zed
z  ZdZdZdZeZeZ erddl!m"Z" ddl#m$Z$ ejJ                   G d dejL                               Z' G d d      Z( G d de(      Z) G d de(      Z* G d de*      Z+ G d de*      Z, G d de*      Z- G d d e*      Z. G d! d"e*      Z/ G d# d$e*      Z0e*Z1 G d% d&      Z2y)'a  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
    )annotationsN)TYPE_CHECKINGAnycast   AbstractMethodException)_is_v6_address)current_time_millis)_CLASS_MASK_CLASS_UNIQUE_CLASSES	_TYPE_ANY_TYPES      i  i     )DNSIncoming)DNSOutgoingc                      e Zd ZdZdZdZy)DNSQuestionTypezAn MDNS question type.

    "QU" - questions requesting unicast responses
    "QM" - questions requesting multicast responses
    https://datatracker.ietf.org/doc/html/rfc6762#section-5.4
    r   r   N)__name__
__module____qualname____doc__QUQM     @/home/ubuntu/myenv/lib/python3.12/site-packages/zeroconf/_dns.pyr   r   5   s     
B	
Br   r   c                  `    e Zd ZdZdZddZddZddZddZe	dd       Z
e	dd       Zdd	Zy
)DNSEntryzA DNS entry)class_keynametypeuniquec                *    | j                  |||       y N)_fast_init_entryselfr%   type_r#   s       r    __init__zDNSEntry.__init__G   s    dE62r   c                    || _         |j                         | _        || _        |t        z  | _        |t        z  dk7  | _        y)Fast init for reuse.r   N)r%   lowerr$   r&   r   r#   r   r'   r+   s       r    r*   zDNSEntry._fast_init_entryJ   s:    	::<	{*-!3r   c                    | j                   |j                   k(  xr4 | j                  |j                  k(  xr | j                  |j                  k(  S r)   )r$   r&   r#   r,   others     r    _dns_entry_matcheszDNSEntry._dns_entry_matchesR   s<    xx599$`ejj)@`T[[TYT`T`E``r   c                H    t        |t              xr | j                  |      S )z6Equality test on key (lowercase name), type, and class)
isinstancer"   r5   r3   s     r    __eq__zDNSEntry.__eq__U   s    %*Mt/F/Fu/MMr   c                6    t        j                  | d|  d      S )zClass accessor?())r   get)r#   s    r    
get_class_zDNSEntry.get_class_Y   s     ||FbN33r   c                6    t        j                  | d|  d      S )zType accessorr:   r;   )r   r<   )ts    r    get_typezDNSEntry.get_type^   s     zz!r!AY''r   c                    dj                  || j                  | j                        | j                  | j                        | j
                  rdnd| j                  |dt        t        |             S d      S )1String representation with additional informationz{}[{},{}{},{}]{}z-unique =)	formatr@   r&   r=   r#   r'   r%   r   r   )r,   hdrr4   s      r    entry_to_stringzDNSEntry.entry_to_stringc   sq    !((MM$))$OODKK(I"II&+&7aS% !"
 	
 >@
 	
r   Nr%   strr-   intr#   rJ   returnNoner%   rI   r-   _intr#   rN   rK   rL   )r4   r"   rK   boolr4   r   rK   rO   )r#   rJ   rK   rI   )r?   rJ   rK   rI   )rF   rI   r4   zbytes | str | NonerK   rI   )r   r   r   r   	__slots__r.   r*   r5   r8   staticmethodr=   r@   rG   r   r   r    r"   r"   B   sM    ;I34aN 4 4 ( (	
r   r"   c                      e Zd ZdZdZddZddZddZddZddZ	e
dd       Ze
dd	       Zej                  dd
       ZddZy)DNSQuestionzA DNS question entry_hashc                *    | j                  |||       y r)   )
_fast_initr+   s       r    r.   zDNSQuestion.__init__t   s    eV,r   c                x    | j                  |||       t        | j                  || j                  f      | _        yr0   N)r*   hashr$   r#   rV   r+   s       r    rX   zDNSQuestion._fast_initw   s/    dE62488UDKK89
r   c                    | j                   |j                   k(  xr9 | j                  |j                  t        fv xr | j                  |j                  k(  S )z6Returns true if the question is answered by the record)r#   r&   r   r%   )r,   recs     r    answered_byzDNSQuestion.answered_by|   sD    {{cjj(iTYY388Y:O-OiTXT]T]adaiaiTiir   c                    | j                   S r)   rU   r,   s    r    __hash__zDNSQuestion.__hash__   s    zzr   c                H    t        |t              xr | j                  |      S )zTests equality on dns question.)r7   rT   r5   r3   s     r    r8   zDNSQuestion.__eq__   s    %-P$2I2I%2PPr   c                t    t        | j                  j                  d            t        z   t        z   t        z   S )z+Maximum size of the question in the packet.utf-8)lenr%   encode	_LEN_BYTE
_LEN_SHORTr`   s    r    max_sizezDNSQuestion.max_size   s-     499##G,-	9JFSSr   c                    | j                   S )zzReturns true if the QU (not QM) is set.

        unique shares the same mask as the one
        used for unicast.
        r'   r`   s    r    unicastzDNSQuestion.unicast   s     {{r   c                    || _         y)zSets the QU bit (not QM).Nrk   )r,   values     r    rl   zDNSQuestion.unicast   s     r   c                    dj                  | j                  | j                        | j                  rdnd| j	                  | j
                        | j                        S )String representationz{}[question,{},{},{}]r   r   )rE   r@   r&   rl   r=   r#   r%   r`   s    r    __repr__zDNSQuestion.__repr__   sG    &--MM$))$LLDdOODKK(II	
 	
r   NrH   rM   )r]   	DNSRecordrK   rO   rK   rJ   rP   )rK   rO   )rn   rO   rK   rL   rK   rI   )r   r   r   r   rQ   r.   rX   r^   ra   r8   propertyri   rl   setterrq   r   r   r    rT   rT   o   sl    I-:
jQ T T   ^^ 
r   rT   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZddZ	dd	Z
dd
ZddZddZddZddZddZddZddZy)rr   z.A DNS record - like a DNS entry, but has a TTLcreatedttlNc                F    | j                  |||||xs
 t                      y r)   )_fast_init_recordr   r,   r%   r-   r#   rz   ry   s         r    r.   zDNSRecord.__init__   s#     	tUFC9YDWDYZr   c                F    | j                  |||       || _        || _        yrZ   )r*   rz   ry   r}   s         r    r|   zDNSRecord._fast_init_record   s"    dE62r   c                    t         zAbstract methodr   r3   s     r    r8   zDNSRecord.__eq__       %%r   c                4    | j                   |j                   k  S r)   rz   r3   s     r    __lt__zDNSRecord.__lt__   s    xx%))##r   c                X    |j                         }|D ]  }| j                  |      s y y)zdReturns true if any answer in a message can suffice for the
        information held in this record.TF)answers_suppressed_by_answer)r,   msgr   records       r    suppressed_byzDNSRecord.suppressed_by   s4     ++- 	F))&1	 r   c                H    | |k(  xr |j                   | j                   dz  kD  S )zwReturns true if another record has same name, type and class,
        and if its TTL is at least half of this record's.r   r   r3   s     r    r   zDNSRecord._suppressed_by_answer   s$     u};dhhl!;;r   c                @    | j                   || j                  z  dz  z   S )zXReturns the time at which this record will have expired
        by a certain percentage.
   rx   )r,   percents     r    get_expiration_timezDNSRecord.get_expiration_time   s!     ||w1B677r   c                `    | j                   t        | j                  z  z   |z
  dz  }|dk  rdS |S )z%Returns the remaining TTL in seconds.g     @@r   ry   _EXPIRE_FULL_TIME_MSrz   )r,   nowremains      r    get_remaining_ttlzDNSRecord.get_remaining_ttl   s5    ,,"6"ABSHFRQJq*F*r   c                H    | j                   t        | j                  z  z   |k  S )z(Returns true if this record has expired.r   r,   r   s     r    
is_expiredzDNSRecord.is_expired   s     ||3dhh>?3FFr   c                H    | j                   t        | j                  z  z   |k  S )z9Returns true if this record is at least half way expired.)ry   _EXPIRE_STALE_TIME_MSrz   r   s     r    is_stalezDNSRecord.is_stale   s     ||4txx?@CGGr   c                H    | j                   t        | j                  z  z   |kD  S )zFReturns true if the record more than one quarter of its TTL remaining.)ry   _RECENT_TIME_MSrz   r   s     r    	is_recentzDNSRecord.is_recent   s    ||9:S@@r   c                     || _         || _        y)z$Set the created and ttl of a record.Nrx   )r,   ry   rz   s      r    _set_created_ttlzDNSRecord._set_created_ttl   s     r   c                    t         r   r   r,   outs     r    writezDNSRecord.write   r   r   c                    | j                    dt        | j                  t                            dt	        t
        |       }t        j                  | d|      S )rB   /,r   )rz   rJ   r   r   r   r   r"   rG   )r,   r4   args      r    	to_stringzDNSRecord.to_string   sQ    
!C 6 67J7L MNOqQUVY[`QaPbc''h<<r   r)   )r%   rI   r-   rJ   r#   rJ   rz   rN   ry   float | NonerK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   ry   _floatrK   rL   rP   )r4   rr   rK   rO   )r   r   rK   rO   )r   rN   rK   float)r   r   rK   zint | float)r   r   rK   rO   )ry   r   rz   rN   rK   rL   r   r   rK   rL   )r4   zbytes | strrK   rI   )r   r   r   r   rQ   r.   r|   r8   r   r   r   r   r   r   r   r   r   r   r   r   r   r    rr   rr      s    8"I !%[[ [ 	[
 [ [ 
[&$<
8+
GHA&=r   rr   c                      e Zd ZdZdZ	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZ	dd	Z
dd
Zy)
DNSAddresszA DNS address record)rV   addressscope_idNc           
     J    | j                  |||||||xs
 t                      y r)   rX   r   r,   r%   r-   r#   rz   r   r   ry   s           r    r.   zDNSAddress.__init__   s%     	eVS'8WEePcPefr   c                    | j                  |||||       || _        || _        t        | j                  || j
                  ||f      | _        yrZ   )r|   r   r   r[   r$   r#   rV   r   s           r    rX   zDNSAddress._fast_init  sG     	tUFCA 488UDKK(KL
r   c                :    |j                  | j                         y'Used in constructing an outgoing packetN)write_stringr   r   s     r    r   zDNSAddress.write  s    &r   c                H    t        |t              xr | j                  |      S )zTests equality on address)r7   r   _eqr3   s     r    r8   zDNSAddress.__eq__      %,@%@r   c                    | j                   |j                   k(  xr, | j                  |j                  k(  xr | j                  |      S r)   )r   r   r5   r3   s     r    r   zDNSAddress._eq  s?    LLEMM) ///''.	
r   c                    | j                   S )z"Hash to compare like DNSAddresses.rU   r`   s    r    ra   zDNSAddress.__hash__&      zzr   c                :   	 | j                  t        j                  t        | j                        rt        j
                  nt        j                  | j                              S # t        t        f$ r' | j                  t        | j                              cY S w xY wrp   )
r   socket	inet_ntopr
   r   AF_INET6AF_INET
ValueErrorOSErrorrI   r`   s    r    rq   zDNSAddress.__repr__*  ss    	5>>  '5dll'CFOOLL  G$ 	5>>#dll"344	5s   A!A$ $3BB)NN)r%   rI   r-   rJ   r#   rJ   rz   rJ   r   bytesr   z
int | Nonery   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r   r   r   z_int | Nonery   r   rK   rL   r   rP   )r4   r   rK   rO   rs   rt   r   r   r   r   rQ   r.   rX   r   r8   r   ra   rq   r   r   r    r   r      s    0I  $ $
g
g 
g 	
g
 
g 
g 
g 
g 

gMM M 	M
 M M M M 
M 'A

5r   r   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZ	dd	Z
dd
Zy)DNSHinfozA DNS host information record)rV   cpuosNc           
     J    | j                  |||||||xs
 t                      y r)   r   r,   r%   r-   r#   rz   r   r   ry   s           r    r.   zDNSHinfo.__init__<  s%     	eVS#r7;[FYF[\r   c                    | j                  |||||       || _        || _        t        | j                  || j
                  ||f      | _        yrZ   )r|   r   r   r[   r$   r#   rV   r   s           r    rX   zDNSHinfo._fast_initH  sG     	tUFCA488UDKKbAB
r   c                    |j                  | j                  j                  d             |j                  | j                  j                  d             y)r   rd   N)write_character_stringr   rf   r   r   s     r    r   zDNSHinfo.writeQ  s8    ""488??7#;<""477>>'#:;r   c                H    t        |t              xr | j                  |      S zTests equality on cpu and os.)r7   r   r   r3   s     r    r8   zDNSHinfo.__eq__V  s    %*>txx>r   c                    | j                   |j                   k(  xr, | j                  |j                  k(  xr | j                  |      S r   )r   r   r5   r3   s     r    r   zDNSHinfo._eqZ  s8    xx599$_EHH)<_AXAXY^A__r   c                    | j                   S )zHash to compare like DNSHinfo.rU   r`   s    r    ra   zDNSHinfo.__hash__^  r   r   c                X    | j                  | j                  dz   | j                  z         S )rp    )r   r   r   r`   s    r    rq   zDNSHinfo.__repr__b  s"    ~~dhhntww677r   r)   )r%   rI   r-   rJ   r#   rJ   rz   rJ   r   rI   r   rI   ry   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r   rI   r   rI   ry   r   rK   rL   r   rP   )r4   r   rK   rO   rs   rt   r   r   r   r    r   r   7  s    '&I !%
]
] 
] 	
]
 
] 
] 
] 
] 

]CC $C.2C9=CDGCMPC[aC	C<
?`8r   r   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZedd       ZddZ	ddZ
dd	Zdd
ZddZy)
DNSPointerzA DNS pointer record)rV   alias	alias_keyNc           	     H    | j                  ||||||xs
 t                      y r)   r   r,   r%   r-   r#   rz   r   ry   s          r    r.   zDNSPointer.__init__l  s#     	eVS%9YDWDYZr   c                    | j                  |||||       || _        |j                         | _        t	        | j
                  || j                  | j                  f      | _        y r)   )r|   r   r1   r   r[   r$   r#   rV   r   s          r    rX   zDNSPointer._fast_initw  sO     	tUFCA
488UDKKHI
r   c                    t         t        z   t        | j                        t        | j                        z
  z   t        z   S )zOMaximum size of the record in the packet assuming the name has been compressed.)_BASE_MAX_SIZE_NAME_COMPRESSION_MIN_SIZEre   r   r%   r`   s    r    max_size_compressedzDNSPointer.max_size_compressed  s;     ()4::TYY/1 ))	
r   c                :    |j                  | j                         yr   )
write_namer   r   s     r    r   zDNSPointer.write  s    tzz"r   c                H    t        |t              xr | j                  |      S zTests equality on alias.)r7   r   r   r3   s     r    r8   zDNSPointer.__eq__  r   r   c                Z    | j                   |j                   k(  xr | j                  |      S r   )r   r5   r3   s     r    r   zDNSPointer._eq  s%    ~~0ST5L5LU5SSr   c                    | j                   S )z Hash to compare like DNSPointer.rU   r`   s    r    ra   zDNSPointer.__hash__  r   r   c                8    | j                  | j                        S r   )r   r   r`   s    r    rq   zDNSPointer.__repr__  s    ~~djj))r   r)   )r%   rI   r-   rJ   r#   rJ   rz   rJ   r   rI   ry   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r   rI   ry   r   rK   rL   rs   r   rP   )r4   r   rK   rO   rt   )r   r   r   r   rQ   r.   rX   ru   r   r   r8   r   ra   rq   r   r   r    r   r   g  s    /I !%	[	[ 	[ 		[
 	[ 	[ 	[ 
	[JJ $J.2J9=JFIJTZJ	J 
 
#AT*r   r   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZ	dd	Z
dd
Zy)DNSTextzA DNS text record)rV   textNc           	     H    | j                  ||||||xs
 t                      y r)   r   r,   r%   r-   r#   rz   r   ry   s          r    r.   zDNSText.__init__  s#     	eVS$8XCVCXYr   c                    | j                  |||||       || _        t        | j                  || j                  |f      | _        y r)   )r|   r   r[   r$   r#   rV   r   s          r    rX   zDNSText._fast_init  s>     	tUFCA	488UDKK>?
r   c                :    |j                  | j                         yr   )r   r   r   s     r    r   zDNSText.write  s    #r   c                    | j                   S )zHash to compare like DNSText.rU   r`   s    r    ra   zDNSText.__hash__  r   r   c                H    t        |t              xr | j                  |      S zTests equality on text.)r7   r   r   r3   s     r    r8   zDNSText.__eq__      %)=dhhuo=r   c                Z    | j                   |j                   k(  xr | j                  |      S r   )r   r5   r3   s     r    r   zDNSText._eq  s%    yyEJJ&I4+B+B5+IIr   c                    t        | j                        dkD  r!| j                  | j                  dd       dz   S | j                  | j                        S )rp   r   N   z...)re   r   r   r`   s    r    rq   zDNSText.__repr__  sC    tyy>B>>$))BQ-0588~~dii((r   r)   )r%   rI   r-   rJ   r#   rJ   rz   rJ   r   r   ry   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r   r   ry   r   rK   rL   r   rs   rP   )r4   r   rK   rO   rt   )r   r   r   r   rQ   r.   rX   r   ra   r8   r   rq   r   r   r    r   r     s    !I !%	Z	Z 	Z 		Z
 	Z 	Z 	Z 
	Z@@ $@.2@9=@EJ@U[@	@$>J)r   r   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZ	dd	Z
dd
Zy)
DNSServicezA DNS service record)rV   portpriorityserver
server_keyweightNc
                N    | j                  |||||||||	xs
 t               	       y r)   r   
r,   r%   r-   r#   rz   r   r   r   r   ry   s
             r    r.   zDNSService.__init__  s,     	%hfgFfQdQf	
r   c
           	         | j                  |||||	       || _        || _        || _        || _        |j                         | _        t        | j                  || j                  |||| j                  f      | _
        y r)   )r|   r   r   r   r   r1   r   r[   r$   r#   rV   r  s
             r    rX   zDNSService._fast_init  sm     	tUFCA 	 ,,.488UDKK64QUQ`Q`ab
r   c                    |j                  | j                         |j                  | j                         |j                  | j                         |j	                  | j
                         yr   )write_shortr   r   r   r   r   r   s     r    r   zDNSService.write  sB    &$		"t{{#r   c                H    t        |t              xr | j                  |      S )z3Tests equality on priority, weight, port and server)r7   r   r   r3   s     r    r8   zDNSService.__eq__  r   r   c                    | j                   |j                   k(  xrb | j                  |j                  k(  xrG | j                  |j                  k(  xr, | j                  |j                  k(  xr | j	                  |      S )z4Tests equality on priority, weight, port and server.)r   r   r   r   r5   r3   s     r    r   zDNSService._eq   sq     MMU^^+ /u||+/		UZZ'/ 5#3#33/ ''.	
r   c                    | j                   S )z Hash to compare like DNSService.rU   r`   s    r    ra   zDNSService.__hash__
  r   r   c                V    | j                  | j                   d| j                         S )rp   :)r   r   r   r`   s    r    rq   zDNSService.__repr__  s$    ~~Qtyyk:;;r   r)   )r%   rI   r-   rJ   r#   rJ   rz   rJ   r   rJ   r   rJ   r   rJ   r   rI   ry   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r   rN   r   rN   r   rN   r   rI   ry   r   rK   rL   r   rP   )r4   r   rK   rO   rs   rt   r   r   r   r    r   r     s   OI !%

 
 	

 
 
 
 
 
 
 

 cc c 	c
 c c c c c c 
c($A
<r   r   c                      e Zd ZdZdZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZddZddZ	dd	Z
dd
Zy)DNSNseczA DNS NSEC record)rV   	next_namerdtypesNc           
     J    | j                  |||||||xs
 t                      y r)   r   r,   r%   r-   r#   rz   r  r  ry   s           r    r.   zDNSNsec.__init__  s%     	eVS)WgFfQdQfgr   c                    | j                  |||||       || _        t        |      | _        t	        | j
                  || j                  |g| j                        | _        y r)   )r|   r  sortedr  r[   r$   r#   rV   r  s           r    rX   zDNSNsec._fast_init$  sR     	tUFCA"g488UDKKRT\\RS
r   c                   t        d      }d}| j                  D ]3  }|dkD  rt        d| d      |dz  }|dz   }||xx   d|dz  z	  z  cc<   5 |dk(  rt        d	      t        |d|       }|j	                  | j
                         |j                  d       |j                  t        |             |j                  |       y
)z(Used in constructing an outgoing packet.s                                    r      zrdtype z is too large for NSEC   r      z"NSEC must have at least one rdtypeN)		bytearrayr  r   r   r   r  _write_bytere   r   )r,   r   bitmaptotal_octetsrdtypebyte	out_bytess          r    r   zDNSNsec.write3  s    :&ll 	1F| 76(2H!IJJQ;D!8L4LDVaZ00L	1 1 ABB&<01	t~~&I'#r   c                H    t        |t              xr | j                  |      S z(Tests equality on next_name and rdtypes.)r7   r  r   r3   s     r    r8   zDNSNsec.__eq__G  r   r   c                    | j                   |j                   k(  xr, | j                  |j                  k(  xr | j                  |      S r  )r  r  r5   r3   s     r    r   zDNSNsec._eqK  sA     NNeoo- /-/''.	
r   c                    | j                   S )zHash to compare like DNSNSec.rU   r`   s    r    ra   zDNSNsec.__hash__S  r   r   c                    | j                  | j                  dz   dj                  | j                  D cg c]  }| j	                  |       c}      z         S c c}w )rp   r   |)r   r  joinr  r@   )r,   r-   s     r    rq   zDNSNsec.__repr__W  sH    ~~NNS 388t||,\eT]]5-A,\#]]
 	
,\s   Ar)   )r%   rI   r-   rJ   r#   rJ   rz   rN   r  rI   r  z	list[int]ry   r   rK   rL   )r%   rI   r-   rN   r#   rN   rz   rN   r  rI   r  z
list[_int]ry   r   rK   rL   r   rP   )r4   r  rK   rO   rs   rt   r   r   r   r    r  r    s    1I !%
h
h 
h 	
h
 
h 
h 
h 
h 

hTT T 	T
 T T T T 
T$(>

r   r  c                  F    e Zd ZdZdZd	dZed
d       ZddZd
dZ	ddZ
y)DNSRRSetz2A set of dns records with a lookup to get the ttl._lookup_recordsc                     || _         d| _        y)z"Create an RRset from records sets.N)r(  r'  )r,   recordss     r    r.   zDNSRRSet.__init__f  s    :>r   c                "    | j                         S )zReturn the lookup table.)_get_lookupr`   s    r    lookupzDNSRRSet.lookupk  s     !!r   c                4    t        | j                               S )z Return the lookup table as aset.)setr,  r`   s    r    
lookup_setzDNSRRSet.lookup_setp  s    4##%&&r   c                |    | j                    | j                  D ci c]  }|| c}| _         | j                   S c c}w )z/Return the lookup table, building it if needed.r&  )r,   r   s     r    r,  zDNSRRSet._get_lookupt  s6    <<9=GvFFNGDL|| Hs   
9c                    | j                         }|j                  |      }|y|j                  |j                  dz  kD  S )zdReturns true if any answer in the rrset can suffice for the
        information held in this record.Fr   )r,  r<   rz   )r,   r   r-  r4   s       r    
suppresseszDNSRRSet.suppresses{  s?     !!#

6"=yyFJJN++r   N)r*  zlist[DNSRecord]rK   rL   )rK   zdict[DNSRecord, DNSRecord])rK   zset[DNSRecord])r   
_DNSRecordrK   rO   )r   r   r   r   rQ   r.   ru   r-  r0  r,  r3  r   r   r    r%  r%  a  s2    <'I?
 " "',r   r%  )3r   
__future__r   enumr   typingr   r   r   _exceptionsr	   
_utils.netr
   _utils.timer   constr   r   r   r   r   rg   rh   _LEN_INTr   r   r   r   r   r   r   rJ   rN   _protocol.incomingr   _protocol.outgoingr   r'   Enumr   r"   rT   rr   r   r   r   r   r   r  r4  r%  r   r   r    <module>r@     s(  , #   + + 0 & , J J	
j(83j@&]   	
// 	dii 	 	*
 *
Z2
( 2
jO= O=d>5 >5B-8y -8`4* 4*n+)i +)\D< D<NH
i H
V 
!, !,r   