Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/lib/python2.7/site-packages/firewall/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyo
�
�c�`c@s�dgZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
defd	��YZd
S(tFirewallDirecti����(tLastUpdatedOrderedDict(t	ipXtables(tebtables(tFirewallTransaction(tlog(terrors(t
FirewallErrorcBsdeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd$d�Z
d�Zd	�Zd$d
�Z
d�Zd�Zd
�Zd�Zd$d�Zd$d�Zd�Zd�Zd�Zd$d�Zd$d�Zd�Zd�Zd�Zd�Zd�Zd�Zd$d�Zd$d�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%d#�Z&RS(%cCs||_|j�dS(N(t_fwt_FirewallDirect__init_vars(tselftfw((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt__init__'s	cCs d|j|j|j|jfS(Ns%s(%r, %r, %r)(t	__class__t_chainst_rulest_rule_priority_positions(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt__repr__+scCs1i|_i|_i|_i|_d|_dS(N(RRRt
_passthroughstNonet_obj(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt__init_vars/s
				cCs|j�dS(N(R	(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytcleanup6scCs
t|j�S(N(RR(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytnew_transaction;scCs
||_dS(N(R(R
tobj((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytset_permanent_config@scCs|t|j�t|j�t|j�dkr3tSt|jj��t|jj��t|jj��dkrxtSt	S(Ni(
tlenRRRtTrueRtget_all_chainst
get_all_rulestget_all_passthroughstFalse(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pythas_configurationCs/%cCsu|dkr|j�}n|}|j|jj�|jj�|jj�f|�|dkrq|jt�ndS(N(	RRt
set_configRRRRtexecuteR(R
tuse_transactionttransaction((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytapply_directLscCs�i}i}i}xi|jD]^}|\}}xI|j|D]:}|jj|||�s<|j|g�j|�q<q<WqWx�|jD]�}|\}}}xl|j|D]]\}	}
|jj||||	|
�s�||kr�t�||<n|	|||	|
f<q�q�Wq�Wxk|jD]`}xW|j|D]H}
|jj	||
�s.||krbg||<n||j|
�q.q.WqW|||fS(N(
RRtquery_chaint
setdefaulttappendRt
query_ruleRRtquery_passthrough(R
tchainstrulestpassthroughsttable_idtipvttabletchaintchain_idtprioritytargs((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytget_runtime_config]s,$
cCs|j|j|jfS(N(RRR(R
((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt
get_config|sc
Cs|dkr|j�}n|}|\}}}x�|D]�}|\}}	xp||D]d}
|j||	|
�sTy|j||	|
d|�Wq�tk
r�}tjt|��q�XqTqTWq7Wx�|D]�}|\}}	}
x�||D]v\}
}|j||	|
|
|�s�y#|j	||	|
|
|d|�Wq]tk
rY}tjt|��q]Xq�q�Wq�Wx{|D]s}xj||D]^}|j
||�s}y|j||d|�Wq�tk
r�}tjt|��q�Xq}q}WqlW|dkr�|jt
�ndS(NR#(RRR&t	add_chainRRtwarningtstrR)tadd_ruleR*tadd_passthroughR"R(R
tconfR#R$RRRR.R/R0R1terrorR2R3R4((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR!s@
"
"
"cCs>dddg}||kr:ttjd||f��ndS(Ntipv4tipv6tebs'%s' not in '%s'(RRtINVALID_IPV(R
R/tipvs((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt
_check_ipv�s	cCsf|j|�|dkr(tjj�ntjj�}||krbttjd||f��ndS(NR>R?s'%s' not in '%s'(sipv4sipv6(RCRtBUILT_IN_CHAINStkeysRRRt
INVALID_TABLE(R
R/R0ttables((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt_check_ipv_table�s
	cCs�|dkrJtj|}|jjr.i}qd|jj|�j|}ntj|}tj|}||kr�tt	j
d|��n||kr�tt	j
d|��n|dkr�|jjj|�dk	r�tt	jd|��q�ndS(NR>R?schain '%s' is built-in chainschain '%s' is reservedsChain '%s' is reserved(sipv4sipv6(sipv4sipv6(RRDRtnftables_enabledtget_direct_backend_by_ipvt
our_chainsRt
OUR_CHAINSRRt
BUILTIN_CHAINtzonetzone_from_chainRt
INVALID_CHAIN(R
R/R0R1tbuilt_in_chainsRK((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt_check_builtin_chain�s"
	

			cCsc|r%|jj|g�j|�n:|j|j|�t|j|�dkr_|j|=ndS(Ni(RR'R(tremoveR(R
R.R1tadd((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt_register_chain�s
cCsZ|dkr|j�}n|}|jt||||�|dkrV|jt�ndS(N(RRt_chainRR"(R
R/R0R1R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR7�scCsZ|dkr|j�}n|}|jt||||�|dkrV|jt�ndS(N(RRRVRR"R(R
R/R0R1R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytremove_chain�scCsO|j||�|j|||�||f}||jkoN||j|kS(N(RHRRR(R
R/R0R1R.((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR&�s
cCs:|j||�||f}||jkr6|j|SgS(N(RHR(R
R/R0R.((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt
get_chains�s
cCsXg}xK|jD]@}|\}}x+|j|D]}|j|||f�q0WqW|S(N(RR((R
trtkeyR/R0R1((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR�scCs`|dkr|j�}n|}|jt||||||�|dkr\|jt�ndS(N(RRt_ruleRR"(R
R/R0R1R3R4R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR:scCs`|dkr|j�}n|}|jt||||||�|dkr\|jt�ndS(N(RRR[RR"R(R
R/R0R1R3R4R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytremove_rulescCsE|j||�|||f}||jkoD||f|j|kS(N(RHR(R
R/R0R1R3R4R2((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR)scCsI|j||�|||f}||jkrEt|j|j��SgS(N(RHRtlistRE(R
R/R0R1R2((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt	get_ruless
c	Csmg}x`|jD]U}|\}}}x=|j|D].\}}|j||||t|�f�q3WqW|S(N(RR(R](R
RYRZR/R0R1R3R4((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR%s*cCs�|r�||jkr(t�|j|<n||j||<||jkrXi|j|<n||j|kr�|j||cd7<q�d|j||<nK|j||=t|j|�dkr�|j|=n|j||cd8<dS(Nii(RRRR(R
trule_idR2R3tenable((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt_register_rule-s
cCs_y&|jj|jj|�j|�SWn2tk
rZ}tj|�ttj	|��nXdS(N(
RtruleRJtnamet	ExceptionRtdebug2RRtCOMMAND_FAILED(R
R/R4tmsg((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytpassthroughAs
&
cCsz|r<||jkr%g|j|<n|j|j|�n:|j|j|�t|j|�dkrv|j|=ndS(Ni(RR(RSR(R
R/R4R`((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt_register_passthroughIscCs]|dkr|j�}n|}|jt|t|�|�|dkrY|jt�ndS(N(RRt_passthroughRR]R"(R
R/R4R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR;SscCs]|dkr|j�}n|}|jt|t|�|�|dkrY|jt�ndS(N(RRRjRR]R"R(R
R/R4R#R$((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytremove_passthrough^scCs&||jko%t|�|j|kS(N(Rttuple(R
R/R4((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR*iscCsOg}xB|jD]7}x.|j|D]}|j|t|�f�q$WqW|S(N(RR(R](R
RYR/R4((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyRms
!cCsGg}||jkrCx+|j|D]}|jt|��q#Wn|S(N(RR(R](R
R/RYR4((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pytget_passthroughsts
cCss|j||�|jjrH|d
krH|jjj||||�n|}|jj|�}	|jjr�|	j|||�r�d|}nB|jjr�|ddkr�|	j|||d �r�|d }n|||f}
||f}|r<|
|jkr�||j|
kr�tt	j
d||||f��q�nX|
|jks^||j|
kr�tt	jd||||f��n|j|
|}d}|
|jkrt
|j|
j��}
d	}xL|t|
�kr||
|kr||j|
|
|7}|d7}q�Wn|j|	|	j|||||��|j||
||�|j|j||
||�dS(NR>R?s	%s_directi����t_directs"rule '%s' already is in '%s:%s:%s'srule '%s' is not in '%s:%s:%s'ii(sipv4sipv6(RHRRIRNtcreate_zone_base_by_chainRJtis_chain_builtinRRRtALREADY_ENABLEDtNOT_ENABLEDRtsortedRERR:t
build_ruleRatadd_fail(R
R`R/R0R1R3R4R$RVtbackendR2R_tindext	positionstj((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR[{sL




		(%%cCs"|j||�|j|||�||f}|r|||jkr�||j|kr�ttjd|||f��q�nD||jks�||j|kr�ttjd|||f��n|jj|�}|j	||j
|||��|j|||�|j|j|||�dS(Ns chain '%s' already is in '%s:%s'schain '%s' is not in '%s:%s'(
RHRRRRRRqRrRRJt	add_rulestbuild_chain_rulesRURu(R
RTR/R0R1R$R.Rv((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyRV�s$		c
Csn|j|�t|�}|rc||jkr�||j|kr�ttjd||f��q�nA||jks�||j|kr�ttjd||f��n|jj|�}|r|j	|�|dkr|j
|�\}}|r|r|jjj|||�qn|}	n|j
|�}	|j||	�|j|||�|j|j|||�dS(Nspassthrough '%s', '%s'R>R?(sipv4sipv6(RCRlRRRRqRrRRJtcheck_passthroughtpassthrough_parse_table_chainRNRotreverse_passthroughR:RiRu(
R
R`R/R4R$t
tuple_argsRvR0R1t_args((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyRj�s0
		
	N('t__name__t
__module__RRR	RRRR RR%R5R6R!RCRHRRRUR7RWR&RXRR:R\R)R^RRaRhRiR;RkR*RRmR[RVRj(((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyR&sH										'															
				_	N(t__all__tfirewall.fw_typesRt
firewall.coreRRtfirewall.core.fw_transactionRtfirewall.core.loggerRtfirewallRtfirewall.errorsRtobjectR(((s;/usr/lib/python2.7/site-packages/firewall/core/fw_direct.pyt<module>s	

ZeroDay Forums Mini