<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
YjW                 @   s   d dl mZ d dlZeejd< d dlZd dlZd dlZd dlZd dl	m
Z
 d dlmZmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZ d dl	mZ d dlmZ d dl m!Z!m"Z"m#Z#m$Z$ G dd dejj%j&Z'dS )    )GObjectNZgobject)config)dbus_to_python%dbus_introspection_prepare_properties!dbus_introspection_add_properties)Zone)ifcfg_set_zone_of_interface)DEFAULT_ZONE_TARGET)	Rich_Rule)log)handle_exceptionsdbus_handle_exceptionsdbus_service_method)errors)FirewallError)portStrportInPortRangecoalescePortRangebreakPortRangec                   s	  e Zd ZdZdZejjZe	 fddZ
edd Zedd Zed	d
 ZeejdddedddZeejdddedddZejjjejjeejddedddZejjejdddd Zejjjejjeejdded fdd	Zeejjd dedd!d"Zeejjddedd#d$Zd%d& Z eejjd dedd'd(Z!eejjddedd)d*Z"eejjedd+d,Z#ejjejjdded-d. Z$eejjedd/d0Z%ejjejjdded1d2 Z&eejjddedd3d4Z'ejjejjdded5d6 Z(eejjddedd7d8Z)eejjddedd9d:Z*eejjddedd;d<Z+eejjddedd=d>Z,eejjddedd?d@Z-eejjddeddAdBZ.eejjddeddCdDZ/eejjddeddEdFZ0eejjdGdeddHdIZ1eejjdGdeddJdKZ2eejjddeddLdMZ3eejjddeddNdOZ4eejjddPdeddQdRZ5eejjdSdeddTdUZ6eejjdSdeddVdWZ7eejjddeddXdYZ8eejjddeddZd[Z9eejjddPdedd\d]Z:eejjdGdedd^d_Z;eejjdGdedd`daZ<eejjddeddbdcZ=eejjddeddddeZ>eejjddPdeddfdgZ?eejjdSdeddhdiZ@eejjdSdeddjdkZAeejjddeddldmZBeejjddeddndoZCeejjddPdeddpdqZDeejjdGdeddrdsZEeejjdGdeddtduZFeejjddeddvdwZGeejjddeddxdyZHeejjddPdeddzd{ZIeejjdPdedd|d}ZJeejjdPdedd~dZKeejjedddZLeejjedddZMeejjdPdedddZNeejjdPdedddZOeejjdPdedddZPeejjedddZQeejjedddZReejjdPdedddZSeejjddedddZTeejjddedddZUeejjddedddZVeejjddedddZWeejjddPdedddZXeejjdGdedddZYeejjdGdedddZZeejjddedddZ[eejjddedddZ\eejjddPdedddZ]eejjdGdedddZ^eejjdGdedddZ_eejjddedddZ`eejjddedddZaeejjddPdedddZbeejjdGdedddZceejjdGded ddZdeejjddedddZeeejjddedddZfeejjddPdedddZg  ZhS (  FirewallDConfigZonezFirewallD main classTc                s\   t t| j|| || _|| _|| _|| _|d | _|d | _d| j | _	t
| tjj d S )Nr      zconfig.zone.%d)superr   __init__parentr   objitem_idbusnamepath_log_prefixr   dbusDBUS_INTERFACE_CONFIG_ZONE)selfr   ZconfZzoner   argskwargs)	__class__ !/usr/lib/python3.6/config_zone.pyr   =   s    

zFirewallDConfigZone.__init__c             C   s   d S )Nr%   )r!   r%   r%   r&   __del__J   s    zFirewallDConfigZone.__del__c             C   s   | j   d S )N)Zremove_from_connection)r!   r%   r%   r&   
unregisterN   s    zFirewallDConfigZone.unregisterc             C   s   |dkrt j| jjS |dkr,t j| jjS |dkrBt j| jjS |dkrXt j| jjS |dkrnt j| jjS t j	j
d| d S )Nnamefilenamer   defaultbuiltinzDorg.freedesktop.DBus.Error.InvalidArgs: Property '%s' does not exist)r   Stringr   r)   r*   r   ZBooleanr+   r,   
exceptionsDBusException)r!   property_namer%   r%   r&   _get_propertyV   s    z!FirewallDConfigZone._get_propertyZssv)in_signatureout_signatureNc             C   sL   t |t}t |t}tjd| j|| |tjjkrBtjj	d| | j
|S )Nz%s.Get('%s', '%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not exist)r   strr   debug1r   r   r   r    r.   r/   r1   )r!   interface_namer0   senderr%   r%   r&   Getg   s    


zFirewallDConfigZone.Getsza{sv}c             C   sd   t |t}tjd| j| |tjjkr6tjj	d| i }xd
D ]}| j
|||< q@W tj|dd	S )Nz%s.GetAll('%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not existr)   r*   r   r+   r,   Zsv)	signature)r)   r*   r   r+   r,   )r   r5   r   r6   r   r   r   r    r.   r/   r1   Z
Dictionary)r!   r7   r8   retxr%   r%   r&   GetAllx   s    

zFirewallDConfigZone.GetAllZssv)r3   c             C   sl   t |t}t |t}t |}tjd| j||| | jj| |tjj	krXtj
jd| tj
jd| d S )Nz%s.Set('%s', '%s', '%s')zJorg.freedesktop.DBus.Error.UnknownInterface: Interface '%s' does not existzGorg.freedesktop.DBus.Error.PropertyReadOnly: Property '%s' is read-only)r   r5   r   r6   r   r   accessCheckr   r   r    r.   r/   )r!   r7   r0   Z	new_valuer8   r%   r%   r&   Set   s    



zFirewallDConfigZone.Setzsa{sv}as)r;   c             C   s2   t |t}t |}t |}tjd| j||| d S )Nz&%s.PropertiesChanged('%s', '%s', '%s'))r   r5   r   r6   r   )r!   r7   Zchanged_propertiesZinvalidated_propertiesr%   r%   r&   PropertiesChanged   s
    

z%FirewallDConfigZone.PropertiesChanged)r4   c                s8   t jd| j tt| j| j| jj }t	| |t
jjS )Nz%s.Introspect())r   Zdebug2r   r   r   
Introspectr   r   Zget_busr   r   r   r    )r!   r8   data)r$   r%   r&   rB      s
    
zFirewallDConfigZone.Introspectz&(sssbsasa(ss)asba(ssss)asasasasa(ss)b)c             C   sD   t jd| j | jj| j}|d tkr@t|}d|d< t|}|S )zget settings for zone
        z%s.getSettings()   r+   )	r   r6   r   r   Zget_zone_configr   r	   listtuple)r!   r8   settings	_settingsr%   r%   r&   getSettings   s    zFirewallDConfigZone.getSettingsc             C   s4   t jd| j | jj| j}|d tkr0d|d< |S )zget settings for zone
        z%s.getSettings2()targetr+   )r   r6   r   r   get_zone_config_dictr   r	   )r!   r8   rG   r%   r%   r&   getSettings2   s
    z FirewallDConfigZone.getSettings2c             C   s  | j j| j}d|kr"t|d nt }d|kr<t|d nt }t|trzt|tjd | }t|tjd | }nDd|krt|d nt }d|krt|d nt }|| }|| }x$|D ]}	| jj	|	rt
tj|	qW x$|D ]}
| jj|
rt
tj|
qW dS )a  Assignment of interfaces/sources to zones is different from other
           zone settings in the sense that particular interface/zone can be
           part of only one zone. So make sure added interfaces/sources have
           not already been bound to another zone.
interfacessourcesN)r   rK   r   set
isinstancerF   r   Zindex_ofr   ZgetZoneOfInterfacer   r   ZZONE_CONFLICTZgetZoneOfSource)r!   rG   Zold_settingsZ
old_ifacesZold_sourcesZadded_ifacesZadded_sourcesZ
new_ifacesZnew_sourcesZifacesourcer%   r%   r&    _checkDuplicateInterfacesSources   s     


z4FirewallDConfigZone._checkDuplicateInterfacesSourcesc             C   st   t |}tjd| j | jj| |d dkrFt|}t|d< t|}| j	| | j
j| j|| _| j| jj dS )z!update settings for zone
        z%s.update('...')rD   r+   N)r   r   r6   r   r   r?   rE   r	   rF   rR   r   Zset_zone_configr   Updatedr)   )r!   rG   r8   rH   r%   r%   r&   update   s    
zFirewallDConfigZone.updatec             C   sl   t |}tjd| j | jj| d|kr>|d dkr>t|d< | j| | jj	| j
|| _
| j| j
j dS )z!update settings for zone
        z%s.update2('...')rJ   r+   N)r   r   r6   r   r   r?   r	   rR   r   Zset_zone_config_dictr   rS   r)   )r!   rG   r8   r%   r%   r&   update2   s    
zFirewallDConfigZone.update2c             C   s<   t jd| j | jj| | jj| j| _| j| jj	 dS )z/load default settings for builtin zone
        z%s.loadDefaults()N)
r   r6   r   r   r?   r   Zload_zone_defaultsr   rS   r)   )r!   r8   r%   r%   r&   loadDefaults  s    z FirewallDConfigZone.loadDefaultsc             C   s   t jd| j|f  d S )Nz%s.Updated('%s'))r   r6   r   )r!   r)   r%   r%   r&   rS     s    zFirewallDConfigZone.Updatedc             C   s:   t jd| j | jj| | jj| j | jj| j dS )zremove zone
        z%s.removeZone()N)	r   r6   r   r   r?   r   Zremove_zoner   Z
removeZone)r!   r8   r%   r%   r&   remove  s    zFirewallDConfigZone.removec             C   s   t jd| j|f  d S )Nz%s.Removed('%s'))r   r6   r   )r!   r)   r%   r%   r&   Removed#  s    zFirewallDConfigZone.Removedc             C   sF   t |t}tjd| j| | jj| | jj| j	|| _	| j
| dS )zrename zone
        z%s.rename('%s')N)r   r5   r   r6   r   r   r?   r   Zrename_zoner   Renamed)r!   r)   r8   r%   r%   r&   rename*  s
    
zFirewallDConfigZone.renamec             C   s   t jd| j|f  d S )Nz%s.Renamed('%s'))r   r6   r   )r!   r)   r%   r%   r&   rY   6  s    zFirewallDConfigZone.Renamedc             C   s   t jd| j | j d S )Nz%s.getVersion()r   )r   r6   r   rI   )r!   r8   r%   r%   r&   
getVersion=  s    zFirewallDConfigZone.getVersionc             C   sH   t |t}tjd| j| | jj| t| j }||d< | j	| d S )Nz%s.setVersion('%s')r   )
r   r5   r   r6   r   r   r?   rE   rI   rT   )r!   versionr8   rG   r%   r%   r&   
setVersionD  s    
zFirewallDConfigZone.setVersionc             C   s   t jd| j | j d S )Nz%s.getShort()r   )r   r6   r   rI   )r!   r8   r%   r%   r&   getShortQ  s    zFirewallDConfigZone.getShortc             C   sH   t |t}tjd| j| | jj| t| j }||d< | j	| d S )Nz%s.setShort('%s')r   )
r   r5   r   r6   r   r   r?   rE   rI   rT   )r!   Zshortr8   rG   r%   r%   r&   setShortX  s    
zFirewallDConfigZone.setShortc             C   s   t jd| j | j d S )Nz%s.getDescription()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getDescriptione  s    z"FirewallDConfigZone.getDescriptionc             C   sH   t |t}tjd| j| | jj| t| j }||d< | j	| d S )Nz%s.setDescription('%s')r`   )
r   r5   r   r6   r   r   r?   rE   rI   rT   )r!   descriptionr8   rG   r%   r%   r&   setDescriptionl  s    
z"FirewallDConfigZone.setDescriptionc             C   s.   t jd| j | j }|d tkr*|d S dS )Nz%s.getTarget()rD   r+   )r   r6   r   rI   r	   )r!   r8   rG   r%   r%   r&   	getTarget|  s    zFirewallDConfigZone.getTargetc             C   sT   t |t}tjd| j| | jj| t| j }|dkr>|nt	|d< | j
| d S )Nz%s.setTarget('%s')r+   rD   )r   r5   r   r6   r   r   r?   rE   rI   r	   rT   )r!   rJ   r8   rG   r%   r%   r&   	setTarget  s    
zFirewallDConfigZone.setTargetasc             C   s   t jd| j | j d S )Nz%s.getServices()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getServices  s    zFirewallDConfigZone.getServicesc             C   sN   t |t}tjd| jdj| | jj| t| j }||d< | j	| d S )Nz%s.setServices('[%s]'),rg   )
r   rE   r   r6   r   joinr   r?   rI   rT   )r!   Zservicesr8   rG   r%   r%   r&   setServices  s    

zFirewallDConfigZone.setServicesc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.addService('%s')rg   )r   r5   r   r6   r   r   r?   rE   rI   r   r   ALREADY_ENABLEDappendrT   )r!   servicer8   rG   r%   r%   r&   
addService  s    
zFirewallDConfigZone.addServicec             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.removeService('%s')rg   )r   r5   r   r6   r   r   r?   rE   rI   r   r   NOT_ENABLEDrW   rT   )r!   rn   r8   rG   r%   r%   r&   removeService  s    
z!FirewallDConfigZone.removeServicebc             C   s*   t |t}tjd| j| || j d kS )Nz%s.queryService('%s')rg   )r   r5   r   r6   r   rI   )r!   rn   r8   r%   r%   r&   queryService  s    
z FirewallDConfigZone.queryServiceza(ss)c             C   s   t jd| j | j d S )Nz%s.getPorts()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getPorts  s    zFirewallDConfigZone.getPortsc             C   s   g }x6t |tD ](}t|tr.|jt| q|j| qW |}tjd| jdjdd |D  | j	j
| t| j }||d< | j| d S )Nz%s.setPorts('[%s]')ri   c             s   s"   | ]}d |d |d f V  qdS )z('%s, '%s')r   r   Nr%   ).0portr%   r%   r&   	<genexpr>  s    z/FirewallDConfigZone.setPorts.<locals>.<genexpr>rt   )r   rE   rP   rm   rF   r   r6   r   rj   r   r?   rI   rT   )r!   portsr8   _portsrw   rG   r%   r%   r&   setPorts  s    

zFirewallDConfigZone.setPortsc       
         s   t |t}t  t tjd| j|  | jj| t| j }tt	 fdd|d }x.|D ]&}t
||d r^ttjd| f q^W t|dd |D \}}x$|D ]}	|d jt|	d	 f qW x$|D ]}	|d jt|	d	 f qW | j| d S )
Nz%s.addPort('%s', '%s')c                s   | d  kS )Nr   r%   )r=   )protocolr%   r&   <lambda>  s    z-FirewallDConfigZone.addPort.<locals>.<lambda>rt   r   z%s:%sc             S   s   g | ]\}}|qS r%   r%   )rv   _port	_protocolr%   r%   r&   
<listcomp>  s    z/FirewallDConfigZone.addPort.<locals>.<listcomp>-)r   r5   r   r6   r   r   r?   rE   rI   filterr   r   r   rl   r   rW   r   rm   rT   )
r!   rw   r|   r8   rG   existing_port_idsport_idadded_rangesremoved_rangesranger%   )r|   r&   addPort  s"    




zFirewallDConfigZone.addPortc       
         s   t |t}t  t tjd| j|  | jj| t| j }tt	 fdd|d }x0|D ]}t
||d r^P q^W ttjd| f t|dd |D \}}x$|D ]}	|d jt|	d	 f qW x$|D ]}	|d jt|	d	 f qW | j| d S )
Nz%s.removePort('%s', '%s')c                s   | d  kS )Nr   r%   )r=   )r|   r%   r&   r}     s    z0FirewallDConfigZone.removePort.<locals>.<lambda>rt   r   z%s:%sc             S   s   g | ]\}}|qS r%   r%   )rv   r~   r   r%   r%   r&   r     s    z2FirewallDConfigZone.removePort.<locals>.<listcomp>r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   r   r   rp   r   rW   r   rm   rT   )
r!   rw   r|   r8   rG   r   r   r   r   r   r%   )r|   r&   
removePort  s"    




zFirewallDConfigZone.removePortc             C   sZ   t |t}t |t}tjd| j|| x.| j d D ]\}}t||r4||kr4dS q4W dS )Nz%s.queryPort('%s', '%s')rt   TF)r   r5   r   r6   r   rI   r   )r!   rw   r|   r8   r~   r   r%   r%   r&   	queryPort  s    

zFirewallDConfigZone.queryPortc             C   s   t jd| j | j d S )Nz%s.getProtocols()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getProtocols  s    z FirewallDConfigZone.getProtocolsc             C   sN   t |t}tjd| jdj| | jj| t| j }||d< | j	| d S )Nz%s.setProtocols('[%s]')ri   r   )
r   rE   r   r6   r   rj   r   r?   rI   rT   )r!   Z	protocolsr8   rG   r%   r%   r&   setProtocols&  s    

z FirewallDConfigZone.setProtocolsc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.addProtocol('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rl   rm   rT   )r!   r|   r8   rG   r%   r%   r&   addProtocol2  s    
zFirewallDConfigZone.addProtocolc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.removeProtocol('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rp   rW   rT   )r!   r|   r8   rG   r%   r%   r&   removeProtocol?  s    
z"FirewallDConfigZone.removeProtocolc             C   s*   t |t}tjd| j| || j d kS )Nz%s.queryProtocol('%s')r   )r   r5   r   r6   r   rI   )r!   r|   r8   r%   r%   r&   queryProtocolL  s    
z!FirewallDConfigZone.queryProtocolc             C   s   t jd| j | j d S )Nz%s.getSourcePorts()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getSourcePortsV  s    z"FirewallDConfigZone.getSourcePortsc             C   s   g }x6t |tD ](}t|tr.|jt| q|j| qW |}tjd| jdjdd |D  | j	j
| t| j }||d< | j| d S )Nz%s.setSourcePorts('[%s]')ri   c             s   s"   | ]}d |d |d f V  qdS )z('%s, '%s')r   r   Nr%   )rv   rw   r%   r%   r&   rx   j  s    z5FirewallDConfigZone.setSourcePorts.<locals>.<genexpr>r   )r   rE   rP   rm   rF   r   r6   r   rj   r   r?   rI   rT   )r!   ry   r8   rz   rw   rG   r%   r%   r&   setSourcePorts]  s    

z"FirewallDConfigZone.setSourcePortsc       
         s   t |t}t  t tjd| j|  | jj| t| j }tt	 fdd|d }x.|D ]&}t
||d r^ttjd| f q^W t|dd |D \}}x$|D ]}	|d jt|	d	 f qW x$|D ]}	|d jt|	d	 f qW | j| d S )
Nz%s.addSourcePort('%s', '%s')c                s   | d  kS )Nr   r%   )r=   )r|   r%   r&   r}   z  s    z3FirewallDConfigZone.addSourcePort.<locals>.<lambda>r   r   z%s:%sc             S   s   g | ]\}}|qS r%   r%   )rv   r~   r   r%   r%   r&   r     s    z5FirewallDConfigZone.addSourcePort.<locals>.<listcomp>r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   r   r   rl   r   rW   r   rm   rT   )
r!   rw   r|   r8   rG   r   r   r   r   r   r%   )r|   r&   addSourcePortp  s"    




z!FirewallDConfigZone.addSourcePortc       
         s   t |t}t  t tjd| j|  | jj| t| j }tt	 fdd|d }x0|D ]}t
||d r^P q^W ttjd| f t|dd |D \}}x$|D ]}	|d jt|	d	 f qW x$|D ]}	|d jt|	d	 f qW | j| d S )
Nz%s.removeSourcePort('%s', '%s')c                s   | d  kS )Nr   r%   )r=   )r|   r%   r&   r}     s    z6FirewallDConfigZone.removeSourcePort.<locals>.<lambda>r   r   z%s:%sc             S   s   g | ]\}}|qS r%   r%   )rv   r~   r   r%   r%   r&   r     s    z8FirewallDConfigZone.removeSourcePort.<locals>.<listcomp>r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   r   r   rp   r   rW   r   rm   rT   )
r!   rw   r|   r8   rG   r   r   r   r   r   r%   )r|   r&   removeSourcePort  s"    




z$FirewallDConfigZone.removeSourcePortc             C   sZ   t |t}t |t}tjd| j|| x.| j d D ]\}}t||r4||kr4dS q4W dS )Nz%s.querySourcePort('%s', '%s')r   TF)r   r5   r   r6   r   rI   r   )r!   rw   r|   r8   r~   r   r%   r%   r&   querySourcePort  s    

z#FirewallDConfigZone.querySourcePortc             C   s   t jd| j | j d S )Nz%s.getIcmpBlocks()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getIcmpBlocks  s    z!FirewallDConfigZone.getIcmpBlocksc             C   sN   t |t}tjd| jdj| | jj| t| j }||d< | j	| d S )Nz%s.setIcmpBlocks('[%s]')ri   r   )
r   rE   r   r6   r   rj   r   r?   rI   rT   )r!   Z	icmptypesr8   rG   r%   r%   r&   setIcmpBlocks  s    

z!FirewallDConfigZone.setIcmpBlocksc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.addIcmpBlock('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rl   rm   rT   )r!   icmptyper8   rG   r%   r%   r&   addIcmpBlock  s    
z FirewallDConfigZone.addIcmpBlockc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.removeIcmpBlock('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rp   rW   rT   )r!   r   r8   rG   r%   r%   r&   removeIcmpBlock  s    
z#FirewallDConfigZone.removeIcmpBlockc             C   s*   t |t}tjd| j| || j d kS )Nz%s.queryIcmpBlock('%s')r   )r   r5   r   r6   r   rI   )r!   r   r8   r%   r%   r&   queryIcmpBlock  s    
z"FirewallDConfigZone.queryIcmpBlockc             C   s   t jd| j | j d S )Nz%s.getIcmpBlockInversion()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getIcmpBlockInversion  s    z)FirewallDConfigZone.getIcmpBlockInversionc             C   sH   t |t}tjd| j| | jj| t| j }||d< | j	| d S )Nz%s.setIcmpBlockInversion('%s')r   )
r   boolr   r6   r   r   r?   rE   rI   rT   )r!   flagr8   rG   r%   r%   r&   setIcmpBlockInversion  s    
z)FirewallDConfigZone.setIcmpBlockInversionc             C   sP   t jd| j | jj| t| j }|d r:ttj	dd|d< | j
| d S )Nz%s.addIcmpBlockInversion()r   zicmp-block-inversionT)r   r6   r   r   r?   rE   rI   r   r   rl   rT   )r!   r8   rG   r%   r%   r&   addIcmpBlockInversion  s    z)FirewallDConfigZone.addIcmpBlockInversionc             C   sP   t jd| j | jj| t| j }|d s:ttj	dd|d< | j
| d S )Nz%s.removeIcmpBlockInversion()r   zicmp-block-inversionF)r   r6   r   r   r?   rE   rI   r   r   rp   rT   )r!   r8   rG   r%   r%   r&   removeIcmpBlockInversion  s    z,FirewallDConfigZone.removeIcmpBlockInversionc             C   s   t jd| j | j d S )Nz%s.queryIcmpBlockInversion()r   )r   r6   r   rI   )r!   r8   r%   r%   r&   queryIcmpBlockInversion  s    z+FirewallDConfigZone.queryIcmpBlockInversionc             C   s   t jd| j | j d S )Nz%s.getMasquerade()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getMasquerade  s    z!FirewallDConfigZone.getMasqueradec             C   sH   t |t}tjd| j| | jj| t| j }||d< | j	| d S )Nz%s.setMasquerade('%s')r   )
r   r   r   r6   r   r   r?   rE   rI   rT   )r!   
masquerader8   rG   r%   r%   r&   setMasquerade  s    
z!FirewallDConfigZone.setMasqueradec             C   sP   t jd| j | jj| t| j }|d r:ttj	dd|d< | j
| d S )Nz%s.addMasquerade()r   r   T)r   r6   r   r   r?   rE   rI   r   r   rl   rT   )r!   r8   rG   r%   r%   r&   addMasquerade'  s    z!FirewallDConfigZone.addMasqueradec             C   sP   t jd| j | jj| t| j }|d s:ttj	dd|d< | j
| d S )Nz%s.removeMasquerade()r   r   F)r   r6   r   r   r?   rE   rI   r   r   rp   rT   )r!   r8   rG   r%   r%   r&   removeMasquerade2  s    z$FirewallDConfigZone.removeMasqueradec             C   s   t jd| j | j d S )Nz%s.queryMasquerade()r   )r   r6   r   rI   )r!   r8   r%   r%   r&   queryMasquerade=  s    z#FirewallDConfigZone.queryMasqueradeza(ssss)c             C   s   t jd| j | j d S )Nz%s.getForwardPorts()	   )r   r6   r   rI   )r!   r8   r%   r%   r&   getForwardPortsF  s    z#FirewallDConfigZone.getForwardPortsc             C   s   g }x6t |tD ](}t|tr.|jt| q|j| qW |}tjd| jdjdd |D  | j	j
| t| j }||d< | j| d S )Nz%s.setForwardPorts('[%s]')ri   c             s   s.   | ]&}d |d |d |d |d f V  qdS )z('%s, '%s', '%s', '%s')r   r   r`      Nr%   )rv   rw   r%   r%   r&   rx   Z  s   z6FirewallDConfigZone.setForwardPorts.<locals>.<genexpr>r   )r   rE   rP   rm   rF   r   r6   r   rj   r   r?   rI   rT   )r!   ry   r8   rz   rw   rG   r%   r%   r&   setForwardPortsM  s    


z#FirewallDConfigZone.setForwardPortsZssssc             C   s   t |t}t |t}t |t}t |t}tjd| j|||| | jj| ||t|t|f}t| j }||d krt	t
jd||||f |d j| | j| d S )Nz)%s.addForwardPort('%s', '%s', '%s', '%s')r   z%s:%s:%s:%s)r   r5   r   r6   r   r   r?   rE   rI   r   r   rl   rm   rT   )r!   rw   r|   toporttoaddrr8   fwp_idrG   r%   r%   r&   addForwardPorta  s    




z"FirewallDConfigZone.addForwardPortc             C   s   t |t}t |t}t |t}t |t}tjd| j|||| | jj| ||t|t|f}t| j }||d krt	t
jd||||f |d j| | j| d S )Nz,%s.removeForwardPort('%s', '%s', '%s', '%s')r   z%s:%s:%s:%s)r   r5   r   r6   r   r   r?   rE   rI   r   r   rp   rW   rT   )r!   rw   r|   r   r   r8   r   rG   r%   r%   r&   removeForwardPortu  s    




z%FirewallDConfigZone.removeForwardPortc             C   sb   t |t}t |t}t |t}t |t}tjd| j|||| ||t|t|f}|| j d kS )Nz+%s.queryForwardPort('%s', '%s', '%s', '%s')r   )r   r5   r   r6   r   rI   )r!   rw   r|   r   r   r8   r   r%   r%   r&   queryForwardPort  s    



z$FirewallDConfigZone.queryForwardPortc             C   s   t jd| j | j d S )Nz%s.getInterfaces()
   )r   r6   r   rI   )r!   r8   r%   r%   r&   getInterfaces  s    z!FirewallDConfigZone.getInterfacesc             C   sN   t |t}tjd| jdj| | jj| t| j }||d< | j	| d S )Nz%s.setInterfaces('[%s]')ri   r   )
r   rE   r   r6   r   rj   r   r?   rI   rT   )r!   rM   r8   rG   r%   r%   r&   setInterfaces  s    

z!FirewallDConfigZone.setInterfacesc             C   st   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| t| jj| d S )Nz%s.addInterface('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rl   rm   rT   r   r   r)   )r!   	interfacer8   rG   r%   r%   r&   addInterface  s    

z FirewallDConfigZone.addInterfacec             C   sp   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| td| d S )Nz%s.removeInterface('%s')r    )r   r5   r   r6   r   r   r?   rE   rI   r   r   rp   rW   rT   r   )r!   r   r8   rG   r%   r%   r&   removeInterface  s    

z#FirewallDConfigZone.removeInterfacec             C   s*   t |t}tjd| j| || j d kS )Nz%s.queryInterface('%s')r   )r   r5   r   r6   r   rI   )r!   r   r8   r%   r%   r&   queryInterface  s    
z"FirewallDConfigZone.queryInterfacec             C   s   t jd| j | j d S )Nz%s.getSources()   )r   r6   r   rI   )r!   r8   r%   r%   r&   
getSources  s    zFirewallDConfigZone.getSourcesc             C   sN   t |t}tjd| jdj| | jj| t| j }||d< | j	| d S )Nz%s.setSources('[%s]')ri   r   )
r   rE   r   r6   r   rj   r   r?   rI   rT   )r!   rN   r8   rG   r%   r%   r&   
setSources  s    

zFirewallDConfigZone.setSourcesc             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.addSource('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rl   rm   rT   )r!   rQ   r8   rG   r%   r%   r&   	addSource  s    
zFirewallDConfigZone.addSourcec             C   sf   t |t}tjd| j| | jj| t| j }||d krJt	t
j||d j| | j| d S )Nz%s.removeSource('%s')r   )r   r5   r   r6   r   r   r?   rE   rI   r   r   rp   rW   rT   )r!   rQ   r8   rG   r%   r%   r&   removeSource  s    
z FirewallDConfigZone.removeSourcec             C   s*   t |t}tjd| j| || j d kS )Nz%s.querySource('%s')r   )r   r5   r   r6   r   rI   )r!   rQ   r8   r%   r%   r&   querySource  s    
zFirewallDConfigZone.querySourcec             C   s   t jd| j | j d S )Nz%s.getRichRules()   )r   r6   r   rI   )r!   r8   r%   r%   r&   getRichRules  s    z FirewallDConfigZone.getRichRulesc             C   s\   t |t}tjd| jdj| | jj| t| j }dd |D }||d< | j	| d S )Nz%s.setRichRules('[%s]')ri   c             S   s   g | ]}t t|d qS ))rule_str)r5   r
   )rv   rr%   r%   r&   r     s    z4FirewallDConfigZone.setRichRules.<locals>.<listcomp>r   )
r   rE   r   r6   r   rj   r   r?   rI   rT   )r!   Zrulesr8   rG   r%   r%   r&   setRichRules  s    

z FirewallDConfigZone.setRichRulesc             C   st   t |t}tjd| j| | jj| t| j }tt	|d}||d krXt
tj||d j| | j| d S )Nz%s.addRichRule('%s'))r   r   )r   r5   r   r6   r   r   r?   rE   rI   r
   r   r   rl   rm   rT   )r!   ruler8   rG   r   r%   r%   r&   addRichRule   s    
zFirewallDConfigZone.addRichRulec             C   st   t |t}tjd| j| | jj| t| j }tt	|d}||d krXt
tj||d j| | j| d S )Nz%s.removeRichRule('%s'))r   r   )r   r5   r   r6   r   r   r?   rE   rI   r
   r   r   rp   rW   rT   )r!   r   r8   rG   r   r%   r%   r&   removeRichRule.  s    
z"FirewallDConfigZone.removeRichRulec             C   s8   t |t}tjd| j| tt|d}|| j d kS )Nz%s.queryRichRule('%s'))r   r   )r   r5   r   r6   r   r
   rI   )r!   r   r8   r   r%   r%   r&   queryRichRule<  s    
z!FirewallDConfigZone.queryRichRule)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)i__name__
__module____qualname____doc__Z
persistentr   r   ZPK_ACTION_CONFIGZdefault_polkit_auth_requiredr   r   r   r'   r(   r1   r   ZPROPERTIES_IFACEr9   r>   slipZpolkitZrequire_authr@   rn   signalrA   ZPK_ACTION_INFOZINTROSPECTABLE_IFACErB   r    rI   rL   rR   rT   rU   rV   rS   rW   rX   rZ   rY   r[   r]   r^   r_   ra   rc   rd   re   rh   rk   ro   rq   rs   ru   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   __classcell__r%   r%   )r$   r&   r   5   sf  		

	


	

	

	


	
	
	
			


r   )(Zgi.repositoryr   sysmodulesr   Zdbus.serviceZ	slip.dbusr   Zslip.dbus.serviceZfirewallr   Zfirewall.dbus_utilsr   r   r   Zfirewall.core.io.zoner   Zfirewall.core.fw_ifcfgr   Zfirewall.core.baser	   Zfirewall.core.richr
   Zfirewall.core.loggerr   Zfirewall.server.decoratorsr   r   r   r   Zfirewall.errorsr   Zfirewall.functionsr   r   r   r   rn   ZObjectr   r%   r%   r%   r&   <module>   s$   
	