CasperSecurity

Current Path : /usr/lib/python3.10/__pycache__/
Upload File :
Current File : //usr/lib/python3.10/__pycache__/asyncore.cpython-310.pyc

o

`�wi,O�@sxdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZejdedd�eee
eeeeh�ZzeWneyYiZYnwdd�ZGd	d
�d
e�ZeeefZ dd�Z!d
d�Z"dd�Z#dd�Z$d)dd�Z%d)dd�Z&e&Z'd*dd�Z(Gdd�d�Z)Gdd�de)�Z*d d!�Z+d+d"d#�Z,ej-d$kr�Gd%d&�d&�Z.Gd'd(�d(e)�Z/dSdS),a�Basic infrastructure for asynchronous socket service clients and servers.

There are only two ways to have a program on a single processor do "more
than one thing at a time".  Multi-threaded programming is the simplest and
most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however.

If your operating system supports the select() system call in its I/O
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking
place in the "background."  Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap.
�N)
�EALREADY�EINPROGRESS�EWOULDBLOCK�
ECONNRESET�EINVAL�ENOTCONN�	ESHUTDOWN�EISCONN�EBADF�ECONNABORTED�EPIPE�EAGAIN�	errorcodezlThe asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio�)�
stacklevelc
CsBzt�|�WStttfy |tvrt|YSd|YSw)NzUnknown error %s)�os�strerror�
ValueError�
OverflowError�	NameErrorr)�err�r�/usr/lib/python3.10/asyncore.py�	_strerrorKs�rc@seZdZdS)�ExitNowN)�__name__�
__module__�__qualname__rrrrrSsrcC�2z|��WdSty�|��YdS�N)�handle_read_event�_reraised_exceptions�handle_error��objrrr�readX�r%cCrr)�handle_write_eventr!r"r#rrr�write`r&r(cCrr)�handle_expt_eventr!r"r#rrr�
_exceptionhr&r*c
Cs�z0|tj@r
|��|tj@r|��|tj@r|��|tjtjBtj	B@r.|�
�WdSWdStyX}z|jt
vrB|��n|�
�WYd}~dSWYd}~dSd}~wty_�|��YdSr)�select�POLLINr �POLLOUTr'�POLLPRIr)�POLLHUP�POLLERR�POLLNVAL�handle_close�OSError�errno�
_DISCONNECTEDr"r!)r$�flags�errr�	readwriteps(


�

��r8�c	Cs6|durt}|r�g}g}g}t|���D]&\}}|��}|��}|r'|�|�|r1|js1|�|�|s5|r:|�|�qg|krJ|krJ|krSnnt�|�dSt	�	||||�\}}}|D]}|�
|�}|durlq`t|�q`|D]}|�
|�}|durqst|�qs|D]}|�
|�}|dur�q�t
|�q�dSdSr)�
socket_map�list�items�readable�writable�append�	accepting�time�sleepr+�getr%r(r*)	�timeout�map�r�wr7�fdr$�is_r�is_wrrr�poll�sF



�"






�rKcCs�|durt}|durt|d�}t��}|r^t|���D]&\}}d}|��r.|tjtjBO}|�	�r:|j
s:|tjO}|rB|�||�q|�|�}|D]\}}|�
|�}|durXqJt||�qJdSdS)Ni�r)r:�intr+rKr;r<r=r,r.r>r@r-�registerrCr8)rDrE�pollsterrHr$r6rFrrr�poll2�s.
�

�rO�>@FcCs�|durt}|rttd�rt}nt}|dur#|r!|||�|sdSdS|r:|dkr>|||�|d}|r<|dks)dSdSdSdS)NrKr�)r:�hasattrr+rOrK)rD�use_pollrE�count�poll_funrrr�loop�s
�
�rVc@s2eZdZdZdZdZdZdZdZe	dh�Z
dAdd�Zdd�ZdBdd	�Z
dBd
d�Zejejfdd
�ZdBdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdCd'd(�Zd)d*�Z d+d,�Z!d-d.�Z"d/d0�Z#d1d2�Z$d3d4�Z%d5d6�Z&d7d8�Z'd9d:�Z(d;d<�Z)d=d>�Z*d?d@�Z+dS)D�
dispatcherFN�warningc
Cs�|durt|_n||_d|_|rK|�d�|�||�d|_z|��|_WdStyJ}z|j	t
tfvr9d|_n|�|��WYd}~dSd}~wwd|_
dS)NFT)r:�_map�_fileno�setblocking�
set_socket�	connected�getpeername�addrr3r4rr�del_channel�socket)�self�sockrErrrr�__init__�s&

���
zdispatcher.__init__cCs�|jjd|jjg}|jr|jr|�d�n|jr|�d�|jdur@z
|�d|j�Wnty?|�t|j��Ynwdd�	|�t
|�fS)N�.�	listeningr]z%s:%dz<%s at %#x>� )�	__class__rrr@r_r?r]�	TypeError�repr�join�id)rb�statusrrr�__repr__s

�zdispatcher.__repr__cCs|dur|j}|||j<dSr)rYrZ)rbrErrr�add_channelszdispatcher.add_channelcCs,|j}|dur
|j}||vr||=d|_dSr)rZrY)rbrErHrrrr`s
zdispatcher.del_channelcCs.||f|_t�||�}|�d�|�|�dS�NF)�family_and_typerar[r\)rb�family�typercrrr�
create_sockets

zdispatcher.create_socketcCs||_|��|_|�|�dSr)ra�filenorZro�rbrcrErrrr\%s
zdispatcher.set_socketcCsBz|j�tjtj|j�tjtj�dB�WdSty YdSw)NrQ)ra�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�
getsockoptr3�rbrrr�set_reuse_addr*s
��
��zdispatcher.set_reuse_addrcC�dS�NTrr{rrrr=;�zdispatcher.readablecCr}r~rr{rrrr>>rzdispatcher.writablecCs(d|_tjdkr|dkrd}|j�|�S)NT�nt�)r@r�namera�listen)rb�numrrrr�Eszdispatcher.listencCs||_|j�|�Sr)r_ra�bind)rbr_rrrr�Kszdispatcher.bindcCsnd|_d|_|j�|�}|tttfvs|tkr!tj	dkr!||_
dS|dtfvr0||_
|��dSt
|t|��)NFTr�r)r]�
connectingra�
connect_exrrrrrr�r_r	�handle_connect_eventr3r)rb�addressrrrr�connectOszdispatcher.connectc
Csdz|j��\}}W||fStyYdSty1}z|jtttfvr,WYd}~dS�d}~wwr)ra�acceptrir3r4rrr
)rb�connr_�whyrrrr�]s	���zdispatcher.acceptc
Csfz	|j�|�}|WSty2}z|jtkrWYd}~dS|jtvr-|��WYd}~dS�d}~ww�Nr)ra�sendr3r4rr5r2)rb�data�resultr�rrrr�ks

��zdispatcher.sendc
Cs`z|j�|�}|s|��WdS|WSty/}z|jtvr*|��WYd}~dS�d}~ww�N�)ra�recvr2r3r4r5)rb�buffer_sizer�r�rrrr�xs
��zdispatcher.recvc
Cspd|_d|_d|_|��|jdur6z|j��WdSty5}z|jtt	fvr*�WYd}~dSd}~wwdSrp)
r]r@r�r`ra�closer3r4rr
)rbr�rrrr��s
����zdispatcher.closecCstj�dt|��dS)Nzlog: %s
)�sys�stderrr(�str)rb�messagerrr�log�szdispatcher.log�infocCs"||jvrtd||f�dSdS)Nz%s: %s)�ignore_log_types�print)rbr�rsrrr�log_info�s
�zdispatcher.log_infocCs>|jr	|��dS|js|jr|��|��dS|��dSr)r@�
handle_acceptr]r�r��handle_readr{rrrr �szdispatcher.handle_read_eventcCs@|j�tjtj�}|dkrt|t|���|��d|_d|_dS)NrTF)	rarzrx�SO_ERRORr3r�handle_connectr]r��rbrrrrr��s
zdispatcher.handle_connect_eventcCs*|jrdS|js|jr|��|��dSr)r@r]r�r��handle_writer{rrrr'�szdispatcher.handle_write_eventcCs2|j�tjtj�}|dkr|��dS|��dSr�)rarzrxr�r2�handle_exptr�rrrr)�szdispatcher.handle_expt_eventcCsTt�\}}}}zt|�}Wn
dt|�}Y|�d||||fd�|��dS)Nz)<__repr__(self) failed for object at %0x>z:uncaptured python exception, closing channel %s (%s:%s %s)�error)�compact_tracebackrjrlr�r2)rb�nil�t�v�tbinfo�	self_reprrrrr"�s��	zdispatcher.handle_errorcC�|�dd�dS)Nz!unhandled incoming priority eventrX�r�r{rrrr���zdispatcher.handle_exptcCr�)Nzunhandled read eventrXr�r{rrrr��r�zdispatcher.handle_readcCr�)Nzunhandled write eventrXr�r{rrrr��r�zdispatcher.handle_writecCr�)Nzunhandled connect eventrXr�r{rrrr��r�zdispatcher.handle_connectcCs"|��}|dur|j|�dSdSr)r��handle_accepted)rb�pairrrrr��s�zdispatcher.handle_acceptcCs|��|�dd�dS)Nzunhandled accepted eventrX)r�r�)rbrcr_rrrr��szdispatcher.handle_acceptedcCs|�dd�|��dS)Nzunhandled close eventrX)r�r�r{rrrr2�szdispatcher.handle_close�NNr)r�),rrr�debugr]r@r��closingr_�	frozensetr�rdrnror`ra�AF_INET�SOCK_STREAMrtr\r|r=r>r�r�r�r�r�r�r�r�r�r r�r'r)r"r�r�r�r�r�r�r2rrrrrW�sL

 

	


rWc@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�dispatcher_with_sendNcCst�|||�d|_dSr�)rWrd�
out_bufferrvrrrrds
zdispatcher_with_send.__init__cCs.d}t�||jdd��}|j|d�|_dS)Nri)rWr�r�)rb�num_sentrrr�
initiate_sendsz"dispatcher_with_send.initiate_sendcCs|��dSr)r�r{rrrr�sz!dispatcher_with_send.handle_writecCs|jpt|j�Sr)r]�lenr�r{rrrr>szdispatcher_with_send.writablecCs0|jr|�dt|��|j||_|��dS)Nz
sending %s)r�r�rjr�r�)rbr�rrrr�szdispatcher_with_send.sendr�)rrrrdr�r�r>r�rrrrr�s
r�cCs�t��\}}}g}|std��|r'|�|jjj|jjjt|j	�f�|j
}|s~|d\}}}d�dd�|D��}|||f|||fS)Nztraceback does not exist���rgcSsg|]}d|�qS)z
[%s|%s|%s]r)�.0�xrrr�
<listcomp>-sz%compact_traceback.<locals>.<listcomp>)r��exc_info�AssertionErrorr?�tb_frame�f_code�co_filename�co_namer��	tb_lineno�tb_nextrk)r�r��tbr��file�function�liner�rrrr�s ��	r�cCs�|durt}t|���D]1}z|��Wqty/}z|jtkr"n|s%�WYd}~qd}~wty6�|s<�Yq|��dSr)	r:r;�valuesr�r3r4r
r!�clear)rE�
ignore_allr�rrr�	close_all0s$
��r��posixc@sNeZdZdd�Zdd�Zdd�Zdd�Zdd
d�ZeZeZ	dd
�Z
dd�Zd	S)�file_wrappercCst�|�|_dSr)r�duprH�rbrHrrrrdUr�zfile_wrapper.__init__cCs*|jdkrtjd|t|d�|��dS)Nrzunclosed file %r)�source)rH�warnings�warn�ResourceWarningr�r{rrr�__del__Xs

�zfile_wrapper.__del__cG�tj|jg|�R�Sr)rr%rH�rb�argsrrrr�^�zfile_wrapper.recvcGr�r)rr(rHr�rrrr�ar�zfile_wrapper.sendNcCs$|tjkr|tjkr|sdStd��)Nrz-Only asyncore specific behaviour implemented.)rarxr��NotImplementedError)rb�level�optname�buflenrrrrzds

�zfile_wrapper.getsockoptcCs(|jdkrdS|j}d|_t�|�dS)Nrr�)rHrr�r�rrrr�os

zfile_wrapper.closecCs|jSr)rHr{rrrruvszfile_wrapper.filenor)rrrrdr�r�r�rzr%r(r�rurrrrr�Ps
r�c@seZdZddd�Zdd�ZdS)�file_dispatcherNcCsNt�|d|�d|_z|��}Wn	tyYnw|�|�t�|d�dS)NTF)rWrdr]ru�AttributeError�set_filer�set_blocking)rbrHrErrrrd{s�
zfile_dispatcher.__init__cCs"t|�|_|j��|_|��dSr)r�rarurZror�rrrr��s
zfile_dispatcher.set_filer)rrrrdr�rrrrr�ys
r�)r9N)rPFNNrp)0�__doc__r+rar�rAr�rr4rrrrrrrr	r
rrr
rr��DeprecationWarningr�r5r:rr�	Exceptionr�KeyboardInterrupt�
SystemExitr!r%r(r*r8rKrO�poll3rVrWr�r�r�r�r�r�rrrr�<module>sT<���


'
*

)�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY