+
        ,                         R t ^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ t. ROtRR	R
RRRRR/tRRR
RRR/t ! R R4      tR tR tR tR tR tR# )zThe ipset command wrapperN)errors)FirewallError)runProg)log)tempFilereadfile)COMMANDSfamilyz
inet|inet6hashsizevaluemaxelemtimeoutzvalue in secsinet102465536c                      a  ] tR t^6t o RtR tR tR tR tRR lt	R t
R	 tR
 tRR ltRR ltR tRR ltRR ltR tR tR tR tRtV tR# )ipsetzipset command wrapper classc                8    \         R ,          V n        R V n        R# )r   N)r   _commandnameselfs   &8/usr/lib/python3.14/site-packages/firewall/core/ipset.py__init__ipset.__init__9   s     )	    c                V   V Uu. uF  pRV,          NK  	  pp\         P                  ! RV P                  V P                  RP	                  V4      4       \        V P                  V4      w  rEV^ 8w  d1   \        RV P                  : RRP	                  V4      : RV: 24      hV# u upi )zCall ipset with args%sz	%s: %s %s '
' failed: )r   debug2	__class__r   joinr   
ValueError)r   argsitem_argsstatusrets   &&    r   __runipset.__run=   s     *...

;sxxOu5Q;(,sxxL  
 /s   B&c                p    \        V4      \        8  d"   \        \        P                  RV,          4      hR# )zCheck ipset namezipset name '%s' is not validN)lenIPSET_MAXNAMELENr   r   INVALID_NAME)r   r   s   &&r   
check_nameipset.check_nameI   s2    t9''##%Cd%J  (r   c                    \        V4      \        8  g   V\        9  d"   \        \        P
                  RV,          4      hR# )zCheck ipset typez!ipset type name '%s' is not validN)r-   r.   IPSET_TYPESr   r   INVALID_TYPE)r   	type_names   &&r   
check_typeipset.check_typeP   s:    y>,,	0L##%H9%T  1Mr   Nc                $   V P                  V4       V P                  V4       RW.p\        V\        4      '       dE   VP	                  4        F0  w  rVVP                  V4       VR8w  g   K  VP                  V4       K2  	  V P                  V4      # )z+Create an ipset with name, type and optionscreate )r0   r6   
isinstancedictitemsappend_ipset__run)r   set_namer5   optionsr%   keyvals   &&&&   r   
set_createipset.set_createW   ss    !	"(.gt$$#MMOC "9KK$ , zz$r   c                J    V P                  V4       V P                  R V.4      # )destroy)r0   r?   )r   r@   s   &&r   set_destroyipset.set_destroyd   s"    !zz9h/00r   c                ,    R W.pV P                  V4      # )addr?   r   r@   entryr%   s   &&& r   set_addipset.set_addh       x'zz$r   c                ,    R W.pV P                  V4      # )delrL   rM   s   &&& r   
set_deleteipset.set_deletel   rQ   r   c                    R W.pV'       d(   VP                  RRP                  V4      ,          4       V P                  V4      # )testr   r   )r>   r#   r?   )r   r@   rN   rA   r%   s   &&&& r   rW   
ipset.testp   s8    (KKsxx001zz$r   c                    R .pV'       d   VP                  V4       V'       d   VP                  V4       V P                  V4      P                  R4      # )list
)r>   extendr?   split)r   r@   rA   r%   s   &&& r   set_listipset.set_listv   sA    xKK!KK zz$%%d++r   c                   V P                  R.R7      p/ pR;r4/ pV EFL  p\        V4      ^8  d   K  VP                  R^4       Uu. uF  qwP                  4       NK  	  pp\        V4      ^8w  d   KV  V^ ,          R8X  d   V^,          pKo  V^ ,          R8X  d   V^,          pK  V^ ,          R8X  g   K  V^,          P                  4       p	^ p
V
\        V	4      8  dZ   W,          pVR	9   d@   \        V	4      V
8  d   V
^,          p
W,          W[&   M\        P
                  ! RV4       / u # V
^,          p
Ki  V'       d   V'       d   V\        V4      3W#&   R;r4VP                  4        EKO  	  V# u upi )
z Get active ipsets (only headers)z-terse)rA   N:NameTypeHeaderz&Malformed ipset list -terse output: %s)r	   r
   r   r   netmask)r^   r-   r]   stripr   errorremove_default_create_optionsclear)r   linesr)   _name_type_optionslinexpairsplitsiopts   &           r   set_get_active_terseipset.set_get_active_terse~   sF   xj1D4y1}'+zz#q'9:'9!GGI'9D:4yA~aF"QaF"QaH$a#f+o )CUUv;?FA,2IHMII&NPTU#%IFAU"')Fx)P!QCJ $$ 5 6 
1 ;s   E0c                \    R .pV'       d   VP                  V4       V P                  V4      # )saver>   r?   r   r@   r%   s   && r   rw   
ipset.save   s'    xKK!zz$r   c                   V P                  V4       V P                  V4       \        4       pR V9   d
   RV,          pRWR.pV'       dE   VP                  4        F0  w  rVP	                  V4       V	R8w  g   K  VP	                  V	4       K2  	  VP                  RR P                  V4      ,          4       VP                  RV,          4       V Fd  p
R V
9   d
   RV
,          p
V'       d0   VP                  RV: R V
: R R P                  V4      : R24       KJ  VP                  RV: R V
: R24       Kf  	  VP                  4        \        P                  ! VP                  4      p\        P                  ! R	V P                  V P                  R
VP                  VP                  3,          4       R.p\!        V P                  WvP                  R7      w  r\        P"                  ! 4       ^8  d    \%        VP                  4       ^p\%        VP                  4       F\  p\        P&                  ! RW3,          ^^ R7       VP)                  R4      '       g   \        P&                  ! R^R7       V^,          pK^  	  \        P,                  ! VP                  4       V^ 8w  d1   \/        RV P                  : R R P                  V4      : RV: 24      hV#   \*         d     Lfi ; i)r   z'%s'r9   z-existr:   z%s
z	flush %s
zadd r[   z%s: %s restore %sz%s: %drestore)stdinz%8d: %s)nofmtnl)r~   r   r    )r0   r6   r   r=   r>   writer#   closeosstatr   r   r!   r"   r   st_sizer   getDebugLogLevelr   debug3endswith	Exceptionunlinkr$   )r   r@   r5   entriescreate_optionsentry_options	temp_filer%   rB   rC   rN   r   r(   r)   rr   rn   s   &&&&&&          r   set_restoreipset.set_restore   s1    	!	"J	(?(H(x8*002C "9KK$ 3 	$/0x/0Ee|(0%-9PQ 5 AB  	wwy~~&

NNMM	55		
 {t>>J!A%
( $Y^^4DJJyA94A!D==..

2Q/FA	 5 			)..!Q;(,sxx~sK  
!  s   2K K%$K%c                \    R .pV'       d   VP                  V4       V P                  V4      # )flushrx   ry   s   && r   	set_flushipset.set_flush   s'    yKK!zz$r   c                (    V P                  R W.4      # )renamerL   )r   old_set_namenew_set_names   &&&r   r   ipset.rename   s    zz8\@AAr   c                (    V P                  R W.4      # )swaprL   )r   
set_name_1
set_name_2s   &&&r   r   
ipset.swap   s    zz6::;;r   c                &    V P                  R .4      # )versionrL   r   s   &r   r   ipset.version   s    zz9+&&r   )r   r   )N)NN)__name__
__module____qualname____firstlineno____doc__r   r?   r0   r6   rD   rH   rO   rT   rW   r^   rt   rw   r   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r   r   6   se     %
 1   ,"H <| B<' 'r   r   c                2    \        V 4      \        8  d   R# R# )z"Return true if ipset name is validFT)r-   r.   )r   s   &r   check_ipset_namer      s    
4y##r   c                    V P                  4       p\         F'  pW!9   g   K  \        V,          W,          8X  g   K%  W K)  	  V# )z&Return only non default create options)copyIPSET_DEFAULT_CREATE_OPTIONS)rA   rm   rs   s   &  r   rh   rh      s7    ||~H+?;C@HMQ , Or   c           
     "   . pV P                  R4       FE  p VP                  R4       VP                  \        \        P
                  ! VRR7      4      4       KG  	  RP                  V4      #   \         d    TP                  T4        Ky  i ; i)zNormalize IP addresses in entry,/Fstrict)r]   indexr>   str	ipaddress
ip_networkr$   r#   )rN   _entry_parts   &  r   normalize_ipset_entryr     sw    FS!	!KKMM#i225GHI " 88F  	!MM% 	!s   AA..BBc                \   \        V P                  R4      4      ^8  d   R#  \        P                  ! V RR7      pT FY  pTP                  \        P                  ! TRR7      4      '       g   K2  \        \        P                  RP                  Y4      4      h	  R#   \         d     R# i ; i)z8Check if entry overlaps any entry in the list of entriesr   NFr   z,Entry '{}' overlaps with existing entry '{}')
r-   r]   r   r   r$   overlapsr   r   INVALID_ENTRYformat)rN   r   entry_networkitrs   &&  r   check_entry_overlaps_existingr     s     5;;sq !,,U5A
 !!)"6"6s5"IJJ$$>EEeQ  	  s   B B+*B+c                    V  Uu. uF  p\         P                  ! VRR7      NK  	  p p\        T 4      ^ 8X  d   R# T P	                  4        T P                  ^ 4      pT  FE  pTP                  T4      '       d*   \        \        P                  RP                  Y#4      4      hTpKG  	  R# u upi   \         d     R# i ; i)z<Check if any entry overlaps any entry in the list of entriesFr   NzEntry '{}' overlaps entry '{}')r   r   r$   r-   sortpopr   r   r   r   r   )r   ro   prev_networkcurrent_networks   &   r   check_for_overlapping_entriesr   '  s    BIJ'Q9''%8'J
 7|qd LLN;;q>L"  11$$077V  ' #u K s!   B. !B)B. )B. .B=<B=)zhash:ipzhash:ip,portzhash:ip,port,ipzhash:ip,port,netzhash:ip,markzhash:netzhash:net,netzhash:net,portzhash:net,port,netzhash:net,ifacezhash:mac)r   os.pathr   r   firewallr   firewall.errorsr   firewall.core.progr   firewall.core.loggerr   firewall.functionsr   r   firewall.configr   r.   r3   IPSET_CREATE_OPTIONSr   r   r   rh   r   r   r    r   r   <module>r      s         ) & $ 1 $ & lw	  fw  }' }'@
(C'r   