
    8j                        d Z ddlmZ ddlmZmZ ddlmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZ eZeZ G d	 d
e          Z G d de	          Z ed          d!d            ZeZeZd"dZd#dZd$dZdZd S )%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
    )annotations)cache	lru_cache)AddressValueErrorIPv4AddressIPv6AddressNetmaskValueError)Any   )
DNSAddress)
_TYPE_AAAAc                  t     e Zd ZdZd fdZdd	Zedd            Zedd            Zedd            Z	 xZ
S )ZeroconfIPv4Address__hash___is_link_local_is_loopback_is_unspecified_str
zc_integerargsr
   kwargsreturnNonec                l     t                      j        |i | t                                                       _        t                      j         _        t                      j         _        t                      j         _	        t           fd           _        t                      _        dS )zInitialize a new IPv4 address.c                 ,    t          j                   S N)r   r   selfs   O/home/user/adhan/venv/lib/python3.11/site-packages/zeroconf/_utils/ipaddress.py<lambda>z.ZeroconfIPv4Address.__init__.<locals>.<lambda>.       k&:4&@&@     Nsuper__init____str__r   is_link_localr   is_unspecifiedr   is_loopbackr   r   r   intr   r   r   r   	__class__s   `  r    r&   zZeroconfIPv4Address.__init__'       $)&)))GGOO%%	#gg3$ww5!GG/@@@@AAd))r#   strc                    | j         S )z5Return the string representation of the IPv4 address.r   r   s    r    r'   zZeroconfIPv4Address.__str__1   
    yr#   boolc                    | j         S z,Return True if this is a link-local address.r   r   s    r    r(   z!ZeroconfIPv4Address.is_link_local5        ""r#   c                    | j         S z.Return True if this is an unspecified address.r   r   s    r    r)   z"ZeroconfIPv4Address.is_unspecified:        ##r#   c                    | j         S z#Return True if this is a loop back.r   r   s    r    r*   zZeroconfIPv4Address.is_loopback?          r#   r   r
   r   r
   r   r   r   r/   r   r3   __name__
__module____qualname__	__slots__r&   r'   propertyr(   r)   r*   __classcell__r-   s   @r    r   r   $           gI$ $ $ $ $ $    # # # X# $ $ $ X$ ! ! ! X! ! ! ! !r#   r   c                  t     e Zd ZdZd fdZdd	Zedd            Zedd            Zedd            Z	 xZ
S )ZeroconfIPv6Addressr   r   r
   r   r   r   c                l     t                      j        |i | t                                                       _        t                      j         _        t                      j         _        t                      j         _	        t           fd           _        t                      _        dS )zInitialize a new IPv6 address.c                 ,    t          j                   S r   )r   r   r   s   r    r!   z.ZeroconfIPv6Address.__init__.<locals>.<lambda>O   r"   r#   Nr$   r,   s   `  r    r&   zZeroconfIPv6Address.__init__H   r.   r#   r/   c                    | j         S )z5Return the string representation of the IPv6 address.r1   r   s    r    r'   zZeroconfIPv6Address.__str__R   r2   r#   r3   c                    | j         S r5   r6   r   s    r    r(   z!ZeroconfIPv6Address.is_link_localV   r7   r#   c                    | j         S r9   r:   r   s    r    r)   z"ZeroconfIPv6Address.is_unspecified[   r;   r#   c                    | j         S r=   r>   r   s    r    r*   zZeroconfIPv6Address.is_loopback`   r?   r#   r@   rA   rB   rC   rJ   s   @r    rM   rM   E   rK   r#   rM   i   )maxsizeaddressstr | bytes | intr   0ZeroconfIPv4Address | ZeroconfIPv6Address | Nonec                    	 t          |           S # t          t          f$ r Y nw xY w	 t          |           S # t          t          f$ r Y dS w xY w)zCache IP addresses.N)r   r   r	   rM   )rU   s    r    _cached_ip_addressesrY   f   sv    
"7+++01   "7+++01   tts    %%8 AArecordr   c                    | j         t          k    r!| j        rt          | j        | j                  S t          | j                  S )z*Get the IP address object from the record.)typer   scope_idip_bytes_and_scope_to_addressrU   cached_ip_addresses_wrapper)rZ   s    r    !get_ip_address_object_from_recordr`   z   s<     {j  V_ ,V^V_MMM&v~666r#   bytes_scopeint_c           	         t          |           }|F|j        r?t          d                    t          |          dt          |          f                    S |S )z4Convert the bytes and scope to an IP address object.N %)r_   r(   joinr/   )rU   rb   base_addresss      r    r^   r^      sU     /w77LL$>*277C4E4EsCPUJJ3W+X+XYYYr#   addr)ZeroconfIPv4Address | ZeroconfIPv6Addressr/   c                    | j         dk    r*t          |           }|                    d          d         S t          |           S )zEReturn the string representation of the address without the scope id.   rf   r   )versionr/   	partition)ri   address_strs     r    str_without_scope_idrp      s?    |q$ii$$S))!,,t99r#   )cached_ip_addressesr`   r^   rp   N)rU   rV   r   rW   )rZ   r   r   rW   )rU   ra   rb   rc   r   rW   )ri   rj   r   r/   )__doc__
__future__r   	functoolsr   r   	ipaddressr   r   r   r	   typingr
   _dnsr   constr   bytesra   r+   rc   r   rM   rY   r_   rq   r`   r^   rp   __all__ r#   r    <module>r|      sx   , # " " " " " & & & & & & & & T T T T T T T T T T T T                  	
! ! ! ! !+ ! ! !B! ! ! ! !+ ! ! !B 3    3 1 7 7 7 7      r#   