/usr/lib/python3.9/site-packages/nftables/__pycache__
Edit: /usr/lib/python3.9/site-packages/nftables/__pycache__/nftables.cpython-39.pyc (17911B)
a
t׎jAN ã @ sD d dl Z d dlT d dlZd dlZdZG dd„ dƒZG dd„ dƒZdS )é N)Ú*z0.1c @ s e Zd ZdZdd„ Zdd„ ZdS )ÚSchemaValidatorz+Libnftables JSON validator using jsonschemac C s^ t j t j t¡d¡}t|dƒ�}t |¡| _W d ƒ n1 sB0 Y dd l }|| _ d S )Nzschema.jsonÚrr )
ÚosÚpathÚjoinÚdirnameÚ__file__ÚopenÚjsonÚloadÚschemaÚ
jsonschema)ÚselfZschema_pathZschema_filer © r ú5/usr/lib/python3.9/site-packages/nftables/nftables.pyÚ__init__ s
*zSchemaValidator.__init__c C s | j j|| jd� d S )N)Úinstancer
)r Úvalidater
)r r r r r r " s zSchemaValidator.validateN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r r r r r r s r c
@ s² e Zd ZdZdddœZddddddd d
œZddddddd ddd
dddœZdZdkdd„Zdd„ Z dd„ Z
dd„ Zdd„ Zdd„ Z
dd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Zd=d>„ Zd?d@„ ZdAdB„ ZdCdD„ Z dEdF„ Z!dGdH„ Z"dIdJ„ Z#dKdL„ Z$dMdN„ Z%dOdP„ Z&dQdR„ Z'dSdT„ Z(dUdV„ Z)dWdX„ Z*dYdZ„ Z+d[d\„ Z,d]d^„ Z-d_d`„ Z.dadb„ Z/dcdd„ Z0dedf„ Z1dgdh„ Z2didj„ Z3dS )lÚNftablesz*A class representing libnftables interfaceé é )zno-dnsr é é é é é@ )ÚscannerÚparserÚevalZnetlinkZmnlz proto-ctxZsegtreeé€ é i i i )Ú
reversednsÚserviceÚ statelessÚhandler ÚechoÚguidÚ
numeric_protoÚnumeric_prioÚnumeric_symbolÚnumeric_timeÚterseNúlibnftables.so.1c C s d| _ t |¡}|j| _t| j_tg| j_|j| _t | j_tg| j_|j
| _
t | j
_tt g| j
_|j| _t | j_tg| j_|j| _tt g| j_|j
| _
t| j
_tg| j
_|j| _ttg| j_|j| _t| j_tg| j_|j| _t| j_tg| j_|j| _t| j_tg| j_|j| _t| j_tg| j_|j| _t| j_ttg| j_|j| _t| j_ttg| j_|j| _t| j_ttg| j_|j| _tg| j_|j| _t| j_tg| j_|j| _ttg| j_|j| _t| j_ttg| j_|j| _tg| j_|j| _tg|j_| d¡| _ | | j ¡ | | j ¡ dS )al Instantiate a new Nftables class object.
Accepts a shared object file to open, by default standard search path
is searched for a file named 'libnftables.so'.
After loading the library using ctypes module, a new nftables context
is requested from the library and buffering of output and error streams
is turned on.
Nr )Ú_Nftables__ctxZcdllZLoadLibraryZnft_ctx_newZc_void_pZrestypeZc_intÚargtypesÚnft_ctx_input_get_flagsZc_uintÚnft_ctx_input_set_flagsÚnft_ctx_output_get_flagsÚnft_ctx_output_set_flagsÚnft_ctx_output_get_debugÚnft_ctx_output_set_debugZnft_ctx_buffer_outputÚnft_ctx_get_output_bufferZc_char_pZnft_ctx_buffer_errorÚnft_ctx_get_error_bufferÚnft_run_cmd_from_bufferÚnft_run_cmd_from_filenameÚnft_ctx_add_include_pathÚnft_ctx_clear_include_pathsÚnft_ctx_get_dry_runZc_boolÚnft_ctx_set_dry_runÚnft_ctx_add_varÚnft_ctx_clear_varsÚnft_ctx_free)r ZsofileÚlibr r r r H sv
zNftables.__init__c C s | j d ur| | j ¡ d | _ d S ©N)r2 rD ©r r r r Ú__del__§ s
zNftables.__del__c C sD g }| ¡ D ]$\}}||@ r| |¡ || M }q|r@| |¡ |S rF )ÚitemsÚappend)r Ú
flags_dictÚvalÚnamesÚnÚvr r r Ú_flags_from_numeric¬ s
zNftables._flags_from_numericc C s€ t |ttfƒr|f}d}|D ]^}t |tƒrF| |¡}|d u rrtdƒ‚n,t |tƒrj|dk s`|dkrrtdƒ‚ntdƒ‚||O }q|S )Nr zInvalid argumentl ÿÿ zNot a valid flag)Ú
isinstanceÚstrÚintÚgetÚ
ValueErrorÚ TypeError)r rK ÚvaluesrL rO r r r Ú_flags_to_numeric¶ s
zNftables._flags_to_numericc C s | | j¡}| | j|¡S )zsGet currently active input flags.
Returns a set of flag names. See set_input_flags() for details.
)r4 r2 rP Úinput_flags©r rL r r r Úget_input_flagsÉ s zNftables.get_input_flagsc C s* | | j|¡}| | j|¡}| | j|¡S )a Set input flags.
Resets all input flags to values. Accepts either a single flag or a list
of flags. Each flag might be given either as string or integer value as
shown in the following table:
Name | Value (hex)
-----------------------
"no-dns" | 0x1
"json" | 0x2
"no-dns" disables blocking address lookup.
"json" enables JSON mode for input.
Returns a set of previously active input flags, as returned by
get_input_flags() method.
)rX rY r5 r2 rP ©r rW rL Úoldr r r Úset_input_flagsÑ s zNftables.set_input_flagsc C s | j | }| | j¡|@ dkS ©Nr )Úoutput_flagsr6 r2 )r ÚnameÚflagr r r Z__get_output_flagç s
zNftables.__get_output_flagc C sH | j | }| | j¡}|r$||B }n
|| @ }| | j|¡ ||@ dkS r_ )r` r6 r2 r7 )r ra rL rb ÚflagsZ new_flagsr r r Z__set_output_flagë s
zNftables.__set_output_flagc C s
| d¡S )z©Get the current state of reverse DNS output.
Returns a boolean indicating whether reverse DNS lookups are performed
for IP addresses in output.
r&