관리-도구
편집 파일: direct.cpython-36.pyc
3 @)�f�= � @ s� d dl jZd dlZd dlZd dlZd dlmZ d dlmZ d dl m Z mZmZ d dl mZmZmZ d dlmZ d dlmZ d dlmZ d d lmZ d d lmZ G dd� de�ZG d d� de�ZdS )� N)�config)�LastUpdatedOrderedDict)� splitArgs�joinArgs� u2b_if_py2)� IO_Object�IO_Object_ContentHandler�IO_Object_XMLGenerator)�log)� ipXtables)�ebtables)�errors)� FirewallErrorc @ s$ e Zd Zdd� Zdd� Zdd� ZdS )�direct_ContentHandlerc C s t j| |� d| _d S )NF)r �__init__�direct)�self�item� r �/usr/lib/python3.6/direct.pyr ( s zdirect_ContentHandler.__init__c C s� t j| ||� | jj||� |dkr@| jr6ttjd��d| _�n>|dkr�| js\tj d� d S |d }|d }|d }| jj t|�t|�t|�� n�|dk�r6| js�tj d � d S |d }|dkr�ttjd | ��|d }|d }yt |d �}W n( tk �r tj d|d � d S X t|�t|�t|�|g| _nH|dk�rl| j�sVtj d� d S |d }t|�g| _ntj d| � d S d S )Nr zMore than one direct tag.T�chainz$Parse Error: chain outside of direct�ipv�table�rulez#Parse Error: rule outside of direct�ipv4�ipv6�ebz"'%s' not from {'ipv4'|'ipv6'|'eb'}�priorityz'Parse Error: %s is not a valid priority�passthroughz&Parse Error: command outside of directzUnknown XML element %s)r r r )r �startElementr Zparser_check_element_attrsr r r ZPARSE_ERRORr �error� add_chainr �INVALID_IPV�int� ValueError�_rule�_passthrough)r �nameZattrsr r r r r r r r , sT z"direct_ContentHandler.startElementc C s� t j| |� |dkrX| jrF| jjdd� t| j�D �� | jj| j� n tj d� d | _nJ|dkr�| jr�| j jdd� t| j�D �� | jj| j � n tj d � d | _ d S ) Nr c S s g | ]}t |��qS r )r )�.0�xr r r � <listcomp>d s z4direct_ContentHandler.endElement.<locals>.<listcomp>z2Error: rule does not have any arguments, ignoring.r c S s g | ]}t |��qS r )r )r( r) r r r r* m s z0Error: passthrough does not have any arguments, z ignoring.z9Error: passthrough does not have any arguments, ignoring.)r � endElementZ_elementr% �appendr r �add_ruler r r&