o
    -˜Žj[  ã                   @   sX   d dl Z d dlZd dlmZmZ ddlmZmZ ddlm	Z	 e 
e¡ZG dd„ dƒZdS )	é    N)ÚOptionalÚTypeé   )ÚTCPÚTCPAbridgedé   )Ú
DataCenterc                   @   s|   e Zd ZdZdefdedededededed	ee	 d
dfdd„Z
ddd„Zddd„Zded
dfdd„Zd
ee fdd„ZdS )Ú
Connectioné   FÚdc_idÚ	test_modeÚipv6Úalt_portÚproxyÚmediaÚprotocol_factoryÚreturnNc                 C   sF   || _ || _|| _|| _|| _|| _|| _t|||||ƒ| _d | _	d S ©N)
r   r   r   r   r   r   r   r   ÚaddressÚprotocol)Úselfr   r   r   r   r   r   r   © r   ú[/var/www/kodo/Anonymous/send/lib/python3.10/site-packages/pyrogram/connection/connection.pyÚ__init__!   s   

zConnection.__init__c                 Ã   sÞ   �t tjƒD ]a}| j| j| jd�| _zt d¡ | j 	| j
¡I d H  W n( tyK } zt d|¡ | j ¡ I d H  t d¡I d H  W Y d }~qd }~ww t d| jrTdnd| j| jr\dnd	| jrbd
nd¡  d S t d¡ t‚)N)r   r   zConnecting...z+Unable to connect due to network issues: %sr   zConnected! %s DC%s%s - IPv%sÚTestÚ
Productionz (media)Ú Ú6Ú4z"Connection failed! Trying again...)Úranger	   ÚMAX_CONNECTION_ATTEMPTSr   r   r   r   ÚlogÚinfoÚconnectr   ÚOSErrorÚwarningÚcloseÚasyncioÚsleepr   r   r   ÚConnectionError)r   Ú_Úer   r   r   r#   6   s*   €
€ýü
zConnection.connectc                 Ã   s    �| j  ¡ I d H  t d¡ d S )NÚDisconnected)r   r&   r!   r"   ©r   r   r   r   r&   L   s   €zConnection.closeÚdatac                 Ã   s   �| j  |¡I d H  d S r   )r   Úsend)r   r.   r   r   r   r/   P   s   €zConnection.sendc                 Ã   s   �| j  ¡ I d H S r   )r   Úrecvr-   r   r   r   r0   S   s   €zConnection.recv)r   N)Ú__name__Ú
__module__Ú__qualname__r    r   ÚintÚboolÚdictr   r   r   r#   r&   Úbytesr/   r   r0   r   r   r   r   r	      s2    	øþýüûúùø	
÷

r	   )r'   ÚloggingÚtypingr   r   Ú	transportr   r   Úsession.internalsr   Ú	getLoggerr1   r!   r	   r   r   r   r   Ú<module>   s   
