
    |;i                        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y)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                  b     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_integerc                     t           |i | t          	          _        t             _        t             _        t              _	        t         fd       _        t                _        y)zInitialize a new IPv4 address.c                 .    t        j                         S N)r   r   selfs   L/home/ubuntu/myenv/lib/python3.12/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   argskwargs	__class__s   `  r   r"   zZeroconfIPv4Address.__init__'   b    $)&)GO%	#g3$w5!G/@Ad)r   c                    | j                   S )z5Return the string representation of the IPv4 address.r   r   s    r   r#   zZeroconfIPv4Address.__str__1       yyr   c                    | 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
   returnNoner=   strr=   bool__name__
__module____qualname__	__slots__r"   r#   propertyr$   r%   r&   __classcell__r+   s   @r   r   r   $   N    gI$ # # $ $ ! !r   r   c                  b     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   c                     t           |i | t          	          _        t             _        t             _        t              _	        t         fd       _        t                _        y)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   c                    | j                   S )z5Return the string representation of the IPv6 address.r.   r   s    r   r#   zZeroconfIPv6Address.__str__R   r/   r   c                    | j                   S r1   r2   r   s    r   r$   z!ZeroconfIPv6Address.is_link_localV   r3   r   c                    | j                   S r5   r6   r   s    r   r%   z"ZeroconfIPv6Address.is_unspecified[   r7   r   c                    | j                   S r9   r:   r   s    r   r&   zZeroconfIPv6Address.is_loopback`   r;   r   r<   r?   rA   rC   rJ   s   @r   rM   rM   E   rK   r   rM   i   )maxsizec                    	 t        |       S # t        t        f$ r Y nw xY w	 t        |       S # t        t        f$ r Y yw xY w)zCache IP addresses.N)r   r   r	   rM   )addresss    r   _cached_ip_addressesrW   f   sR    
"7++01 "7++01 s   
 
. A A 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_addressrV   cached_ip_addresses_wrapper)records    r   !get_ip_address_object_from_recordr^   z   s:     {{j V__,V^^V__MM&v~~66r   c           	         t        |       }|;|j                  r/t        dj                  t        |      dt        |      f            S |S )z4Convert the bytes and scope to an IP address object. %)r\   r$   joinr@   )rV   scopebase_addresss      r   r[   r[      sG     /w7LL$>$>*277C4EsCPUJ3W+XYYr   c                t    | j                   dk(  rt        |       }|j                  d      d   S t        |       S )zEReturn the string representation of the address without the scope id.   ra   r   )versionr@   	partition)addraddress_strs     r   str_without_scope_idrk      s7    ||q$i$$S)!,,t9r   )cached_ip_addressesr^   r[   rk   N)rV   zstr | bytes | intr=   0ZeroconfIPv4Address | ZeroconfIPv6Address | None)r]   r   r=   rm   )rV   bytes_rc   int_r=   rm   )ri   z)ZeroconfIPv4Address | ZeroconfIPv6Addressr=   r@   )__doc__
__future__r   	functoolsr   r   	ipaddressr   r   r   r	   typingr
   _dnsr   constr   bytesrn   r'   ro   r   rM   rW   r\   rl   r^   r[   rk   __all__ r   r   <module>rz      s   , # & T T   	
!+ !B!+ !B 35  3 1 7757 5r   