1 # ˆl–ß=¿JJj"Tâ‚ ÆÞ¸&”Å£Æ ƒh¹ÅÀà MAJOR=4 MINOR=4 DEVNAME=tty4 $ ˆl–äY>”ŠClÊq@Šà¸&”Å£Ç „ ¯„?ÆÁÄ?÷ a t׎jANã@sDddlZddlTddlZddlZdZGdd„dƒZGdd„dƒZdS)éN)Ú*z0.1c@s eZdZdZdd„Zdd„ZdS)ÚSchemaValidatorz+Libnftables JSON validator using jsonschemacCs^tj tj t¡d¡}t|dƒ�}t |¡|_Wdƒn1sB0Yddl }||_ dS)Nz schema.jsonÚrr) ÚosÚpathÚjoinÚdirnameÚ__file__ÚopenÚjsonÚloadÚschemaÚ jsonschema)ÚselfZ schema_pathZ schema_filer©rú5/usr/lib/python3.9/site-packages/nftables/nftables.pyÚ__init__s  *zSchemaValidator.__init__cCs|jj||jd�dS)N)Úinstancer )rÚvalidater )rr rrrr"szSchemaValidator.validateN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrrsrc @s²eZdZdZdddœZddddddd d œZddddddd d d d dddœ ZdZdkdd„Zdd„Z dd„Z dd„Z dd„Z dd„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é€éiii) Ú reversednsÚserviceÚ statelessÚhandler ÚechoÚguidÚ numeric_protoÚ numeric_prioÚnumeric_symbolÚ numeric_timeÚterseNúlibnftables.so.1cCs 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)alInstantiate 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__ctxZcdllZ LoadLibraryZ nft_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)rZsofileÚlibrrrrHsv                        zNftables.__init__cCs |jdur| |j¡d|_dS©N)r2rD©rrrrÚ__del__§s  zNftables.__del__cCsDg}| ¡D]$\}}||@r | |¡||M}q |r@| |¡|SrF)ÚitemsÚappend)rÚ flags_dictÚvalÚnamesÚnÚvrrrÚ_flags_from_numeric¬s   zNftables._flags_from_numericcCs€t|ttfƒr|f}d}|D]^}t|tƒrF| |¡}|durrtdƒ‚n,t|tƒrj|dks`|dkrrtdƒ‚ntdƒ‚||O}q|S)Nrz