HEX
Server: LiteSpeed
System: Linux 112.webhostingindonesia.co.id 5.14.0-570.62.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 10:10:59 EST 2025 x86_64
User: iyfwylsv (10313)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //lib/python3.9/site-packages/fail2ban/compat/__pycache__/asyncore.cpython-39.pyc
a

!�f�N'�@sfdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZeee
eeeeh�ZzeWney�iZYn0dd�ZGdd�de�ZeeefZdd	�Zd
d�Z dd
�Z!dd�Z"d&dd�Z#d'dd�Z$e$Z%d(dd�Z&Gdd�d�Z'Gdd�de'�Z(dd�Z)d)dd �Z*ej+d!k�rbGd"d#�d#�Z,Gd$d%�d%e'�Z-dS)*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�	errorcodec
CsFzt�|�WStttfy@|tvr4t|YSd|YS0dS)NzUnknown error %s)�os�strerror�
ValueError�
OverflowError�	NameErrorr)�err�r�</usr/lib/python3.9/site-packages/fail2ban/compat/asyncore.py�	_strerrorDsrc@seZdZdS)�ExitNowN)�__name__�
__module__�__qualname__rrrrrLsrcCs8z|��Wn&ty �Yn|��Yn0dS�N)�handle_read_event�_reraised_exceptions�handle_error��objrrr�readQsr"cCs8z|��Wn&ty �Yn|��Yn0dSr)�handle_write_eventrrr rrr�writeYsr$cCs8z|��Wn&ty �Yn|��Yn0dSr)�handle_expt_eventrrr rrr�
_exceptionasr&c
Cs�zX|tj@r|��|tj@r&|��|tj@r8|��|tjtjBtj	B@rV|�
�Wndty�}z(|jt
vr||��n|�
�WYd}~n.d}~0ty��Yn|��Yn0dSr)�select�POLLINr�POLLOUTr#�POLLPRIr%�POLLHUP�POLLERR�POLLNVAL�handle_close�OSError�errno�
_DISCONNECTEDrr)r!�flags�errr�	readwriteis"




r4�c	Cs<|durt}|�r8g}g}g}t|���D]L\}}|��}|��}|rP|�|�|rd|jsd|�|�|sl|r*|�|�q*g|kr�|kr�|kr�nnt�|�dSt	�	||||�\}}}|D] }|�
|�}|dur�q�t|�q�|D]"}|�
|�}|du�rq�t|�q�|D]&}|�
|�}|du�r,�qt
|��qdSr)�
socket_map�list�items�readable�writable�append�	accepting�time�sleepr'�getr"r$r&)	�timeout�map�r�wr3�fdr!Zis_rZis_wrrr�poll}s@


"







rEcCs�|durt}|dur t|d�}t��}|r�t|���D]L\}}d}|��r\|tjtjBO}|�	�rt|j
st|tjO}|r8|�||�q8|�|�}|D]&\}}|�
|�}|dur�q�t||�q�dS)Ni�r)r6�intr'rEr7r8r9r(r*r:r<r)�registerr?r4)r@rAZpollsterrDr!r2rBrrr�poll2�s(


rH�>@FcCsb|durt}|r ttd�r t}nt}|dur>|r^|||�q,n |r^|dkr^|||�|d}q>dS)NrEr�)r6�hasattrr'rHrE)r@Zuse_pollrA�countZpoll_funrrr�loop�s
rMc@s2eZdZdZdZdZdZdZdZe	dh�Z
dAdd�Zdd�ZdBdd	�Z
dCd
d�Zejejfdd
�ZdDdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdEd'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)F�
dispatcherFN�warningc
Cs�|durt|_n||_d|_|r�|�d�|�||�d|_z|��|_Wq�ty�}z.|j	t
tfvrpd|_n|�|��WYd}~q�d}~00nd|_
dS)NFT)r6�_map�_fileno�setblocking�
set_socket�	connected�getpeername�addrr/r0rr�del_channel�socket)�self�sockrArrrr�__init__�s 

zdispatcher.__init__cCs�|jjd|jjg}|jr.|jr.|�d�n|jr>|�d�|jdur�z|�d|j�Wn"ty~|�t|j��Yn0dd�	|�t
|�fS)N�.Z	listeningrTz%s:%dz<%s at %#x>� )�	__class__rrr<rVr;rT�	TypeError�repr�join�id)rY�statusrrr�__repr__�s

zdispatcher.__repr__cCs|dur|j}|||j<dSr)rPrQ)rYrArrr�add_channel	szdispatcher.add_channelcCs,|j}|dur|j}||vr"||=d|_dSr)rQrP)rYrArDrrrrWszdispatcher.del_channelcCs.||f|_t�||�}|�d�|�|�dS�NF)Zfamily_and_typerXrRrS)rY�family�typerZrrr�
create_sockets

zdispatcher.create_socketcCs||_|��|_|�|�dSr)rX�filenorQre�rYrZrArrrrSs
zdispatcher.set_socketcCsBz*|j�tjtj|j�tjtj�dB�Wnty<Yn0dS)NrJ)rX�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�
getsockoptr/�rYrrr�set_reuse_addr#s
���zdispatcher.set_reuse_addrcCsdS�NTrrprrrr94szdispatcher.readablecCsdSrrrrprrrr:7szdispatcher.writablecCs(d|_tjdkr|dkrd}|j�|�S)NT�nt�)r<r�namerX�listen)rY�numrrrrv>szdispatcher.listencCs||_|j�|�Sr)rVrX�bind)rYrVrrrrxDszdispatcher.bindcCspd|_d|_|j�|�}|tttfvs8|tkrBtj	dkrB||_
dS|dtfvr^||_
|��nt
|t|��dS)NFTrsr)rT�
connectingrX�
connect_exrrrrrrurVr	�handle_connect_eventr/r)rY�addressrrrr�connectHs��
zdispatcher.connectc
Csvz|j��\}}WnVty&YdStyh}z,|jtttfvrRWYd}~dS�WYd}~nd}~00||fSdSr)rX�acceptr_r/r0rrr
)rYZconnrV�whyrrrr~Vszdispatcher.acceptc
Csvz|j�|�}|WStyp}zF|jtkr:WYd}~dS|jtvrZ|��WYd}~dS�WYd}~n
d}~00dS�Nr)rX�sendr/r0rr1r.)rY�data�resultrrrrr�ds

zdispatcher.sendc
Cstz(|j�|�}|s |��WdS|WSWnFtyn}z.|jtvrX|��WYd}~dS�WYd}~n
d}~00dS�N�)rX�recvr.r/r0r1)rY�buffer_sizer�rrrrr�qs

zdispatcher.recvc
Csld|_d|_d|_|��|jdurhz|j��Wn4tyf}z|jtt	fvrR�WYd}~n
d}~00dSrf)
rTr<ryrWrX�closer/r0rr
)rYrrrrr��s
zdispatcher.closecCstj�dt|��dS)Nzlog: %s
)�sys�stderrr$�str)rY�messagerrr�log�szdispatcher.log�infocCs||jvrtd||f�dS)Nz%s: %s)�ignore_log_types�print)rYr�rhrrr�log_info�s
zdispatcher.log_infocCs:|jr|��n&|js.|jr$|��|��n|��dSr)r<�
handle_acceptrTryr{�handle_readrprrrr�s

zdispatcher.handle_read_eventcCs@|j�tjtj�}|dkr(t|t|���|��d|_d|_dS)NrTF)	rXrorm�SO_ERRORr/r�handle_connectrTry�rYrrrrr{�szdispatcher.handle_connect_eventcCs*|jr
dS|js|jr|��|��dSr)r<rTryr{�handle_writerprrrr#�szdispatcher.handle_write_eventcCs0|j�tjtj�}|dkr$|��n|��dSr�)rXrormr�r.�handle_exptr�rrrr%�s
zdispatcher.handle_expt_eventcCsXt�\}}}}zt|�}Wndt|�}Yn0|�d||||fd�|��dS)Nz)<__repr__(self) failed for object at %0x>z:uncaptured python exception, closing channel %s (%s:%s %s)�error)�compact_tracebackr`rbr�r.)rY�nil�t�v�tbinfoZ	self_reprrrrr�s��	zdispatcher.handle_errorcCs|�dd�dS)Nz!unhandled incoming priority eventrO�r�rprrrr��szdispatcher.handle_exptcCs|�dd�dS)Nzunhandled read eventrOr�rprrrr��szdispatcher.handle_readcCs|�dd�dS)Nzunhandled write eventrOr�rprrrr��szdispatcher.handle_writecCs|�dd�dS)Nzunhandled connect eventrOr�rprrrr��szdispatcher.handle_connectcCs|��}|dur|j|�dSr)r~�handle_accepted)rY�pairrrrr��szdispatcher.handle_acceptcCs|��|�dd�dS)Nzunhandled accepted eventrO)r�r�)rYrZrVrrrr��szdispatcher.handle_acceptedcCs|�dd�|��dS)Nzunhandled close eventrO)r�r�rprrrr.�szdispatcher.handle_close)NN)N)N)N)r�),rrr�debugrTr<ry�closingrV�	frozensetr�r[rdrerWrX�AF_INET�SOCK_STREAMrirSrqr9r:rvrxr}r~r�r�r�r�r�rr{r#r%rr�r�r�r�r�r�r.rrrrrN�sJ

 

	


rNc@s6eZdZddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�dispatcher_with_sendNcCst�|||�d|_dSr�)rNr[�
out_bufferrkrrrr[�szdispatcher_with_send.__init__cCs.d}t�||jdd��}|j|d�|_dS)Nri)rNr�r�)rYZnum_sentrrr�
initiate_sendsz"dispatcher_with_send.initiate_sendcCs|��dSr)r�rprrrr�sz!dispatcher_with_send.handle_writecCs|jpt|j�Sr)rT�lenr�rprrrr:szdispatcher_with_send.writablecCs0|jr|�dt|��|j||_|��dS)Nz
sending %s)r�r�r`r�r�)rYr�rrrr�szdispatcher_with_send.send)NN)rrrr[r�r�r:r�rrrrr��s

r�cCs�t��\}}}g}|std��|rL|�|jjj|jjjt|j	�f�|j
}q~|d\}}}d�dd�|D��}|||f|||fS)Nztraceback does not exist���r]cSsg|]}d|�qS)z
[%s|%s|%s]r)�.0�xrrr�
<listcomp>&r�z%compact_traceback.<locals>.<listcomp>)r��exc_info�AssertionErrorr;�tb_frame�f_code�co_filename�co_namer��	tb_lineno�tb_nextra)r�r��tbr��file�function�liner�rrrr�s�r�cCs�|durt}t|���D]j}z|��Wqty^}z|jtkrDn|sJ�WYd}~qd}~0typ�Yq|s|�Yq0q|��dSr)	r6r7�valuesr�r/r0r
r�clear)rAZ
ignore_allr�rrr�	close_all)s 

r��posixc@sNeZdZdd�Zdd�Zdd�Zdd�Zdd
d�ZeZeZ	dd
�Z
dd�Zd	S)�file_wrappercCst�|�|_dSr)r�duprD�rYrDrrrr[Nszfile_wrapper.__init__cCs*|jdkrtjd|t|d�|��dS)Nrzunclosed file %r)�source)rD�warnings�warn�ResourceWarningr�rprrr�__del__Qs

�zfile_wrapper.__del__cGstj|jg|�R�Sr)rr"rD�rY�argsrrrr�Wszfile_wrapper.recvcGstj|jg|�R�Sr)rr$rDr�rrrr�Zszfile_wrapper.sendNcCs(|tjkr|tjkr|sdStd��dS)Nrz-Only asyncore specific behaviour implemented.)rXrmr��NotImplementedError)rY�level�optname�buflenrrrro]s
��zfile_wrapper.getsockoptcCs(|jdkrdS|j}d|_t�|�dS)Nrr�)rDrr�r�rrrr�hs

zfile_wrapper.closecCs|jSr)rDrprrrrjoszfile_wrapper.fileno)N)rrrr[r�r�r�ror"r$r�rjrrrrr�Is
r�c@seZdZddd�Zdd�ZdS)�file_dispatcherNcCsNt�|d|�d|_z|��}Wnty2Yn0|�|�t�|d�dS)NTF)rNr[rTrj�AttributeError�set_filer�set_blocking)rYrDrArrrr[ts
zfile_dispatcher.__init__cCs"t|�|_|j��|_|��dSr)r�rXrjrQrer�rrrr�s
zfile_dispatcher.set_file)N)rrrr[r�rrrrr�rs
r�)r5N)r5N)rIFNN)NF).�__doc__r'rXr�r=r�rr0rrrrrrrr	r
rrr
rr�r1r6rr�	Exceptionr�KeyboardInterrupt�
SystemExitrr"r$r&r4rErHZpoll3rMrNr�r�r�rur�r�rrrr�<module>sD<�


'

*
)