
    g                        U d dl mZ d dlmZ d dlmZ  ee      Zded<   dZ	ded<   dZ
ded	<   d
Zded<   daded<   daded<   ddZddZdddZddZy)    )annotations)Final)
get_loggerr   _LOGGERzhttp://checkip.amazonaws.com_AWS_CHECK_IPzhttps://checkip.amazonaws.com_AWS_CHECK_IP_HTTPSzhttps://docs.streamlit.io/	_HELP_DOCN
str | None_external_ip_internal_ipc                     t         t         S t        t        d      } | t        t        d      } t	        |       r| a t         S t
        j                  dt               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_adressr   warningr	   )responses    G/var/www/openai/venv/lib/python3.12/site-packages/streamlit/net_util.pyget_external_ipr   "   se     &}a@H*+>J)  	T	
     c                    t         t         S ddl} | j                  | j                  | j                        5 }	 |j	                  d       |j                         d   a ddd       t         S # t        $ r da Y w xY w# 1 sw Y   t         S xY w)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.

    Nr   )z8.8.8.8   z	127.0.0.1)r   socketAF_INET
SOCK_DGRAMconnectgetsockname	Exception)r   ss     r   get_internal_ipr!   A   s     	v~~v'8'8	9Q	'IIn%==?1-L	 
:   	'&L	' 
: s(   A<$A++A96A<8A99A<<B
c                    dd l }	 |j                  | |      j                  }t        |t              r|j                         }|S # t        $ r Y y w xY w)Nr   r   )requestsgettext
isinstancestrstripr   )urlr   r#   r%   s       r   r   r   ^   sN    ||C|166dC ::<D s   >A 	AAc                    | ydd l }	 |j                  |j                  |        y# t        t        f$ r Y nw xY w	 |j                  |j
                  |        y# t        t        f$ r Y yw xY w)NFr   T)r   	inet_ptonr   AttributeErrorOSErrorAF_INET6)addressr   s     r   r   r   j   sx    1G$ '2G$  	s   & 88A A+*A+)returnr
   )r   )r)   r'   r   floatr0   r
   )r/   r
   r0   bool)
__future__r   typingr   streamlit.loggerr   __name__r   __annotations__r   r   r	   r   r   r   r!   r   r    r   r   <module>r9      sj    #  'H% % 6u 5< U < 0	5 /j j >:	r   