관리-도구
편집 파일: ipset.cpython-36.pyc
3 @)�fq2 � @ s� d Z dddgZddlZddlZddlmZ ddlmZ ddl m Z dd lmZ dd l mZmZ ddlmZ dZd ddddddddddgZddddd�Zdddd�ZG d d� de�Zd!d� Zd"d� Zd#d$� Zd%d&� Zd'd(� ZdS ))zThe ipset command wrapper�ipset�check_ipset_name�remove_default_create_options� N)�errors)� FirewallError)�runProg)�log)�tempFile�readfile)�COMMANDS� zhash:ipzhash:ip,portzhash:ip,port,ipzhash:ip,port,netzhash:ip,markzhash:netzhash:net,netz hash:net,portzhash:net,port,netzhash:net,ifacezhash:macz inet|inet6�valuez value in secs)�family�hashsize�maxelem�timeoutZinetZ1024Z65536)r r r c @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zd'd d�Z dd� Z dd� Zdd� Zd(dd�Z d)dd�Zdd� Zd*dd�Zd+dd�Zdd � Zd!d"� Zd#d$� Zd%d&� ZdS ),r zipset command wrapper classc C s t d | _d| _d S )Nr )r �_command�name)�self� r �/usr/lib/python3.6/ipset.py�__init__K s zipset.__init__c C s^ dd� |D �}t jd| j| jdj|�� t| j|�\}}|dkrZtd| jdj|�|f ��|S )zCall ipset with argsc S s g | ]}d | �qS )z%sr )�.0�itemr r r � <listcomp>R s zipset.__run.<locals>.<listcomp>z %s: %s %s� r z'%s %s' failed: %s)r �debug2� __class__r �joinr � ValueError)r �argsZ_args�status�retr r r Z__runO s zipset.__runc C s t |�tkrttjd| ��dS )zCheck ipset namezipset name '%s' is not validN)�len�IPSET_MAXNAMELENr r ZINVALID_NAME)r r r r r � check_nameZ s zipset.check_namec C s� g }d}y| j dg�}W n0 tk rH } ztjd| � W Y dd}~X nX |j� }d}xT|D ]L}|r�|j� jdd�}|d |kr�|d tkr�|j|d � |j d�r\d }q\W |S ) z?Return types that are supported by the ipset command and kernel� z--helpzipset error: %sNF� r zSupported set types:T) �_ipset__runr r Zdebug1� splitlines�strip�split�IPSET_TYPES�append� startswith)r r"