HEX
Server: LiteSpeed
System: Linux spg20.cloudpowerdns.com 5.14.0-611.35.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Feb 25 03:46:09 EST 2026 x86_64
User: carrerup (3153)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/fail2ban/client/__pycache__/beautifier.cpython-39.opt-1.pyc
a

J��g�&�@sRdZdZdZddlZddlmZmZddlmZm	Z	m
Z
ee�ZGdd	�d	�Z
dS)
z!Cyril Jaquier, Yaroslav Halchenkoz:Copyright (c) 2004 Cyril Jaquier, 2013- Yaroslav HalchenkoZGPL�N�)�UnknownJailException�DuplicateJailException)�	getLogger�logging�
PREFER_ENCc@sheZdZeZejr&ejjdur&ejjZe��dkr6dndZ	ddd�Z
dd�Zd	d
�Zdd�Z
d
d�ZdS)�
BeautifierNzutf-8�rcCs
||_dS�N��_Beautifier__inputCmd��self�cmd�r�>/usr/lib/python3.9/site-packages/fail2ban/client/beautifier.py�__init__.szBeautifier.__init__cCs
||_dSr
rr
rrr�setInputCmd1szBeautifier.setInputCmdcCs|jSr
r)rrrr�getInputCmd4szBeautifier.getInputCmdc	stt�ddt|�dt|j��|j}|��z�|ddkrHd|��n�|ddkr\|��n�|ddkrpd	��n�|dd
kr�t|�dkr�|dur�d�n|dur�d
��nz|ddkr�d|��nb|ddkr�d|��nJ|ddkr�d�����n0|dd�dgk�rndd�fdd�	}t|�dk�rH|ddk�rHd|dg�||��nd}t|�dk�rn|d}|dd�}dg�t|�D]n\}}|�s�|t|�dk�r�dnd}t|dt��r�d�t	t
|d��n|d}��d||d|f��q||�r`��d�d}	|��D]V\}}
|	d7}	|	t|�k�r*dnd}��d ||f�||
|	t|�k�rVd!nd"��qd#�����n�|dd�d$gk�s�|dd�d%gk�r�gd&�gd'�g}d(d)�}|�s�Wd*Sd#�||||j
����nLt|�d+k�r�n:|dd,k�rd-��d.|7��n|dd/k�r*d0��d.|7��n�|dd+�d1gk�rhd2��tt|t��r\t�|�n|�7��n�|dd3k�r�|du�r�d4�nd5��d.|7��n�|dd6k�r�|du�r�d4�nd7��d8|7��nTt|�d9k�rސnB|d+d:v�r<t|�dk�rd;�n8d<�|dd�D]}
�d=|
d#7��q�d.|d7��n�|d+d>k�rZd?��|7��n�|d+d@v�r�t|�dk�r|dA�ndB��dC�dDdE�|D��7��n�|d+dFk�r�dG�|du�rˆdH7�n,|ddu�r�dI|d7�n�dJ|7��n.|d+dKv�rPt|�dk�rdL�n8dM�|dd�D]}�d=|d#7��q$�d.|d7��n�|d+dNv�r�t|�dk�rrdO�n\dP�d}|dd�D]*}�dQt
|�dR|d#7�|d7}�q��dSt
|�dR|d7��nN|d+dTk�rt|�dk�r�dU|d�ndV|d��dW�|�7��n|d+dXk�rpt|�dk�rLdY|d|d9f�n"dZ|d|d9f��dW�|�7�n�|d+d[k�r�t|�dk�r�d\|d|d9f�n"d]|d|d9f��dW�|�7�nZ|d+d^k�r |dd_k�r t|t��r t|�d9k�rdn|d9}|d`k�rd#}|�|��WnLt�ynt�da�tjdb||jt��tjkdc�t��t|��Yn0�S)eN�z	Beautify z with rZpingzServer replied: �version�startzJail started�stopr	zShutdown successfulzJail stopped�addzAdded jail Z	flushlogszlogs: Zecho� �status�c	s�t|�D]�\}}||t|�dkr&dnd}��d||df�||t|�dkrXdnd}t|d�D]j\}}||t|d�dkr�dnd}t|dt�r�d�tt|d��n|d}��d	||d|f�qjqdS)
Nr	�`-�|-z%s %srz   z|  r�	%s %s:	%s)�	enumerate�len�append�
isinstance�list�join�map�str)	�responseZpref�n�res1�prefix1�mZres2Zprefix2�val��msgrr�	jail_statQs *z&Beautifier.beautify.<locals>.jail_statz--allzStatus for the jail: %s���ZStatusrrrz`- Status for the jails:z   %s Jail: %sz      z   |  �
ZstatsZ
statistics)�|�-r3�xr5r4r3r4)u║u═u╟u╫u╬u╩u│u─c	slgd�}gd�}gd�}gd�}dd�|��D�}g}tt|d��D].��fdd	�|D�}|�t|�t|���qFg}	g}
tt|d��D]8�|�r�d
nd}|	�||��|
�||��q�|	d|	dd
|	d�d|	dfd
|	d�d|	dfg}	|
d|
dd
|
d�d|
dfd
|
d�d|
dfg}
|d|dd|d|dd|d|dg}|
d|
dd|dfd|dfg}
|
dd�}d�dd�|	�}	d�dd�|
�}
d�dd�|
�}
d�dd�|�}|t|dd��d�d�d�d�d�d��fdd�|dd�D���d}g}|�d|
tddg|dd���|�d|�|�d|
t|���d�d�d��fdd�|D���d}|��d|�|D]}|�d|	t|���q�d�d�d��fdd�|D���d}|��d|�|S)N)ZJailZBackendZFilterZActions)rr�cur�totr6r7)�r8�r9r9r9)rrr	r	r	r	cSs,g|]$\}}||dg|d�|d��qS)rr	rr)�.0r)�rrrr�
<listcomp>{�z<Beautifier.beautify.<locals>._statstable.<locals>.<listcomp>rc3s|]}tt|���VqdSr
)r!r')r:�s)�irr�	<genexpr>~r=z;Beautifier.beautify.<locals>._statstable.<locals>.<genexpr>z%%%dsz%%-%dsr	z%s %s %sr�r9�rr�csg|]}�d|�qS)rCr�r:r)��ctrrr<�r=rcsg|]}�d|�qS�r	rrDrErrr<�r=csg|]}�d|�qSrGrrDrErrr<�r=)�items�ranger!r"�maxr%�tuple)r(rFZtopheadZheadersZminlensZralignZrowsZlens�colZrfmtZhfmt�fZtlensZtfmtZtsep�	separator�ret�rowr)rFr?r�_statstablevsP@@4(&2��&44z(Beautifier.beautify.<locals>._statstablezNo jails found.rZsyslogsocketzCurrent syslog socket is:
z`- Z	logtargetzCurrent logging target is:
ZloglevelzCurrent logging level is ZdbfilezDatabase currently disabledzCurrent database file is:
Z
dbpurgeagezCurrent database purge age is:
z`- %isecondsr9)ZlogpathZ
addlogpathZ
dellogpathzNo file is currently monitoredzCurrent monitored log file(s):
z|- Zlogencodingz Current log encoding is set to:
)ZjournalmatchZaddjournalmatchZdeljournalmatchzNo journal match filter setzCurrent match filter:
z + css|]}d�|�VqdS)rN)r%)r:�resrrrr@�r=z&Beautifier.beautify.<locals>.<genexpr>ZdatepatternzCurrent date pattern set to: zNot set/requiredz%sz%s (%s))ZignoreipZaddignoreipZdelignoreipz No IP address/network is ignoredz)These IP addresses/networks are ignored:
)Z	failregexZaddfailregexZdelfailregexZignoreregexZaddignoreregexZdelignoreregexz No regular expression is definedz.The following regular expression are defined:
z|- [z]: z`- [�actionszNo actions for jail %sz'The jail %s has the following actions:
z, Zactionpropertiesz#No properties for jail %s action %sz4The jail %s action %s has the following properties:
Z
actionmethodsz No methods for jail %s action %sz1The jail %s action %s has the following methods:
Zbanip�getz--with-timez)Beautifier error. Please report the errorzBeautify %r with %r failed)�exc_info)r)�logSys�log�reprrr!r%r r#r$r&r'r"rH�encUtf�intrZgetLevelName�	ExceptionZwarning�errorZgetEffectiveLevel�DEBUG)rr(ZinCr0Zjstatr)r*r+r-r?�jZchrTablerQ�path�ip�c�l�seprr.r�beautify7s0�
 ,
 (�&&



 ����

�zBeautifier.beautifycCsbt�d||j�|}t|t�r2d|jdd}n,t|t�rBd}nt|t�r^d|jdd}|S)NzBeautify (error) %r with %rzSorry but the jail 'rz' does not existz Sorry but the command is invalidz
The jail 'z' already exists)rV�debugrr#r�args�
IndexErrorr)rr(r/rrr�
beautifyErrors


zBeautifier.beautifyError)N)�__name__�
__module__�__qualname__rZ	stdoutEnc�sys�stdout�encoding�lowerrYrrrrdrhrrrrr's
Qr)�
__author__Z
__copyright__Z__license__rl�
exceptionsrrZhelpersrrrrirVrrrrr�<module>s