o
    ßý°jt  ã                   @   s   d Z dd„ Zdd„ ZdS )zC Some helper functions for validation of ports and lists of ports. c                 C   s$   t | tƒr| tddƒvrdS dS dS )zh Check if a port is valid. Return an error message indicating what is invalid if something isn't valid. é    éÿÿ  ú)Source port must in range from 0 to 65535úSource port must be an integerN)Ú
isinstanceÚintÚrange)Úport© r	   úŽ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/ldap3/utils/port_validators.pyÚ
check_port   s
   
ÿr   c                 C   s”   | dur
|dur
dS | dur t | tƒr| tddƒvrdS dS dS |durHzt|ƒ}W n ty8   d |¡ Y S w |D ]}t|ƒ}|rG|  S q;dS )zÝ Take in a port and a port list and check that at most one is non-null. Additionally check that if either
    is non-null, it is valid.
    Return an error message indicating what is invalid if something isn't valid.
    Nz8Cannot specify both a source port and a source port listr   r   r   r   z'Source port list must be an iterable {})r   r   r   ÚiterÚ	TypeErrorÚformatr   )r   Ú	port_listÚ_Úcandidate_portÚerrr	   r	   r
   Úcheck_port_and_port_list   s(   
õÿÿr   N)Ú__doc__r   r   r	   r	   r	   r
   Ú<module>   s    
