관리-도구
편집 파일: fw_policy.cpython-36.pyc
3 @)�f=V � @ s� d dl Z d dlZd dlmZ d dlmZmZmZmZm Z m Z mZmZm Z mZ d dlmZmZmZmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlm Z d dl!m"Z" d d l#m$Z$ G d d� de%�Z&dS )� N)�log) �portStr�checkIPnMask� checkIP6nMask� checkProtocol�enable_ip_forwarding�check_single_address�portInPortRange�get_nf_conntrack_short_name�coalescePortRange�breakPortRange)� Rich_Rule�Rich_Accept�Rich_Service� Rich_Port� Rich_Protocol�Rich_Masquerade�Rich_ForwardPort�Rich_SourcePort�Rich_IcmpBlock� Rich_IcmpType� Rich_Mark)�FirewallTransaction)�errors)� FirewallError)�LastUpdatedOrderedDict)�SOURCE_IPSET_TYPESc @ s� e Zd Zdd� Zdd� Zdd� Zdd� Zd d � Zdd� Zd d� Z dd� Z dd� Zdd� Zdd� Z �ddd�Zdd� Zdd� Zdd� Z�dd d!�Z�d d"d#�Z�dd$d%�Zd&d'� Zd(d)� Zd*d+� Zd,d-� Z�dd0d1�Zd2d3� Z�dd4d5�Zd6d7� Zd8d9� Zd:d;� Zd<d=� Zd>d?� Z �dd@dA�Z!dBdC� Z"�ddDdE�Z#dFdG� Z$dHdI� Z%dJdK� Z&dLdM� Z'dNdO� Z(dPdQ� Z)dRdS� Z*�ddTdU�Z+dVdW� Z,�ddXdY�Z-dZd[� Z.d\d]� Z/d^d_� Z0d`da� Z1dbdc� Z2�dddde�Z3dfdg� Z4�ddhdi�Z5djdk� Z6dldm� Z7dndo� Z8dpdq� Z9drds� Z:dtdu� Z;dvdw� Z<�ddxdy�Z=dzd{� Z>�dd|d}�Z?d~d� Z@d�d�� ZAd�d�� ZBd�d�� ZCd�d�� ZD�dd�d��ZEd�d�� ZF�dd�d��ZGd�d�� ZHd�d�� ZId�d�� ZJd�d�� ZK�dd�d��ZLd�d�� ZM�dd�d��ZNd�d�� ZOd�d�� ZPd�d�� ZQd�d�� ZR�dd�d��ZSd�d�� ZT�dd�d��ZUd�d�� ZVd�d�� ZW�dd�d��ZX�d d�d��ZY�d!d�d��ZZd�d�� Z[�d"d�d��Z\d�d�� Z]�d#d�d��Z^d�d�� Z_d�d�� Z`d�d�� Za�d$d�dÄZbd�dń Zc�d%d�dDŽZdd�dɄ Zed�d˄ Zfd�d̈́ Zgd�dτ Zh�d&d�dфZid�dӄ Zjd�dՄ Zk�d'd�dׄZld�dل Zmd�dۄ Znd�d݄ Zod�d߄ Zpd�d� Zqd�d� Zrd�d� Zsd�d� Ztd�d� Zu�d(d�d�Zv�d)d�d�Zwd�d� Zxd�d� Zyd�d� Zzd�d�� Z{�d*d�d��Z|d�d�� Z}d�d�� Z~d�d�� Zd�d�� Z��d �d� Z��d�d� Z��d�d� Z��d�d� Z��d+�d �d �Z�dS (, �FirewallPolicyc C s || _ i | _i | _d S )N)�_fw�_chains� _policies)�self�fw� r# �/usr/lib/python3.6/fw_policy.py�__init__ s zFirewallPolicy.__init__c C s d| j | j| jf S )Nz %s(%r, %r))� __class__r r )r! r# r# r$ �__repr__ s zFirewallPolicy.__repr__c C s | j j� | jj� d S )N)r �clearr )r! r# r# r$ �cleanup s zFirewallPolicy.cleanupc C s t | j�S )N)r r )r! r# r# r$ �new_transaction$ s zFirewallPolicy.new_transactionc C s t | jj� �S )N)�sortedr �keys)r! r# r# r$ �get_policies) s zFirewallPolicy.get_policiesc C s8 g }x*| j � D ]}| j|�}|js|j|� qW t|�S )N)r- � get_policy�derived_from_zone�appendr+ )r! Zpolicies�p�p_objr# r# r$ �"get_policies_not_derived_from_zone, s z1FirewallPolicy.get_policies_not_derived_from_zonec C s~ g }xt| j � D ]h}| j|�}t|d �t| jjj� �tddg�B @ rt|d �t| jjj� �tddg�B @ r|j|� qW |S )N� ingress_zones�HOST�ANY�egress_zones)r3 �get_settings�setr �zoneZget_active_zonesr0 )r! Zactive_policies�policy�settingsr# r# r$ �)get_active_policies_not_derived_from_zone4 s ((z8FirewallPolicy.get_active_policies_not_derived_from_zonec C s | j j|�}| j| S )N)r �check_policyr )r! r; r1 r# r# r$ r. >