https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/fail2ban/server/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/fail2ban/server/__pycache__/ticket.cpython-310.pyc
o

;s*b	!�@sldZdZdZddlmZddlmZddlmZee	�Z
Gdd	�d	e�ZGd
d�de�Z
Gdd
�d
e
�ZdS)z
Cyril Jaquierz Copyright (c) 2004 Cyril Jaquier�GPL�)�	getLogger�)�IPAddr)�MyTimec@s:eZdZdZdZdZdZdddidfdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd>dd�Zd?dd �Zd@d!d"�Zd#d$�Zd>d%d&�Zd>d'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zed1d2��Zejd3d2��Zed4d5��Zejd6d5��Zd7d8�Z dAd9d:�Z!ed;d<��Z"e"jd=d<��Z"dS)B�Ticket)�_ip�_flags�	_banCount�_banTime�_time�_data�_retry�
_lastResetl���r�NcCs�|�|�d|_d|_d|_|dur|nt��|_|pgdd�|_|dur7|��D]
\}}|dur6||j|<q)|r@|�	|�dSdS)z{Ticket constructor

		@param ip the IP address
		@param time the ban time
		@param matches (log) lines caused the ticket
		�N)�matches�failures)
�setIPr	r
rr�timerr
�items�update)�self�iprr�data�ticket�k�v�r�8/usr/lib/python3/dist-packages/fail2ban/server/ticket.py�__init__+s

��zTicket.__init__cCs<d|jj�d�d|j|j|j|j|jd|j�dg�fS)Nz@%s: ip=%s time=%s bantime=%s bancount=%s #attempts=%d matches=%r�.���rr)	�	__class__�__name__�splitrrrr
r
�get�rrrr�__str__Bs��zTicket.__str__cCst|�S�N)�strr'rrr�__repr__HszTicket.__repr__cCsHz|j|jkot|jd�t|jd�ko|j|jkWSty#YdSw)NrF)r�roundrr
�AttributeError)r�otherrrr�__eq__Ks�
��z
Ticket.__eq__cCs0|jD]}t||d�}|durt|||�qdSr))�	__slots__�getattr�setattr)rr�nrrrrrSs
��z
Ticket.updatecCst|t�r	t|�}||_dSr))�
isinstancer*rr�r�valuerrrrZs

zTicket.setIPcCs|j�d|j�S)N�fid)r
r&rr'rrr�getID`szTicket.getIDcC�|jSr))rr'rrr�getIPc�zTicket.getIPcC�
||_dSr)�rr5rrr�setTimef�
zTicket.setTimecCr9r)r=r'rrr�getTimeir;zTicket.getTimecCr<r)�rr5rrr�
setBanTimelr?zTicket.setBanTimecCs|jdur|jS|Sr)rA)r�	defaultBTrrr�
getBanTimeoszTicket.getBanTimeFcCs|s||jkr||_dSdSr)�r
)rr6�alwaysrrr�setBanCountrs
�zTicket.setBanCountcCs|j|7_dSr)rEr5rrr�incrBanCountvszTicket.incrBanCountcCr9r)rEr'rrr�getBanCountyr;zTicket.getBanCountcCs,|jdur|jn|}|dkrtjS|j|S)Nr")rr�MAX_TIMEr)rrC�bantimerrr�getEndOfBanTime|s
zTicket.getEndOfBanTimecCs.|jdur|jn|}|dkrdS||j|kS)Nr"F)rr)rrrCrKrrr�
isTimedOut�szTicket.isTimedOutcCs||jd<dS�Nr�r
r5rrr�
setAttempt�szTicket.setAttemptcCs
|jdSrNrOr'rrr�
getAttempt�r?zTicket.getAttemptcCs6|r	||jd<dSz|jd=WdStyYdSw)Nr)r
�KeyError)rrrrr�
setMatches�s�zTicket.setMatchescCsdd�|j�dd�D�S)NcSs(g|]}t|ttf�s
|nd�|��qS)�)r4�list�tuple�join)�.0�linerrr�
<listcomp>�s �z%Ticket.getMatches.<locals>.<listcomp>rr)r
r&r'rrr�
getMatches�s�zTicket.getMatchescC�|jtj@Sr)�r	r�RESTOREDr'rrr�restored��zTicket.restoredcC�.|r|jtjO_dS|jtjM_dSr)r]r5rrrr_��cCr\r)�r	r�BANNEDr'rrr�banned�r`z
Ticket.bannedcCrar)rcr5rrrre�rbcOs�t|�dkrtdd�|d��D��|_n&t|�dkr#|j�|f�nt|�dkr;|j�dd�tt|�gd�D��t|�rE|j�|�tdd�|j��D��|_dS)	NrcS� g|]\}}|dur||f�qSr)r�rXrrrrrrZ�� z"Ticket.setData.<locals>.<listcomp>rrcss�|]	\}}||fVqdSr)rrgrrr�	<genexpr>�s�z!Ticket.setData.<locals>.<genexpr>cSrfr)rrgrrrrZ�rh)�len�dictrr
r�zip�iter)r�args�argvrrr�setData�s$zTicket.setDatacs��dur|jS|js|St�ttd�ttttf�s>t��r+t	�fdd�|j�
�D��St�d�r>t	�fdd�|j�
�D��S|j��|�S)Ncs g|]\}}�|�r||f�qSrrrg��keyrrrZ�rhz"Ticket.getData.<locals>.<listcomp>�__iter__cs g|]\}}|�vr||f�qSrrrgrqrrrZ�rh)
r
r4r*�type�int�float�bool�complex�callablerkr�hasattrr&)rrr�defaultrrqr�getData�s
zTicket.getDatacCst|dd�S)N�	_banEpochr)r1r'rrr�banEpoch�r`zTicket.banEpochcCr<r))r}r5rrrr~�s
r))F)r)NN)#r$�
__module__�__qualname__r0rJr^rdr r(r+r/rrr8r:r>r@rBrDrGrHrIrLrMrPrQrSr[�propertyr_�setterrerpr|r~rrrrr#sP




	





rc@sNeZdZdddidfdd�Zdd�Zdd�Zdd	�Zddd�Zed
d��Z	dS)�
FailTicketNcCsXd|_d|_t�||||||�t|t�s*|dur|n|��|_|j�dd�|_dSdS)Nrr)	�
_firstTimerrr r4r�r@r
r&)rrrrrrrrrr �s
�zFailTicket.__init__cCs:||_|jds
d|jd<|sd|jd<g|jd<dSdS)z� Set artificial retry count, normally equal failures / attempt,
		used in incremental features (BanTimeIncr) to increase retry count for bad IPs
		rrrrN�rr
r5rrr�setRetry�s


�zFailTicket.setRetrycCr9)zV Returns failures / attempt count or
		artificial retry count increased for bad IPs
		)rr'rrr�getRetry�szFailTicket.getRetrycCsR||jkr'|j||kr"tt|jt||j�|��|_|||_||_dSdS)z� Adjust time of ticket and current attempts count considering given maxTime
		as estimation from rate by previous known interval (if it exceeds the findTime)
		N)rr�rur,rrv)rr�maxTimerrr�
adjustTimes
"

�zFailTicket.adjustTimercCsX|j|7_|jd|7<|r*|jdr#|jd||jd<dS||jd<dSdS)Nrrr�)rr�attempt�countrrr�inc
s
�zFailTicket.inccC�
t|_|Sr))r�r#��orrr�wrap�zFailTicket.wrap)Nrr)
r$rr�r r�r�r�r��staticmethodr�rrrrr��s


r�c@seZdZedd��ZdS)�	BanTicketcCr�r))r�r#r�rrrr�#r�zBanTicket.wrapN)r$rr�r�r�rrrrr�!sr�N)�
__author__�
__copyright__�__license__�helpersr�ipdnsr�mytimerr$�logSys�objectrr�r�rrrr�<module>s@?

https://t.me/RX1948 - 2025