§
    (U e´  ã                  ó˜   — d Z ddlmZ ddlZddlZddlZddlmZmZ ej        rddl	m
Z
 dZ G d„ d	e¦  «        Z	 ddd„Zd d„Z	 d!d"d„ZdS )#zHThe match_hostname() function from Python 3.5, essential when using SSL.é    )ÚannotationsN)ÚIPv4AddressÚIPv6Addressé   )Ú_TYPE_PEER_CERT_RET_DICTz3.5.0.1c                  ó   — e Zd ZdS )ÚCertificateErrorN)Ú__name__Ú
__module__Ú__qualname__© ó    úc/var/www/dev/btcams2023/python_venv/lib/python3.11/site-packages/urllib3/util/ssl_match_hostname.pyr	   r	      s   € € € € € Ø€Dr   r	   Údnú
typing.AnyÚhostnameÚstrÚmax_wildcardsÚintÚreturnútyping.Match[str] | None | boolc                ó†  — g }| sdS |                       d¦  «        }|d         }|dd…         }|                     d¦  «        }||k    rt          dt          | ¦  «        z   ¦  «        ‚|s7t	          |                      ¦   «         |                     ¦   «         k    ¦  «        S |dk    r|                     d¦  «         n�|                     d	¦  «        s|                     d	¦  «        r(|                     t          j	        |¦  «        ¦  «         n;|                     t          j	        |¦  «         
                    d
d¦  «        ¦  «         |D ])}|                     t          j	        |¦  «        ¦  «         Œ*t          j        dd                     |¦  «        z   dz   t          j        ¦  «        }	|	                     |¦  «        S )zhMatching according to RFC 6125, section 6.4.3

    http://tools.ietf.org/html/rfc6125#section-6.4.3
    Fú.r   r   NÚ*z,too many wildcards in certificate DNS name: z[^.]+zxn--z\*z[^.]*z\Az\.z\Z)ÚsplitÚcountr	   ÚreprÚboolÚlowerÚappendÚ
startswithÚreÚescapeÚreplaceÚcompileÚjoinÚ
IGNORECASEÚmatch)
r   r   r   ÚpatsÚpartsÚleftmostÚ	remainderÚ	wildcardsÚfragÚpats
             r   Ú_dnsname_matchr0      s±  € ð €DØð Øˆuð �HŠH�T‰NŒN€EØ�QŒx€HØ�a�b�b”	€Ià—’˜sÑ#Ô#€IØ�=Ò Ð õ
 Ø:½TÀ"¹X¼XÑEñ
ô 
ð 	
ð
 ð 4Ý�B—H’H‘J”J (§.¢.Ñ"2Ô"2Ò2Ñ3Ô3Ð3ð
 �3‚€ð 	�Š�GÑÔÐÐØ	×	Ò	˜VÑ	$Ô	$ð A¨×(;Ò(;¸FÑ(CÔ(Cð Að
 	�Š•B”I˜hÑ'Ô'Ñ(Ô(Ð(Ð(ð 	�Š•B”I˜hÑ'Ô'×/Ò/°°wÑ?Ô?Ñ@Ô@Ð@ð ð %ð %ˆØ�Š•B”I˜d‘O”OÑ$Ô$Ð$Ð$å
Œ*�U˜UŸZšZ¨Ñ-Ô-Ñ-°Ñ5µr´}Ñ
EÔ
E€CØ�9Š9�XÑÔÐr   ÚipnameÚhost_ipúIPv4Address | IPv6Addressr   c                óˆ   — t          j        |                      ¦   «         ¦  «        }t          |j        |j        k    ¦  «        S )a…  Exact matching of IP addresses.

    RFC 9110 section 4.3.5: "A reference identity of IP-ID contains the decoded
    bytes of the IP address. An IP version 4 address is 4 octets, and an IP
    version 6 address is 16 octets. [...] A reference identity of type IP-ID
    matches if the address is identical to an iPAddress value of the
    subjectAltName extension of the certificate."
    )Ú	ipaddressÚ
ip_addressÚrstripr   Úpacked)r1   r2   Úips      r   Ú_ipaddress_matchr:   P   s3   € õ 
Ô	˜fŸmšm™oœoÑ	.Ô	.€BÝ�”	˜Wœ^Ò+Ñ,Ô,Ð,r   FÚcertú_TYPE_PEER_CERT_RET_DICT | NoneÚhostname_checks_common_nameÚNonec                ó   — | st          d¦  «        ‚	 d|v r0t          j        |d|                     d¦  «        …         ¦  «        }nt          j        |¦  «        }n# t           $ r d}Y nw xY wg }|                      dd¦  «        }|D ]f\  }}|dk    r+|€t          ||¦  «        r dS |                     |¦  «         Œ6|dk    r*|�t          ||¦  «        r dS |                     |¦  «         Œg|rT|€R|sP|                      dd¦  «        D ]9}|D ]4\  }}|d	k    r)t          ||¦  «        r  dS |                     |¦  «         Œ5Œ:t          |¦  «        d
k    r;t          d|›dd 
                    t          t          |¦  «        ¦  «        ›�¦  «        ‚t          |¦  «        d
k    rt          d|›d|d         ›�¦  «        ‚t          d¦  «        ‚)a)  Verify that *cert* (in decoded format as returned by
    SSLSocket.getpeercert()) matches the *hostname*.  RFC 2818 and RFC 6125
    rules are followed, but IP addresses are not accepted for *hostname*.

    CertificateError is raised on failure. On success, the function
    returns nothing.
    ztempty or no certificate, match_hostname needs a SSL socket or SSL context with either CERT_OPTIONAL or CERT_REQUIREDú%NÚsubjectAltNamer   ÚDNSz
IP AddressÚsubjectÚ
commonNamer   z	hostname z doesn't match either of z, z doesn't match r   z/no appropriate subjectAltName fields were found)Ú
ValueErrorr5   r6   ÚrfindÚgetr0   r    r:   Úlenr	   r&   Úmapr   )	r;   r   r=   r2   ÚdnsnamesÚsanÚkeyÚvalueÚsubs	            r   Úmatch_hostnamerO   _   sI  € ð ð 
Ýð-ñ
ô 
ð 	
ð
ð �(ˆ?ˆ?ÝÔ*¨8Ð4I°h·n²nÀSÑ6IÔ6IÐ4IÔ+JÑKÔKˆGˆGåÔ*¨8Ñ4Ô4ˆGøøåð ð ð àˆˆˆðøøøð €HØ'+§x¢xÐ0@À"Ñ'EÔ'E€Cð ð #ð #‰
ˆˆUØ�%Š<ˆ<Øˆ¥>°%¸Ñ#BÔ#BˆØ��Ø�OŠO˜EÑ"Ô"Ð"Ð"Ø�LÒ Ð ØÐ"Õ'7¸¸wÑ'GÔ'GÐ"Ø��Ø�OŠO˜EÑ"Ô"Ð"øð #ð + w ¸x Ø—8’8˜I rÑ*Ô*ð 	+ð 	+ˆCØ!ð +ð +‘
��UØ˜,Ò&Ð&Ý% e¨XÑ6Ô6ð Ø˜˜˜Ø—O’O EÑ*Ô*Ð*øð	+õ ˆ8�}„}�qÒÐÝÐà,4¨H¨H°d·i²iÅÅDÈ(Ñ@SÔ@SÑ6TÔ6TÐ6TðVñ
ô 
ð 	
õ 
ˆX‰Œ˜!Ò	Ð	ÝÐU¨8ÐUÐUÀhÈqÄkÐUÐUÑVÔVÐVåÐPÑQÔQÐQs   “AA ÁA+Á*A+)r   )r   r   r   r   r   r   r   r   )r1   r   r2   r3   r   r   )F)r;   r<   r   r   r=   r   r   r>   )Ú__doc__Ú
__future__r   r5   r"   Útypingr   r   ÚTYPE_CHECKINGÚssl_r   Ú__version__rE   r	   r0   r:   rO   r   r   r   ú<module>rV      s
  ðØ NÐ Nð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø 	€	€	€	Ø €€€Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .à	Ôð /Ø.Ð.Ð.Ð.Ð.Ð.à€ð	ð 	ð 	ð 	ð 	�zñ 	ô 	ð 	ð
 9:ð5ð 5ð 5ð 5ð 5ðp-ð -ð -ð -ð$ ).ð@Rð @Rð @Rð @Rð @Rð @Rð @Rr   