
    %e                        U d dl Z d dlmZ d dlmZ d dlmZ d dlmZ  ee	          Z
dZeed<   dZeed	<   daee         ed
<   daee         ed<   dee         fdZdee         fdZddededee         fdZdee         defdZdS )    N)Optional)Final)util)
get_loggerzhttp://checkip.amazonaws.com_AWS_CHECK_IPzhttps://checkip.amazonaws.com_AWS_CHECK_IP_HTTPS_external_ip_internal_ipreturnc                      t           t           S t          t          d          } | t          t          d          } t	          |           r| a n't
                              dt          j                   da t           S )zGet the *external* IP address of the current machine.

    Returns
    -------
    string
        The external IPv4 address of the current machine.

    N   timeoutzEDid not auto detect external IP.
Please go to %s for debugging hints.)	r	   _make_blocking_http_getr   r   _looks_like_an_ip_adressLOGGERwarningr   HELP_DOC)responses    2lib/python3.11/site-packages/streamlit/net_util.pyget_external_ipr   !   s     &}a@@@H*+>JJJ)) 
3 M	
 	
 	
     c                  4   t           t           S t          j        t          j        t          j                  5 } 	 |                     d           |                                 d         a n# t          $ r da Y nw xY wddd           n# 1 swxY w Y   t           S )zGet the *local* IP address of the current machine.

    From: https://stackoverflow.com/a/28950776

    Returns
    -------
    string
        The local IPv4 address of the current machine.

    N)z8.8.8.8   r   z	127.0.0.1)r
   socketAF_INET
SOCK_DGRAMconnectgetsockname	Exception)ss    r   get_internal_ipr"   C   s     	v~v'8	9	9 'Q	'IIn%%%==??1-LL 	' 	' 	'&LLL	'' ' ' ' ' ' ' ' ' ' ' ' ' ' ' s4   B/A*)B*A96B8A99BBBr   urlr   c                     dd l }	 |                    | |          j        }t          |t                    r|                                }|S # t          $ r Y d S w xY w)Nr   r   )requestsgettext
isinstancestrstripr    )r#   r   r%   r'   s       r   r   r   ^   sn    OOO||C|116dC   	 ::<<D   tts   AA 
AAaddressc                     | dS 	 t          j        t           j        |            dS # t          t          f$ r Y nw xY w	 t          j        t           j        |            dS # t          t          f$ r Y nw xY wdS )NFT)r   	inet_ptonr   AttributeErrorOSErrorAF_INET6)r+   s    r   r   r   j   s    u111tG$   '222tG$    5s   ' ;;A   A43A4)r   )r   typingr   typing_extensionsr   	streamlitr   streamlit.loggerr   __name__r   r   __annotations__r   r	   r)   r
   r   r"   floatr   boolr    r   r   <module>r:      sU          # # # # # #       ' ' ' ' ' '	H		 6u 5 5 5< U < < <"hsm " " ""hsm " " "#    D#    6	 	 	u 	Xc] 	 	 	 	hsm       r   