Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ³Y„jy²ã@sÀddlZddlZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z mZmZmZmZmZmZmZmZddlmZmZmZddlmZdd lmZdd lmZGd d „d e ƒZ!dS) éN)Ú SHORTCUTSÚDEFAULT_ZONE_TARGETÚSOURCE_IPSET_TYPES)ÚFirewallTransaction)ÚPolicy)Úlog) Ú Rich_ServiceÚ Rich_PortÚ Rich_ProtocolÚRich_SourcePortÚRich_ForwardPortÚRich_IcmpBlockÚ Rich_IcmpTypeÚRich_MasqueradeÚ Rich_Mark)Ú checkIPnMaskÚ checkIP6nMaskÚ check_mac)Úerrors)Ú FirewallError)ÚLastUpdatedOrderedDictc@sNeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„ZdÇdd „Zd!d"„Zd#d$„Zd%d&„ZdÈd'd(„Zd)d*„Zd+d,„Zd-d.„ZdÉd/d0„ZdÊd1d2„Zd3d4„Zd5d6„Zd7d8„Zd9d:„Zd;d<„Z d=d>„Z!dËd@dA„Z"dBdC„Z#dÌdDdE„Z$dÍdFdG„Z%dÎdHdI„Z&dJdK„Z'dLdM„Z(dNdO„Z)dÏdQdR„Z*dÐdSdT„Z+dÑdUdV„Z,dWdX„Z-dÒdYdZ„Z.dÓd[d\„Z/d]d^„Z0d_d`„Z1dadb„Z2dÔdcdd„Z3dedf„Z4dgdh„Z5didj„Z6dkdl„Z7dmdn„Z8dodp„Z9dÕdqdr„Z:dsdt„Z;dudv„Zd{d|„Z?d}d~„Z@dd€„ZAd×d�d‚„ZBdƒd„„ZCd…d†„ZDd‡dˆ„ZEd‰dŠ„ZFdØd‹dŒ„ZGd�dŽ„ZHd�d�„ZId‘d’„ZJdÙd“d”„ZKd•d–„ZLd—d˜„ZMd™dš„ZNdÚd›dœ„ZOd�dž„ZPdŸd „ZQdÛd¡d¢„ZRdÜd£d¤„ZSdÝd¥d¦„ZTd§d¨„ZUdÞd©dª„ZVd«d¬„ZWd­d®„ZXd¯d°„ZYdßd±d²„ZZd³d´„Z[dµd¶„Z\d·d¸„Z]d¹dº„Z^d»d¼„Z_dàd½d¾„Z`d¿dÀ„ZadádÁd„ZbdÃdÄ„ZcdÅdÆ„ZddS)âÚ FirewallZonercCs||_i|_i|_dS)N)Ú_fwÚ_zonesÚ_zone_policies)ÚselfÚfw©rú/usr/lib/python3.6/fw_zone.pyÚ__init__&szFirewallZone.__init__cCsd|j|jfS)Nz%s(%r))Ú __class__r)rrrrÚ__repr__+szFirewallZone.__repr__cCs|jjƒ|jjƒdS)N)rÚclearr)rrrrÚcleanup.s zFirewallZone.cleanupcCs t|jƒS)N)rr)rrrrÚnew_transaction2szFirewallZone.new_transactioncCsdj||d�S)Nzzone_{fromZone}_{toZone})ÚfromZoneÚtoZone)Úformat)rr%r&rrrÚpolicy_name_from_zones5sz#FirewallZone.policy_name_from_zonescCst|jjƒƒS)N)ÚsortedrÚkeys)rrrrÚ get_zones:szFirewallZone.get_zonescCs8g}x.|jƒD]"}|j|ƒs&|j|ƒr|j|ƒqW|S)N)r+Úlist_interfacesÚ list_sourcesÚappend)rZ active_zonesÚzonerrrÚget_active_zones=s zFirewallZone.get_active_zonescCs6|j|ƒ}x&|jD]}||j|jdkr|SqWdS)NÚ interfaces)Ú_FirewallZone__interface_idrÚsettings)rÚ interfaceÚ interface_idr/rrrÚget_zone_of_interfaceDs   z"FirewallZone.get_zone_of_interfacecCs6|j|ƒ}x&|jD]}||j|jdkr|SqWdS)NÚsources)Ú_FirewallZone__source_idrr3)rÚsourceÚ source_idr/rrrÚget_zone_of_sourceLs   zFirewallZone.get_zone_of_sourcecCs|jj|ƒ}|j|S)N)rÚ check_zoner)rr/ÚzrrrÚget_zoneTs zFirewallZone.get_zonecCsBtƒ}|j|_|j||ƒ|_|j|_|j|_|g|_|g|_�xþd D�]ô}||jkr~|d kr~|d kr~t ||t j t ||ƒƒƒqD|d kr²||jkr²|d kr²t ||t j t ||ƒƒƒqD||jkoÊ|d koÊ|dk�rèt ||t j t ||ƒƒƒqD|dkrDg|_ xB|j D]8}|j||ƒ}||j|j|ƒk�rþ|j jt j |ƒƒ�qþWqDW|S)NÚservicesÚportsÚ masqueradeÚ forward_portsÚ source_portsÚ icmp_blocksÚrulesÚ protocolsÚHOSTÚANY)r?r@rArBrCrDrErF)r?r@rCrDrF)rA)rDrB)rE)rÚnameZderived_from_zoner(ÚZONE_POLICY_PRIORITYZpriorityÚtargetZ ingress_zonesZ egress_zonesÚsetattrÚcopyÚdeepcopyÚgetattrrEÚ_rich_rule_to_policiesr.)rÚz_objr%r&Úp_objZsettingÚruleZcurrent_policyrrrÚpolicy_obj_from_zone_objXs6    z%FirewallZone.policy_obj_from_zone_objcCs’dd„d Dƒ|_||j|j<g|j|j<xX|jdfd|jf|jdfgD]8\}}|j|||ƒ}|jjj|ƒ|j|jj|jƒqFW|j |jƒdS) NcSsi|] }tƒ|“qSr)r)Ú.0Úxrrrú sz)FirewallZone.add_zone..r1r7Úicmp_block_inversionÚforwardrGrH)r1r7rXrY) r3rrIrrTrÚpolicyZ add_policyr.Úcopy_permanent_to_runtime)rÚobjr%r&rRrrrÚadd_zone~s   zFirewallZone.add_zonecCsn|j|}x|jD]}|j||dd�qWx|jD]}|j||dd�q2W|jrZ|j|ƒ|jrj|j|ƒdS)NF)Ú allow_apply) rr1Ú add_interfacer7Ú add_sourcerYÚ add_forwardrXÚadd_icmp_block_inversion)rr/r\Úargrrrr[—s    z&FirewallZone.copy_permanent_to_runtimecCs8|j|}|jr|j|ƒ|jjƒ|j|=|j|=dS)N)rÚappliedÚunapply_zone_settingsr3r"r)rr/r\rrrÚ remove_zone£s    zFirewallZone.remove_zoneNcCsVxP|jƒD]D}|j|}t|jƒdks4t|jƒdkr tjd|ƒ|j||d�q WdS)NrzApplying zone '%s')Úuse_transaction)r+rÚlenr1r7rÚdebug1Úapply_zone_settings)rrgr/rQrrrÚ apply_zones«s   zFirewallZone.apply_zonescCs|j|}||_dS)N)rrd)rr/rdr\rrrÚset_zone_applied²s zFirewallZone.set_zone_appliedcCsœd|kr dS|jdƒ}t|ƒdkr&dSd}x tD]}|dt|kr0|}q0W|dk r˜|d|jƒkrhdSt|ƒdksŒt|ƒdkr˜|dd kr˜|d|fSdS) NÚ_érééÚprerÚdenyÚallowÚpost)rqrrrrsrt)Úsplitrhrr+)rÚchainZsplitsÚ_chainrVrrrÚzone_from_chain¸s      zFirewallZone.zone_from_chaincCst|j|ƒ}|dkrdS|\}}|d kr0|}d}n4|d krB|}d}n"|d krTd}|}nttjd|ƒ‚|j||ƒ|fS) NÚ PREROUTINGÚ FORWARD_INrHÚINPUTrGÚ POSTROUTINGÚ FORWARD_OUTz&chain '%s' can't be mapped to a policy)ryrz)r{)r|r})rxrrZ INVALID_CHAINr()rrvrVr/rwr%r&rrrÚpolicy_from_chainÌs zFirewallZone.policy_from_chainc Csj|dkrf|j|ƒ}|dk rf|j|ƒ\}}|dkr:|jƒ}n|}|jjj|d|||ƒ|dkrf|jdƒdS)NÚipv4Úipv6T)rr€)r~r$rrZZgen_chain_rulesÚexecute) rÚipvÚtablervrgrVrZrwÚ transactionrrrÚcreate_zone_base_by_chainás  z&FirewallZone.create_zone_base_by_chaincCstjƒ||dœ}|S)N)ZdateÚsenderÚtimeout)Útime)rr‡r†ÚretrrrZ__gen_settings÷szFirewallZone.__gen_settingscCs |j|ƒjS)N)r>r3)rr/rrrÚ get_settingsÿszFirewallZone.get_settingscCs¤|j|ƒ}x‚|D]z}xt||D]h}|dkr<|j||||ƒq|dkr`|j|||d|d|ƒq|dkrlqq|dkrvqtjd|||ƒqWqW|r |j|||ƒdS)Nr1r7rrorXrYz3Zone '%s': Unknown setting '%s:%s', unable to apply)rŠÚ _interfaceÚ_sourcerZwarningÚ_icmp_block_inversion)rÚenabler/r„r3ÚkeyÚargsrrrÚ_zone_settingss  zFirewallZone._zone_settingscCs”|jj|ƒ}|j|}|jr dSd|_|dkr8|jƒ}n|}x2|j|D]$}tjd||ƒ|jjj ||d�qHW|j d||ƒ|dkr�|j dƒdS)NTz+Applying policy (%s) derived from zone '%s')rg) rr<rrdr$rrrirZÚapply_policy_settingsr‘r�)rr/rgÚ_zoner\r„rZrrrrjs   z FirewallZone.apply_zone_settingscCs€|jj|ƒ}|j|}|js dS|dkr2|jƒ}n|}x$|j|D]}|jjj||d�qBW|jd||ƒ|dkr||j dƒdS)N)rgFT) rr<rrdr$rrZÚunapply_policy_settingsr‘r�)rr/rgr“r\r„rZrrrre,s   z"FirewallZone.unapply_zone_settingscCs~|j|ƒ}|j|ƒ}g}x\tdƒD]P}|j|d|krZ|jtjt||j|dƒƒƒq"|j||j|dƒq"Wt|ƒS)zH :return: exported config updated with runtime settings ér) r>Úget_config_with_settings_dictÚrangeZIMPORT_EXPORT_STRUCTUREr.rMrNrOÚtuple)rr/r\Z conf_dictZ conf_listÚirrrÚget_config_with_settings?s  "z%FirewallZone.get_config_with_settingsc Cs–|j|ƒjƒ}|dtkr"d|d<|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j |ƒ|j |ƒ|j |ƒ|j |ƒ|j |ƒ|j|ƒdœ }|jj||ƒS)zH :return: exported config updated with runtime settings rKÚdefault) r?r@rDrArBr1r7Ú rules_strrFrCrXrY)r>Zexport_config_dictrÚ list_servicesÚ list_portsÚlist_icmp_blocksÚquery_masqueradeÚlist_forward_portsr,r-Ú list_rulesÚlist_protocolsÚlist_source_portsÚquery_icmp_block_inversionÚ query_forwardrZ'combine_runtime_with_permanent_settings)rr/Z permanentZruntimerrrr–Os  z*FirewallZone.get_config_with_settings_dictc sddlm‰d‡‡fdd„ }‡‡fdd„}ˆjˆjfˆjˆjfˆjˆjfˆjˆj fˆj ˆj fˆj ˆj fˆjˆjf||fˆjˆjfˆjˆjfˆjˆjfˆjˆjfdœ }ˆj|ƒ}ˆjj||ƒ\}} xv| D]n} t| | tƒ�r$xX| | D]:} t| tƒ�r || d|f| žŽqä|| d|| ƒqäWqÆ|| d|ƒqÆWxÐ|D]È} t|| tƒ�rÎx°|| D]l} | dk�r‚|| d|| |d �nDt| tƒ�r®|| d|f| žd|d œŽn|| d|| d|d ��q\Wn6| dk�rî|| d||d �n|| d|d|d ��q>WdS)Nr)Ú Rich_Rulecsˆj|ˆ|d�d|d�dS)N)Úrule_strr)r‡r†)Úadd_rule)r/r¨r‡r†)r§rrrÚadd_rule_wrapperhszDFirewallZone.set_config_with_settings_dict..add_rule_wrappercsˆj|ˆ|d�ƒdS)N)r¨)Ú remove_rule)r/r¨)r§rrrÚremove_rule_wrapperjszGFirewallZone.set_config_with_settings_dict..remove_rule_wrapper) r?r@rDrArBr1r7rœrFrCrXrYror1r7)r†)r‡r†rX)rN)r1r7)rX)Úfirewall.core.richr§Ú add_serviceÚremove_serviceÚadd_portÚ remove_portÚadd_icmp_blockÚremove_icmp_blockÚadd_masqueradeÚremove_masqueradeÚadd_forward_portÚremove_forward_portr_Úremove_interfacer`Ú remove_sourceÚ add_protocolÚremove_protocolÚadd_source_portÚremove_source_portrbÚremove_icmp_block_inversionraÚremove_forwardr–rZget_added_and_removed_settingsÚ isinstanceÚlistr˜) rr/r3r†rªr¬Z setting_to_fnZ old_settingsZ add_settingsZremove_settingsr�r�r)r§rrÚset_config_with_settings_dictesF                    z*FirewallZone.set_config_with_settings_dictcCs|jj|ƒdS)N)rÚcheck_interface)rr4rrrrÃ�szFirewallZone.check_interfacecCs\|jj|ƒ}|j|}|j|ƒ}||jdkrX|jd|}d|krX|ddk rX|dSdS)Nr1r†)rr<rr2r3)rr/r4r“Ú_objr5r3rrrÚinterface_get_sender s   z!FirewallZone.interface_get_sendercCs|j|ƒ|S)N)rÃ)rr4rrrZ__interface_id¬s zFirewallZone.__interface_idTc Cs|jjƒ|jj|ƒ}|j|}|j|ƒ}||jdkrLttjd||fƒ‚|j |ƒdk rjttj d|ƒ‚t j d||fƒ|dkrŽ|j ƒ} n|} |j r¼|r¼|j|| d�| j|j|dƒ|rÐ|jd||| ƒ|j||||ƒ| j|j||ƒ|dk�r| jdƒ|S)Nr1z'%s' already bound to '%s'z'%s' already bound to a zonez&Setting zone of interface '%s' to '%s')rgFT)rÚ check_panicr<rr2r3rrÚZONE_ALREADY_SETr6Ú ZONE_CONFLICTrrir$rdrjÚadd_failrlr‹Ú!_FirewallZone__register_interfaceÚ#_FirewallZone__unregister_interfacer�) rr/r4r†rgr^r“rÄr5r„rrrr_°s8            zFirewallZone.add_interfacecCs6|jd|ƒ|jd|<| p"|dk|jd|d<dS)Nrr1ÚÚ __default__)Ú_FirewallZone__gen_settingsr3)rrÄr5r/r†rrrZ__register_interfaceÙsz!FirewallZone.__register_interfacecCsR|jjƒ|j|ƒ}|jj|ƒ}||kr,|S|dk r@|j||ƒ|j|||ƒ}|S)N)rrÆr6r<r¸r_)rr/r4r†Ú _old_zoneÚ _new_zoner“rrrÚchange_zone_of_interfaceàs    z%FirewallZone.change_zone_of_interfacecCsz|jjƒ|dkr|jƒ}n|}|j||ƒ|jd|d|dd�|dk rd|dkrd|jd|d|dd�|dkrv|jdƒdS)NTú+)r.rÌF)rrÆr$rjr‹r�)rZold_zoneZnew_zonergr„rrrÚchange_default_zoneïs   z FirewallZone.change_default_zonec CsÂ|jjƒ|j|ƒ}|dkr,ttjd|ƒ‚|dkr8|n |jj|ƒ}||krbttjd|||fƒ‚|dkrt|jƒ}n|}|j |}|j |ƒ}|j |j ||ƒ|j d|||ƒ|dkr¾|jdƒ|S)Nz'%s' is not in any zonerÌz"remove_interface(%s, %s): zoi='%s'FT)rrÆr6rrZUNKNOWN_INTERFACEr<rÈr$rr2Úadd_postrËr‹r�) rr/r4rgZzoir“r„rÄr5rrrr¸ÿs(       zFirewallZone.remove_interfacecCs||jdkr|jd|=dS)Nr1)r3)rrÄr5rrrZ__unregister_interfacesz#FirewallZone.__unregister_interfacecCs|j|ƒ|j|ƒdkS)Nr1)r2rŠ)rr/r4rrrÚquery_interfaceszFirewallZone.query_interfacecCs|j|ƒdjƒS)Nr1)rŠr*)rr/rrrr,"szFirewallZone.list_interfacesFcCsxt|ƒr dSt|ƒrdSt|ƒr$dS|jdƒrh|j|dd…ƒ|rV|j|dd…ƒ|j|dd…ƒSttj |ƒ‚dS)Nrr€rÌzipset:é) rrrÚ startswithÚ_check_ipset_type_for_sourceÚ_check_ipset_appliedÚ _ipset_familyrrZ INVALID_ADDR)rr9rdrrrÚ check_source's zFirewallZone.check_sourcecCs|j||d�}||fS)N)rd)rÛ)rr9rdr‚rrrZ __source_id6szFirewallZone.__source_idc Cs|jjƒ|jj|ƒ}|j|}t|ƒr0|jƒ}|j||d�}||jdkr`tt j d||fƒ‚|j |ƒdk r~tt j d|ƒ‚|dkr�|j ƒ} n|} |j r¾|r¾|j|| d�| j|j|dƒ|rÜ|jd||d|d | ƒ|j||||ƒ| j|j||ƒ|dk�r| jdƒ|S) N)rdr7z'%s' already bound to '%s'z'%s' already bound to a zone)rgFTrro)rrÆr<rrÚupperr8r3rrrÇr;rÈr$rdrjrÉrlrŒÚ_FirewallZone__register_sourceÚ _FirewallZone__unregister_sourcer�) rr/r9r†rgr^r“rÄr:r„rrrr`:s4        zFirewallZone.add_sourcecCs6|jd|ƒ|jd|<| p"|dk|jd|d<dS)Nrr7rÌrÍ)rÎr3)rrÄr:r/r†rrrZ__register_sourceaszFirewallZone.__register_sourcecCsb|jjƒ|j|ƒ}|jj|ƒ}||kr,|St|ƒr<|jƒ}|dk rP|j||ƒ|j|||ƒ}|S)N)rrÆr;r<rrÜr¹r`)rr/r9r†rÏrÐr“rrrÚchange_zone_of_sourcegs    z"FirewallZone.change_zone_of_sourcec CsÜ|jjƒt|ƒr|jƒ}|j|ƒ}|dkr¡sz-FirewallZone.list_sources..r7)rŠr*)rr/rrrr- szFirewallZone.list_sourcesc s„x®ˆjjƒD] }|jsq xPˆj|D]B}x<ˆjjj|ƒD]*\}} |j|||||| |ƒ} |j|| ƒq8Wq$Wˆj|dƒ}ˆj |ƒdr |d kr |j |||d|d�} |j|| ƒq WxΈjjj ƒD]¾}|ˆjjj |ƒkrè|ˆjjj |ƒkrèq¾|ˆjjjƒk�rdˆjjj|ƒj�rd| �rÇsz)FirewallZone._interface..cs|ˆjjjƒkoˆjjj|ƒS)N)rrZrår’)rç)rrrrèÊs)rÒrã)rÚenabled_backendsÚpolicies_supportedrrZÚ#_get_table_chains_for_zone_dispatchZ!build_zone_source_interface_rulesÚ add_rulesr(rŠÚbuild_zone_forward_rulesÚ"get_policies_not_derived_from_zoneÚlist_ingress_zonesÚlist_egress_zonesråÚ get_policyrdrhr,r”Ú_ingress_egress_zonesrÔ) rrŽr/r4r„r.ÚbackendrZrƒrvrEr)rrr‹£s2 $zFirewallZone._interfacecCs$|j|ƒdkrdS|jjj|dd�S)Nzhash:macF)rd)Ú _ipset_typerÚipsetZ get_family)rrIrrrrÚÏszFirewallZone._ipset_familycCs|jjj|dd�S)NF)rd)rrõZget_type)rrIrrrrôÔszFirewallZone._ipset_typecCsdj|g|jjj|ƒƒS)Nú,)ÚjoinrrõZ get_dimension)rrIÚflagrrrÚ_ipset_match_flags×szFirewallZone._ipset_match_flagscCs|jjj|ƒS)N)rrõZ check_applied)rrIrrrrÙÚsz!FirewallZone._check_ipset_appliedcCs*|j|ƒ}|tkr&ttjd||fƒ‚dS)Nz.ipset '%s' with type '%s' not usable as source)rôrrrZ INVALID_IPSET)rrIZ_typerrrrØÝs  z)FirewallZone._check_ipset_type_for_sourcec sŒx¶|rˆjj|ƒgnˆjjƒD]–}|js*qxNˆj|D]@}x:ˆjjj|ƒD](\}} |j|||||| ƒ} |j|| ƒqJWq6Wˆj |dƒ}ˆj |ƒdr|j |||d|d�} |j|| ƒqWxΈjjj ƒD]¾}|ˆjjj |ƒkrð|ˆjjj|ƒkrðqÆ|ˆjjjƒk�rlˆjjj|ƒj�rl| �rDtˆj|ƒƒdk�rDˆjjj||d�n&ˆjjjd||ƒ|j‡fdd „|ƒqÆ|rÆ|j‡fd d „|ƒqÆWdS) NrHrYrä)r9ro)rgFcs |ˆjjjƒkoˆjjjd|ƒS)NT)rrZråræ)rç)rrrrèsz&FirewallZone._source..cs|ˆjjjƒkoˆjjj|ƒS)N)rrZrår’)rç)rrrrè s)rÚget_backend_by_ipvrérêrrZrëZbuild_zone_source_address_rulesrìr(rŠrírîrïrðrårñrdrhr-r”ròrÔ) rrŽr/r‚r9r„rórZrƒrvrEr)rrrŒås2"  $zFirewallZone._sourcecCs0|jj|ƒ}|j|dƒ}|jjj||||ƒ|S)NrG)rr<r(rZr®)rr/Úservicer‡r†Úp_namerrrr® s  zFirewallZone.add_servicecCs,|jj|ƒ}|j|dƒ}|jjj||ƒ|S)NrG)rr<r(rZr¯)rr/rûrürrrr¯s  zFirewallZone.remove_servicecCs(|jj|ƒ}|j|dƒ}|jjj||ƒS)NrG)rr<r(rZÚ query_service)rr/rûrürrrrýs  zFirewallZone.query_servicecCs&|jj|ƒ}|j|dƒ}|jjj|ƒS)NrG)rr<r(rZr�)rr/rürrrr�s  zFirewallZone.list_servicescCs2|jj|ƒ}|j|dƒ}|jjj|||||ƒ|S)NrG)rr<r(rZr°)rr/ÚportÚprotocolr‡r†rürrrr°#s  zFirewallZone.add_portcCs.|jj|ƒ}|j|dƒ}|jjj|||ƒ|S)NrG)rr<r(rZr±)rr/rþrÿrürrrr±)s  zFirewallZone.remove_portcCs*|jj|ƒ}|j|dƒ}|jjj|||ƒS)NrG)rr<r(rZÚ query_port)rr/rþrÿrürrrr/s  zFirewallZone.query_portcCs&|jj|ƒ}|j|dƒ}|jjj|ƒS)NrG)rr<r(rZrž)rr/rürrrrž4s  zFirewallZone.list_portscCs2|jj|ƒ}|j|dƒ}|jjj|||||ƒ|S)NrG)rr<r(rZr¼)rr/Ú source_portrÿr‡r†rürrrr¼9s  zFirewallZone.add_source_portcCs.|jj|ƒ}|j|dƒ}|jjj|||ƒ|S)NrG)rr<r(rZr½)rr/rrÿrürrrr½?s  zFirewallZone.remove_source_portcCs*|jj|ƒ}|j|dƒ}|jjj|||ƒS)NrG)rr<r(rZÚquery_source_port)rr/rrÿrürrrrEs  zFirewallZone.query_source_portcCs&|jj|ƒ}|j|dƒ}|jjj|ƒS)NrG)rr<r(rZr¤)rr/rürrrr¤Js  zFirewallZone.list_source_portscCsà|jj|ƒ}t|jƒtkr(|j|dƒgSt|jƒttt t gkrL|j|dƒgSt|jƒt t gkrv|j|dƒ|j|dƒgSt|jƒt gkr”|j|dƒgSt|jƒtgkr²|jd|ƒgS|jdkrÊ|j|dƒgStdt|jƒƒ‚dS)NrHrGz Rich rule type (%s) not handled.)rr<ÚtypeÚactionrr(Úelementrr r r r rr rr)rr/rSrrrrPOs    z#FirewallZone._rich_rule_to_policiescCs.x(|j||ƒD]}|jjj||||ƒqW|S)N)rPrrZr©)rr/rSr‡r†rürrrr©bszFirewallZone.add_rulecCs*x$|j||ƒD]}|jjj||ƒqW|S)N)rPrrZr«)rr/rSrürrrr«gszFirewallZone.remove_rulecCs2d}x(|j||ƒD]}|o(|jjj||ƒ}qW|S)NT)rPrrZÚ query_rule)rr/rSr‰rürrrrlszFirewallZone.query_rulecCs^|jj|ƒ}tƒ}xB|j|dƒ|j|dƒ|jd|ƒgD]}|jt|jjj|ƒƒƒq6Wt|ƒS)NrHrG)rr<Úsetr(ÚupdaterZr¢rÁ)rr/r‰rürrrr¢rs   zFirewallZone.list_rulescCs0|jj|ƒ}|j|dƒ}|jjj||||ƒ|S)NrG)rr<r(rZrº)rr/rÿr‡r†rürrrrº{s  zFirewallZone.add_protocolcCs,|jj|ƒ}|j|dƒ}|jjj||ƒ|S)NrG)rr<r(rZr»)rr/rÿrürrrr»�s  zFirewallZone.remove_protocolcCs(|jj|ƒ}|j|dƒ}|jjj||ƒS)NrG)rr<r(rZÚquery_protocol)rr/rÿrürrrr ‡s  zFirewallZone.query_protocolcCs&|jj|ƒ}|j|dƒ}|jjj|ƒS)NrG)rr<r(rZr£)rr/rürrrr£Œs  zFirewallZone.list_protocolscCs.|jj|ƒ}|jd|ƒ}|jjj|||ƒ|S)NrH)rr<r(rZr´)rr/r‡r†rürrrr´‘s  zFirewallZone.add_masqueradecCs*|jj|ƒ}|jd|ƒ}|jjj|ƒ|S)NrH)rr<r(rZrµ)rr/rürrrrµ—s  zFirewallZone.remove_masqueradecCs&|jj|ƒ}|jd|ƒ}|jjj|ƒS)NrH)rr<r(rZr )rr/rürrrr �s  zFirewallZone.query_masqueradec Cs6|jj|ƒ}|j|dƒ}|jjj|||||||ƒ|S)NrH)rr<r(rZr¶) rr/rþrÿÚtoportÚtoaddrr‡r†rürrrr¶¢s   zFirewallZone.add_forward_portcCs2|jj|ƒ}|j|dƒ}|jjj|||||ƒ|S)NrH)rr<r(rZr·)rr/rþrÿr r rürrrr·ªs  z FirewallZone.remove_forward_portcCs.|jj|ƒ}|j|dƒ}|jjj|||||ƒS)NrH)rr<r(rZÚquery_forward_port)rr/rþrÿr r rürrrr ±s  zFirewallZone.query_forward_portcCs&|jj|ƒ}|j|dƒ}|jjj|ƒS)NrH)rr<r(rZr¡)rr/rürrrr¡¸s  zFirewallZone.list_forward_portscCsP|jj|ƒ}|j|dƒ}|jjj||||ƒ|j|dƒ}|jjj||||ƒ|S)NrGrH)rr<r(rZr²)rr/Úicmpr‡r†rürrrr²½s    zFirewallZone.add_icmp_blockcCsH|jj|ƒ}|j|dƒ}|jjj||ƒ|j|dƒ}|jjj||ƒ|S)NrGrH)rr<r(rZr³)rr/r rürrrr³Æs    zFirewallZone.remove_icmp_blockcCsD|jj|ƒ}|j|dƒ}|j|dƒ}|jjj||ƒoB|jjj||ƒS)NrGrH)rr<r(rZÚquery_icmp_block)rr/r Ú p_name_hostÚ p_name_fwdrrrrÏs    zFirewallZone.query_icmp_blockcCsH|jj|ƒ}|j|dƒ}|j|dƒ}tt|jjj|ƒ|jjj|ƒƒƒS)NrGrH)rr<r(r)rrZrŸ)rr/rrrrrrŸÖs    zFirewallZone.list_icmp_blockscCsH|jj|ƒ}|j|dƒ}|jjj||ƒ|j|dƒ}|jjj||ƒ|S)NrGrH)rr<r(rZrb)rr/r†rürrrrbÝs    z%FirewallZone.add_icmp_block_inversioncCsL|jj|ƒ}|j|dƒ}|jjj|||ƒ|j|dƒ}|jjj|||ƒdS)NrGrH)rr<r(rZr�)rrŽr/r„rürrrr�æs    z"FirewallZone._icmp_block_inversioncCsD|jj|ƒ}|j|dƒ}|jjj|ƒ|j|dƒ}|jjj|ƒ|S)NrGrH)rr<r(rZr¾)rr/rürrrr¾îs    z(FirewallZone.remove_icmp_block_inversioncCs@|jj|ƒ}|j|dƒ}|j|dƒ}|jjj|ƒo>|jjj|ƒS)NrGrH)rr<r(rZr¥)rr/rrrrrr¥÷s    z'FirewallZone.query_icmp_block_inversionc CsÒ|j|dƒ}xT|j|jdD]@}x:|jjƒD],}|js:q.|j|||d|d�}|j||ƒq.WqWxj|j|jdD]V\}} xL|r�|jj|ƒgn|jjƒD],}|js¦qš|j|||d| d�}|j||ƒqšWqtWdS)NrHr1rä)r4r7)r9) r(rr3rrérêrírìrú) rrŽr/r„rür4rórEr‚r9rrrÚ_forwardþs "zFirewallZone._forwardcCsdS)NTr)rrrrZ __forward_idszFirewallZone.__forward_idc Cs²|jj|ƒ}|jj|ƒ|jjƒ|j|}|jƒ}||jdkrRttj d|ƒ‚|dkrd|j ƒ}n|}|j r||j d||ƒ|j ||||ƒ|j|j||ƒ|dkr®|jdƒ|S)NrYzforward already enabled in '%s'T)rr<Z check_timeoutrÆrÚ_FirewallZone__forward_idr3rrZALREADY_ENABLEDr$rdrÚ_FirewallZone__register_forwardrÉÚ!_FirewallZone__unregister_forwardr�) rr/r‡r†rgr“rÄÚ forward_idr„rrrras$       zFirewallZone.add_forwardcCs|j||ƒ|jd|<dS)NrY)rÎr3)rrÄrr‡r†rrrZ__register_forward.szFirewallZone.__register_forwardcCs–|jj|ƒ}|jjƒ|j|}|jƒ}||jdkrFttjd|ƒ‚|dkrX|j ƒ}n|}|j rp|j d||ƒ|j |j ||ƒ|dkr’|jdƒ|S)NrYzforward not enabled in '%s'FT)rr<rÆrrr3rrZ NOT_ENABLEDr$rdrrÔrr�)rr/rgr“rÄrr„rrrr¿2s       zFirewallZone.remove_forwardcCs||jdkr|jd|=dS)NrY)r3)rrÄrrrrZ__unregister_forwardKsz!FirewallZone.__unregister_forwardcCs|jƒ|j|ƒdkS)NrY)rrŠ)rr/rrrr¦OszFirewallZone.query_forward)N)N)N)N)NNT)N)N)N)F)F)NNT)N)N)F)rN)rN)rN)rN)rN)rN)NNrN)NN)NN)rN)N)rNN)N)eÚ__name__Ú __module__Ú __qualname__rJrr!r#r$r(r+r0r6r;r>rTr]r[rfrkrlrxr~r…rÎrŠr‘rjreršr–rÂrÃrÅr2r_rÊrÑrÓr¸rËrÕr,rÛr8r`rÝrßr¹rÞràr-r‹rÚrôrùrÙrØrŒr®r¯rýr�r°r±rržr¼r½rr¤rPr©r«rr¢rºr»r r£r´rµr r¶r·r r¡r²r³rrŸrbr�r¾r¥rrrarr¿rr¦rrrrr#sÐ&     8  (      &   ,(               r)"rˆrMZfirewall.core.baserrrZfirewall.core.fw_transactionrZfirewall.core.io.policyrZfirewall.core.loggerrr­rr r r r r rrrZfirewall.functionsrrrZfirewallrZfirewall.errorsrZfirewall.fw_typesrÚobjectrrrrrÚs   ,