관리-도구
편집 파일: nftables.cpython-36.pyc
3 @)�f� � % @ sl d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm Z m Z mZmZ d dl mZmZmZmZmZmZmZ d dlmZmZmZmZmZmZmZ d dlmZ dZed d Z dZ!dZ"i d ddCe" fiddDe" fdde" fd�dd e" fdd e" fdd e" fdd e" fd�d�Z#dEdd�Z$e$ddd�e$dd�e$dd�e$dd�e$ddd�e$ddd �e$ddd�e$dd!d"�e$ddd#�e$ddd"�e$dd$d"�e$ddd%�e$dd!d �e$ddd&�e$ddd �e$dd$�e$ddd'�e$ddd(�e$ddd)�e$dd!�e$dd$d"�e$dd*�e$dd+�e$dd,�e$ddd-�e$dd.�e$dd/�e$dd0�e$dd!d'�e$ddd1�e$dd!d)�e$ddd2�e$dd.d"�e$dd.d �d3�"e$d4dd'�e$d4d$d �e$d4dd)�e$d4dd"�e$d4d�e$d4d�e$d4d�e$d4dd-�e$d4d5�e$d4d6�e$d4d7�e$d4d8�e$d4d9�e$d4d:�e$d4dd �e$d4d;�e$d4d$�e$d4dd�e$d4d<�e$d4dd&�e$d4d=�e$d4d>�e$d4d.�e$d4d.d"�e$d4d.d �e$d4d$d"�e$d4d$d)�d?�d@�Z%G dAdB� dBe&�Z'dS )F� )�absolute_importN)�log)� check_mac�getPortRange�normalizeIP6�check_single_address� check_address)� FirewallError� UNKNOWN_ERROR�INVALID_RULE�INVALID_ICMPTYPE�INVALID_TYPE� INVALID_ENTRY�INVALID_PORT)�Rich_Accept�Rich_Reject� Rich_Drop� Rich_Mark�Rich_Masquerade�Rich_ForwardPort�Rich_IcmpBlock)�NftablesZ firewalld�_Zpolicy_dropZpolicy_� � PREROUTING� prerouting� �d Zpostrouting)r �POSTROUTING�input�forward�output)r �INPUT�FORWARD�OUTPUT)�raw�mangle�nat�filterc C sH dd| dd�id|d�ig}|d k rD|j dd| dd�id|d�i� |S )N�match�payload�type)�protocol�fieldz==)�left�op�right�code)�append)r, r+ r1 � fragments� r4 �/usr/lib/python3.6/nftables.py�_icmp_types_fragmentsS s r6 �icmpzdestination-unreachable� z echo-replyzecho-request� � �redirect� � zparameter-problem� � � � � zrouter-advertisementzrouter-solicitationz source-quench� z time-exceededztimestamp-replyztimestamp-request� � )"zcommunication-prohibitedzdestination-unreachablez echo-replyzecho-requestzfragmentation-neededzhost-precedence-violationzhost-prohibitedz host-redirectzhost-unknownzhost-unreachablez ip-header-badznetwork-prohibitedznetwork-redirectznetwork-unknownznetwork-unreachablezparameter-problemzport-unreachablezprecedence-cutoffzprotocol-unreachabler; zrequired-option-missingzrouter-advertisementzrouter-solicitationz source-quenchzsource-route-failedz time-exceededztimestamp-replyztimestamp-requestztos-host-redirectztos-host-unreachableztos-network-redirectztos-network-unreachablezttl-zero-during-reassemblyzttl-zero-during-transit�icmpv6zmld-listener-donezmld-listener-queryzmld-listener-reportzmld2-listener-reportznd-neighbor-advertznd-neighbor-solicitzpacket-too-bigznd-redirectznd-router-advertznd-router-solicit)zaddress-unreachablez bad-headerzbeyond-scopezcommunication-prohibitedzdestination-unreachablez echo-replyzecho-requestz failed-policyzmld-listener-donezmld-listener-queryzmld-listener-reportzmld2-listener-reportzneighbour-advertisementzneighbour-solicitationzno-routezpacket-too-bigzparameter-problemzport-unreachabler; zreject-routezrouter-advertisementzrouter-solicitationz time-exceededzttl-zero-during-reassemblyzttl-zero-during-transitzunknown-header-typezunknown-option)�ipv4�ipv6c @ s` e Zd Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Z dd � Z dd� Zd�dd�Zdd� Z dd� Zdd� Zdd� Zd�dd�Zdd� Zd�d d!�Zd"d#� Zd�d%d&�Zd�d(d)�Zd�d*d+�Zd�d,d-�Zd.d/� Zd0d1� Zd2d3� Zd4d5� Zd6d7� Zd8d9� Zd:d;� Zd<d=� Z d>d?� Z!d@dA� Z"dBdC� Z#dDdE� Z$dFdG� Z%dHdI� Z&d�dJdK�Z'dLdM� Z(dNdO� Z)dPdQ� Z*dRdS� Z+d�dTdU�Z,d�dVdW�Z-d�dXdY�Z.dZd[� Z/d�d\d]�Z0d�d^d_�Z1d�d`da�Z2d�dbdc�Z3d�ddde�Z4dfdg� Z5d�dhdi�Z6djdk� Z7d�dldm�Z8dndo� Z9dpdq� Z:drds� Z;dtdu� Z<d�dvdw�Z=d�dxdy�Z>dzd{� Z?d�d|d}�Z@d~d� ZAd�d�� ZBd�d�� ZCd�d�� ZDd�d�� ZEd�d�� ZFd�d�� ZGd�d�d��ZHdS )��nftablesTc C sb || _ d| _g | _i | _i | _i | _i | _i | _g g g d�| _t � | _ | j jd� | j jd� d S )NT)�inet�ip�ip6) �_fwZrestore_command_existsZavailable_tables�rule_to_handle�rule_ref_count�rich_rule_priority_counts�policy_priority_counts�zone_source_index_cache�created_tablesr rI Zset_echo_outputZset_handle_output)�self�fwr4 r4 r5 �__init__� s znftables.__init__c C s� xdD ]}||krP qW d|| d kr`|| d d d || d d d f}|| d d= n(d|| d kr�d }|| d d= nd S || d d }|r�|dkr�||kr�||| kr�|| j |� n�|dk�r�||kr�g ||<