o
    ßý°jÝ	  ã                   @   s2   d Z ddlZG dd„ deƒZd
dd„Zdd	„ ZdS )z7 Utilities and constants related to reverse dns lookup é    Nc                   @   s.   e Zd ZdZdZdZdZdZeeeeehZdS )ÚReverseDnsSetting)r   )é   )é   )é   )é   N)	Ú__name__Ú
__module__Ú__qualname__ÚOFFÚREQUIRE_RESOLVE_ALL_ADDRESSESÚ!REQUIRE_RESOLVE_IP_ADDRESSES_ONLYÚOPTIONAL_RESOLVE_ALL_ADDRESSESÚ"OPTIONAL_RESOLVE_IP_ADDRESSES_ONLYÚSUPPORTED_VALUES© r   r   ú‚/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/ldap3/core/rdns.pyr      s    ÿr   Tc              
   C   s>   zt  | ¡d W S  ty } z
|r‚ W Y d}~dS d}~ww )a   Resolve the hostname for an ip address. If success is required, raise an exception if a hostname cannot
    be resolved for the address.
    Returns the hostname resolved for the address.
    If success is not required, returns None for addresses that do not resolve to hostnames.
    r   N)ÚsocketÚgethostbyaddrÚ	Exception)ÚaddrÚsuccess_requiredÚexr   r   r   Úget_hostname_by_addr'   s   
ÿ€ür   c              
   C   sz   t jt jfD ]4}z
t  || ¡ W  dS  ty2   d| v r.tdd„ |  dd¡D ƒƒr.Y  dS Y  dS  ty:   Y qw dS )zbReturns True if an address is an ipv4 address or an ipv6 address based on format. False otherwise.TÚ.c                 S   s   g | ]}|  ¡ ‘qS r   )Úisalpha)Ú.0Úcr   r   r   Ú
<listcomp>=   s    zis_ip_addr.<locals>.<listcomp>Ú F)r   ÚAF_INETÚAF_INET6Ú	inet_ptonÚAttributeErrorÚanyÚreplaceÚOSError)r   Ú	addr_typer   r   r   Ú
is_ip_addr6   s   "ÿr'   )T)Ú__doc__r   Úobjectr   r   r'   r   r   r   r   Ú<module>   s
    

