+
    i[  c                   sX   ^ RI Ht ^ RIHtHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^ RIHtHt  ! R R	4      t]! 4       tR
 tR tR tR tR tR tR tR tR t]! RRR7       ! R R4      4       t]! RRR7       ! R R4      4       t]! RRR7       ! R R4      4       t]! RRR7       ! R R4      4       t]! RRR7       ! R R4      4       t]! RRR7       ! R R 4      4       t ]! RR!7       ! R" R#4      4       t!]! RRR7       ! R$ R%4      4       t"]! RRR7       ! R& R'4      4       t#]! RRR7       ! R( R)4      4       t$]! RRR7       ! R* R+4      4       t%R,^R-^<R.RCR/RD/t&]! RRR7       ! R0 R14      4       t']! RR!7       ! R2 R34      4       t(]! RR!7       ! R4 R54      4       t)]! RR!7       ! R6 R74      4       t*]! RR!7       ! R8 R94      4       t+]! RR!7       ! R: R;4      4       t,]! RR!7       ! R< R=4      4       t-]! RR!7       ! R> R?4      4       t.]! RR!7       ! R@ RA4      4       t/RB# )Ei    )ClassVar)	dataclassfieldInitVar)	functions)check_ipset_name)REJECT_TYPES)errors)FirewallErrorBugErrorc                   s&   a  ] tR t^t o R tRtV tR# )_EOLTypec                    R # )zfirewall.core.rich.EOL self   &7/usr/lib/python3.14/site-packages/firewall/core/rich.py__repr__Z_EOLType.__repr__   s    '    r   N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classdict__   @r   r
   r
      s     ( (r   r
   c                 s    V f   Ve   R# V e   Vf   R# V f   Vf   R# \        V 4      \        V4      J d   W8  # \        V 4      P                  \        V4      P                  8  # )NTF)typer   ZleftZright   &&r   
lt_objectsr      s_    |)		em	%-	dtE{	"|Dz""T%[%9%999r   c                 4    V P                   VP                   8  # N)familyr   r   r   	lt_familyr#   +   s    ;;%%r   c                 r    r!   )priorityr   r   r   lt_priorityr%   /   s    ==5>>))r   c                 B    \        V P                  VP                  4      # r!   )r   sourcer   r   r   	lt_sourcer(   3       dkk5<<00r   c                 r&   r!   )r   destinationr   r   r   lt_destinationr+   7   s    d&&(9(9::r   c                 r&   r!   )r   elementr   r   r   
lt_elementr-   ;   s    dllEMM22r   c                 r&   r!   )r   logr   r   r   lt_logr/   ?   s    dhh		**r   c                 r&   r!   )r   auditr   r   r   lt_auditr1   C   s    djj%++..r   c                 r&   r!   )r   actionr   r   r   	lt_actionr3   G   r)   r   T)frozenZorderc                   s@   a  ] tR t^Kt o RtRtR tR tV 3R ltRt	V t
R# )Rich_SourceqThis object only holds data and is read-only after init. It is also
hashable and can be used as a dictionary key.Fc                s2   \        V P                  V P                  V P                  .4      '       g   \	        \
        P                  R 4      hV P                  f   \        P                  V RR4       V P                  f   \        P                  V RR4       V P                  f   \        P                  V RR4       V P                  '       d[   V P                  '       d   \	        \
        P                  R4      hV P                  '       d   \	        \
        P                  R4      hR# V P                  '       d   V P                  '       d   \	        \
        P                  R4      h\        P                  ! V P                  4      '       g.   \	        \
        P                  \        V P                  4      4      hR# V P                  '       dK   \        V P                  4      '       g.   \	        \
        P                  \        V P                  4      4      hR# R# )	zno address, mac and ipsetNaddr macipsetzaddress and macaddress and ipsetzmac and ipset)anyr7   r9   r:   r   r   INVALID_RULEobject__setattr__r   Z	check_macZINVALID_MACstrr   INVALID_IPSETr   r   r   __post_init__ZRich_Source.__post_init__U   sg   DIItxx455 3 35PQQ99tVR088tUB/::tWb1999xxx#F$7$79JKKzzz#F$7$79LMM XXXzzz#F$7$7II&&txx00#F$6$6DHHFF 1ZZZ#DJJ//#F$8$8#djj/JJ 0 r   c                sH   R V P                   '       d   RMR,          pV P                  '       d   VRV P                  ,          ,           # V P                  '       d   VRV P                  ,          ,           # V P                  '       d   VRV P                  ,          ,           # R# )z	source%s  NOTr8   address="%s"zmac="%s"
ipset="%s"N)invertr7   r9   r:   r   Zret   & r   __str__ZRich_Source.__str__n   sr    t{{{V;999$))333XXXdhh...ZZZ

222 r   c                sJ   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[;R&   # )   r7   r9   r:   rF   r@   ZboolZformatr      "r   __annotate__ZRich_Source.__annotate__K   s6     
 I  
H  J   r   r   Nr   r   r   r   __doc__rF   rB   rI   __annotate_func__r   r   r   r   r   r5   r5   K   s$     5 FK23G  r   r5   c                   s@   a  ] tR t^xt o RtRtR tR tV 3R ltRt	V t
R# )Rich_Destinationr6   Fc                sT   \        V P                  V P                  .4      '       g   \        \        P
                  R 4      hV P                  f   \        P                  V RR4       V P                  f   \        P                  V RR4       V P                  '       d/   V P                  '       d   \        \        P
                  R4      hR# V P                  '       dK   \        V P                  4      '       g.   \        \        P                  \        V P                  4      4      hR# R# )zno address or ipsetNr7   r8   r:   r;   )r<   r7   r:   r   r   ZINVALID_DESTINATIONr>   r?   r   rA   r@   r   r   r   rB   ZRich_Destination.__post_init__   s    DIItzz*++ : :<QRR99tVR0::tWb1999zzz#F$>$>@STT ZZZ#DJJ//#F$8$8#djj/JJ 0 r   c                s    R V P                   '       d   RMR,          pV P                  '       d   VRV P                  ,          ,           # V P                  '       d   VRV P                  ,          ,           # R# )zdestination%s rC   r8   rD   rE   N)rF   r7   r:   rG   rH   r   rI   ZRich_Destination.__str__   sU    DKKK&R@999$))333ZZZ

222 r   c                >   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[;R&   # )rJ   r7   r:   rF   rK   rL   rM   r   rN   ZRich_Destination.__annotate__x   s*     
 I  J   r   r   NrO   r   r   r   rR   rR   x   s#     5
 FK 33  r   rR   c                   s6   a  ] tR t^t o RtR tV 3R ltRtV tR# )Rich_Servicer6   c                (    R V P                   ,          # )zservice name="%s"namer   r   r   rI   ZRich_Service.__str__   s    "dii00r   c                &   < V ^8  d   Qh/ S[ ;R&   # rJ   rW   r@   rL   rM   r   rN   ZRich_Service.__annotate__        
 I r   r   N)	r   r   r   r   rP   rI   rQ   r   r   r   r   r   rT   rT      s     5
1  r   rT   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )	Rich_Portr6   c                   \         P                  ! V P                  4      '       g%   \        \        P
                  V P                  4      hV P                  R9  d%   \        \        P                  V P                  4      hR# tcpNr_   ZudpZsctpZdccpr   
check_portportr   r   INVALID_PORTprotocolINVALID_PROTOCOLr   r   r   rB   ZRich_Port.__post_init__   W    ##DII.. 3 3TYY??== >> 7 7GG ?r   c                @    R V P                   : RV P                  : R2# )zport port="" protocol=""rc   re   r   r   r   rI   ZRich_Port.__str__   s    15DMMJJr   c                2   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   # rJ   rc   re   rZ   rL   rM   r   rN   ZRich_Port.__annotate__        
 I  M r   r   N
r   r   r   r   rP   rB   rI   rQ   r   r   r   r   r   r\   r\      s     5HK  r   r\   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )Rich_SourcePortr6   c                r]   r^   ra   r   r   r   rB   ZRich_SourcePort.__post_init__   rg   r   c                rh   )zsource-port port="ri   rj   rk   r   r   r   rI   ZRich_SourcePort.__str__   s    8<		4==QQr   c                rl   rm   rZ   rL   rM   r   rN   ZRich_SourcePort.__annotate__   rn   r   r   Nro   r   r   r   rp   rp      s     5HR  r   rp   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )Rich_Protocolr6   c                s    \         P                  ! V P                  4      '       g%   \        \        P
                  V P                  4      hR # r!   )r   ZcheckProtocolvaluer   r   rf   r   r   r   rB   ZRich_Protocol.__post_init__   s3    &&tzz22 7 7DD 3r   c                rU   )zprotocol value="%s"rr   r   r   r   rI   ZRich_Protocol.__str__   s    $

33r   c                rX   rJ   rr   rZ   rL   rM   r   rN   ZRich_Protocol.__annotate__        
 J r   r   Nro   r   r   r   rq   rq      s     5
E4  r   rq   )r4   c                   s*   a  ] tR t^t o RtR tRtV tR# )Rich_Masquerader6   c                r   )
masquerader   r   r   r   rI   ZRich_Masquerade.__str__   s    r   r   N)r   r   r   r   rP   rI   r   r   r   r   r   rv   rv      s     5 r   rv   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )Rich_IcmpBlockr6   c                    V P                   e   \        V P                   4      ^8  d.   \        \        P                  \        V P                   4      4      hR # r!   rW   lenr   r   ZINVALID_ICMPTYPEr@   r   r   r   rB   ZRich_IcmpBlock.__post_init__   ;    99DII 2 7 7TYYHH !3r   c                rU   )zicmp-block name="%s"rV   r   r   r   rI   ZRich_IcmpBlock.__str__   s    %33r   c                rX   rY   rZ   rL   rM   r   rN   ZRich_IcmpBlock.__annotate__   r[   r   r   Nro   r   r   r   rx   rx      s     5
I4  r   rx   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )Rich_IcmpTyper6   c                ry   r!   rz   r   r   r   rB   ZRich_IcmpType.__post_init__   r|   r   c                rU   )zicmp-type name="%s"rV   r   r   r   rI   ZRich_IcmpType.__str__   s    $		22r   c                rX   rY   rZ   rL   rM   r   rN   ZRich_IcmpType.__annotate__   r[   r   r   Nro   r   r   r   r}   r}      s     5
I3  r   r}   c                   s<   a  ] tR t^t o RtR tR tV 3R ltRtV t	R# )Rich_Tcp_Mss_Clampr6   c                s
   V P                   f   \        P                  V RR4       V P                   '       dL   \        P                  ! V P                   4      '       g$   \        \        P                  \        V 4      4      hR # R # )Nrr   r8   )	rr   r>   r?   r   ZcheckTcpMssClampr   r   r=   r@   r   r   r   rB   Z Rich_Tcp_Mss_Clamp.__post_init__  s]    ::tWb1:::--djj99#F$7$7TCC : r   c                sP    V P                   '       d   R V P                   ,          # R# )ztcp-mss-clamp value="%s"tcp-mss-clamprs   r   r   r   rI   ZRich_Tcp_Mss_Clamp.__str__  s    :::-<<"r   c                rX   rt   rZ   rL   rM   r   rN   ZRich_Tcp_Mss_Clamp.__annotate__   ru   r   r   Nro   r   r   r   r~   r~      s     5
D#  r   r~   c                   s<   a  ] tR tRt o RtR tR tV 3R ltRtV t	R# )Rich_ForwardPorti  r6   c                s   V P                   f   \        P                  V RR4       V P                  f   \        P                  V RR4       \        P
                  ! V P                  4      '       g%   \        \        P                  V P                  4      hV P                  R9  d%   \        \        P                  V P                  4      hV P                   '       g7   V P                  '       g%   \        \        P                  V P                   4      hV P                   '       dM   \        P
                  ! V P                   4      '       g%   \        \        P                  V P                   4      hR # R # )Nto_portr8   
to_addressr`   )r   r>   r?   r   r   rb   rc   r   r   rd   re   rf   r   r   r   rB   ZRich_ForwardPort.__post_init__  s    <<tY3??"t\26##DII.. 3 3TYY??== >> 7 7GG|||DOOO 3 3T\\BB<<<	 4 4T\\ B B 3 3T\\BB !C<r   c                s    R V P                   : RV P                  : RV P                  R8w  d   RV P                  ,          MR: V P                  R8w  d   RV P                  ,          : 2# R: 2# )zforward-port port="ri   rj   r8   z to-port="%s"z to-addr="%s")rc   re   r   r   r   r   r   rI   ZRich_ForwardPort.__str__-  sd    IIMM.2llb.@Odll*bH15B1FOdoo-N	
 	
 MON	
 	
r   c                sJ   < V ^8  d   Qh/ S[ ;R&   S[ ;R&   S[ ;R&   S[ ;R&   # )rJ   rc   re   r   r   rZ   rL   rM   r   rN   ZRich_ForwardPort.__annotate__  s5     
 I  M  L  O r   r   Nro   r   r   r   r   r     s     5C
3  r   r   smhdc                   sp   a  ] tR tRt o Rt^ t]! RR7      t]! RR7      tR t	R t
R tR tV 3R	 ltR
tV tR# )
Rich_Limiti>  r6   F)Zinitc                sH   V P                  V4      w  r#\        P                  V R V4       \        P                  V RV4       \        P                  V RV P                  V P                  4      4       \        P                  V RV P
                   RV P                   24       R# )ratedurationburstrr   /N)_value_parser>   r?   _burst_parser   r   r   )r   rr   r   r      &&  r   rB   ZRich_Limit.__post_init__H  s~    **514.4X64$*;*;DJJ*GH4TYYKq*HIr   c                s^   R pRV9   d   VP                  R4      pV'       d   \        V4      ^8w  d   \        \        P                  V4      hVw  r4 \        V4      pTP                  4       pTR9   d
   TR,          pT^8  g   TR9  d   \        \        P                  T4      hR\        T,          ,          T,          ^ 8X  d   \        \        P                  T R24      hT^8X  d%   TR8X  d   \        \        P                  T R24      hY43#    \        \        P                  T4      h; i)	Nr   :Ni   Nr   i'  z	 too fastz	 too slow)ZsecondZminuteZhourZday)r   r   r   r   )splitr{   r   r   INVALID_LIMITintZstripDURATION_TO_MULT)r   rr   splitsr   r   s   &&   r   r   ZRich_Limit._value_parseO  s   %<[[%FV) 4 4e<<!	=t9D >>#::|H!8x';; 4 4e<<#H--5: 4 4y6IJJ19S 4 4y6IJJ~%	= 4 4e<<s   D D,c                s    Vf   ^ #  \        V4      pT^ 8  g   TR8  d   \        \        P                  T4      hT#    \        \        P                  T4      h; i)Ni )r   r   r   r   )r   r   Zbs   && r   r   ZRich_Limit._burst_parsel  sY    =	=E
A q5A
N 4 4e<<	= 4 4e<<s	   = Ac                sv    R V P                    R2pV P                  '       d   VRV P                   2,          pV# )zlimit value="rj   z burst=rr   r   )r   r   rH   r   rI   ZRich_Limit.__str__z  s7    DJJ<q):::74::,''Ar   c                sZ   < V ^8  d   Qh/ S[ S[,          ;R&   S[;R&   S[;R&   S[;R&   # )rJ   rr   r   r   r   )r   r@   r   rL   rM   r   rN   ZRich_Limit.__annotate__>  s<     
 3<  N  !  % r   r   N)r   r   r   r   rP   r   r   r   r   rB   r   r   rI   rQ   r   r   r   r   r   r   r   >  sB     5 E5!Du%HJ:y  r   r   c                   sN   a  ] tR tRt o RtRtRtRtR tR t	R t
V 3R ltR	tV tR# )
Rich_Logi  r6   r8   Nc                s   V P                   f   \        P                  V RR4       V P                  f   \        P                  V RR4       V P                   '       d5   \	        V P                   4      ^8  d   \        \        P                  R4      hV P                  '       d8   V P                  R9  d%   \        \        P                  V P                  4      hR # R # )Nprefixr8   level+maximum accepted length of 'prefix' is 127.)ZemergZalertZcritZerrorZwarningZnoticeZinfoZdebug)	r   r>   r?   r   r{   r   r   INVALID_LOG_PREFIXZINVALID_LOG_LEVELr   r   r   rB   ZRich_Log.__post_init__  s    ;;tXr2::tWb1;;;3t{{+c1))+X  :::$** 	-
 	
   8 8$**EE	
:r   c                s    V P                   VP                   8  d   R # V P                  VP                  8  d   R # \        V P                  VP                  4      '       d   R # R# TF)r   r   r   limitr   otherr   r   __lt__ZRich_Log.__lt__  sC    ;;%ZZ%++%

EKK00r   c                s    R V P                   '       d   RV P                   ,          MR: V P                  '       d   RV P                  ,          MR: V P                  '       d   RV P                  ,          : 2# R: 2# )r.    prefix="%s"r8   z level="%s" %s)r   r   r   r   r   r   rI   ZRich_Log.__str__  sg    .2kkkNdkk*rA,0JJJMTZZ(B>"&***EDJJ4
 	
 354
 	
r   c                rS   )rJ   r   r   r   r@   r   rL   rM   r   rN   ZRich_Log.__annotate__  s+     
   O   r   r   )r   r   r   r   rP   r   r   r   rB   r   rI   rQ   r   r   r   r   r   r   r     s3     5 FEEF.
U  r   r   c                   F   a  ] tR tRt o RtRtR tR tR tV 3R lt	Rt
V tR# )	
Rich_NFLogi  r6   Nc           	     s   V P                   f   \        P                  V R^ 4       V P                  f   \        P                  V RR4       V P                  f   \        P                  V R^ 4       V P                   '       dA   \
        P                  ! V P                   4      '       g   \        \        P                  R4      h\        P                  V R\        \        V P                   4      ^ 4      4       V P                  '       d5   \        V P                  4      ^8  d   \        \        P                  R4      hV P                  '       dA   \
        P                  ! V P                  4      '       g   \        \        P                  R4      h\        P                  V R\        \        V P                  4      ^ 4      4       R # )Ngroupr   r8   	thresholdz5nflog 'group' must be an integer between 0 and 65535.r   z:nflog 'queue-size' must be an integer between 0 and 65535.)r   r>   r?   r   r   r   ZcheckUINT16r   r   ZINVALID_NFLOG_GROUPr   r@   r{   r   ZINVALID_NFLOG_QUEUEr   r   r   rB   ZRich_NFLog.__post_init__  s=   ::tWa0;;tXr2>>!t[!4:::i33DJJ??**G  	4#c$**oq*AB;;;3t{{+c1))+X  >>>)"7"7"G"G**L  	4c#dnn2Eq.IJr   c                s   V P                   VP                   8  d   R # V P                  VP                  8  d   R # V P                  VP                  8  d   R # \        V P                  VP                  4      '       d   R # R# r   )r   r   r   r   r   r   r   r   r   ZRich_NFLog.__lt__  sV    ::#[[5<<'^^eoo-

EKK00r   c                sN   R V P                   '       d   RV P                   ,          MR: V P                  '       d   RV P                  ,          MR: V P                  '       d   RV P                  ,          MR: V P                  '       d   RV P                  ,          : 2# R: 2# )nflogz group="%s"r8   r   z queue-size="%s"r   )r   r   r   r   r   r   r   rI   ZRich_NFLog.__str__  s    ,0JJJMTZZ(B>.2kkkNdkk*rA59^^^$..1K"&***EDJJ4	
 	
 354	
 	
r   c                sJ   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   S[;R&   # )rJ   r   r   r   r   )r   r@   r   rL   rM   r   rN   ZRich_NFLog.__annotate__  s6     
 J  K  N   r   r   r   r   r   r   rP   r   rB   r   rI   rQ   r   r   r   r   r   r   r     s)     5 EK6

c  r   r   c                   @   a  ] tR tRt o RtRtR tR tV 3R ltRt	V t
R# )
Rich_Auditi  r6   Nc                V    \        V P                  VP                  4      '       d   R # R# r   r   r   r   r   r   r   ZRich_Audit.__lt__      djj%++..r   c                j    R V P                   '       d   RV P                   ,          ,          # R,          # )zaudit%sr   r8   r   r   r   r   rI   ZRich_Audit.__str__  s&    $***EDJJ.EE"EEr   c                rX   rJ   r   r   rL   rM   r   rN   ZRich_Audit.__annotate__       
  r   r   r   r   r   r   rP   r   r   rI   rQ   r   r   r   r   r   r   r     s#     5 EF  r   r   c                   r   )Rich_Accepti  r6   Nc                r   r   r   r   r   r   r   ZRich_Accept.__lt__  r   r   c                r   )zaccept%sr   r8   r   r   r   r   rI   ZRich_Accept.__str__  s&    4:::UTZZ/FF2FFr   c                rX   r   r   rL   rM   r   rN   ZRich_Accept.__annotate__  r   r   r   r   r   r   r   r   r     s#     5 EG  r   r   c                   sD   a  ] tR tRt o RtRtRtR tR tV 3R lt	Rt
V tR# )	Rich_Rejecti  r6   r8   Nc                    V P                   VP                   8  d   R # \        V P                  VP                  4      '       d   R # R# r   )r   r   r   r   r   r   r   ZRich_Reject.__lt__  s0    99uzz!

EKK00r   c                s    R V P                   '       d   RV P                   ,          MR: V P                  '       d   RV P                  ,          : 2# R: 2# )rejectz
 type="%s"r8   r   )r   r   r   r   r   rI   ZRich_Reject.__str__  sL    (,			L499$r9"&***EDJJ4
 	
244
 	
r   c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )rJ   r   r   r   rL   rM   r   rN   ZRich_Reject.__annotate__  s     
 N   r   r   )r   r   r   r   rP   r   r   r   rI   rQ   r   r   r   r   r   r   r     s'     5 DE
!  r   r   c                   r   )	Rich_Dropi&  r6   Nc                r   r   r   r   r   r   r   ZRich_Drop.__lt__-  r   r   c                r   )zdrop%sr   r8   r   r   r   r   rI   ZRich_Drop.__str__3  s&    54::-DDDDr   c                rX   r   r   rL   rM   r   rN   ZRich_Drop.__annotate__&  r   r   r   r   r   r   r   r   r   &  s#     5 EE  r   r   c                   r   )		Rich_Marki7  r6   Nc                s$   V P                   e   V P                   pM\        \        P                  R4      hRV9   d   VP	                  R4      p\        V4      ^8w  d   \        \        P                  V4      h\        P                  ! V^ ,          4      '       d$   \        P                  ! V^,          4      '       g   \        \        P                  V4      hR # \        P                  ! V4      '       g   \        \        P                  V4      hR # )Nzno value setr   )setr   r   ZINVALID_MARKr   r{   r   ZcheckUINT32)r   Zxr   s   &  r   rB   ZRich_Mark.__post_init__?  s    88A 3 3^DD!8WWS\F6{a#F$7$7;;((339;P;Pq	< < $F$7$7;;	< ((++#F$7$7;; ,r   c                r   r   )r   r   r   r   r   r   r   ZRich_Mark.__lt__S  s0    88eii

EKK00r   c                sx    R V P                   : V P                  '       d   RV P                  ,          : 2# R: 2# )z	mark set=r   r8   )r   r   r   r   r   rI   ZRich_Mark.__str__[  s1    "&(($***EDJJ,>,TUURT,TUUr   c                r   )rJ   r   r   r   rL   rM   r   rN   ZRich_Mark.__annotate__7  s     
 
H   r   r   r   r   r   r   r   r   7  s)     5 E<(VI  r   r   c                   s   a  ] tR tRt o RtRtRtRtRt^ t	Rt
RtRtRtRtRtR tR t]R 4       tR	 tR
 tR tV 3R ltRtV tR# )	Rich_Rulei_  r6   i  Nr8   c           
     s   V P                   f   \        P                  V RR4       V P                  f   \        P                  V R^ 4       Ve   \	        V P                   V P                  V P
                  V P                  V P                  V P                  V P                  V P                  .4      '       d   \        R4      hV P                  V4       V P                  4        R # R # )Nr"   r8   r$   zHMay not specify other arguments if constructing object using 'rule_str'.)r"   r>   r?   r$   r<   r'   r*   r,   r.   r0   r2   r	   _import_from_stringcheck)r   rule_strr   r   rB   ZRich_Rule.__post_init__{  s    ;;tXr2== tZ3 KKMMKK$$LLHHJJKK	  ^  $$X.JJL)  r   c                s    \         \        \        \        \        \
        \        \        .pV F%  pV! W4      '       d    R # V! W4      '       g   K$   R# 	  R# r   )r%   r#   r(   r+   r-   r/   r1   r3   )r   r   Zlt_functionsZ_ltr   r   r   ZRich_Rule.__lt__  sN    	
  C4U!!	   r   c                s   . p\         P                  ! V 4       F  pRV9   d   VP                  R4      p\        V4      ^8w  g   V^ ,          '       d   V^,          '       g"   \	        \
        P                  RV,          4      hVP                  RV^ ,          RV^,          /4       K  VP                  RV/4       K  	  VP                  R\        /4       V# )zLexical analysisZ=zinternal error in _lexer(): %s	attr_name
attr_valuer,   )	r   Z	splitArgsr   r{   r   r   r=   appendEOL)r   tokensZrZattrs   &   r   _lexerZRich_Rule._lexer  s     $$X.Aaxwws|t9>aQ'++-MPQ-Q  {DG\47KLy!n- / 	y#&'r   c                s   V'       g   \        \        P                  R 4      h\        P                  ! V4      pV P                  V4      pV'       d;   V^ ,          P                  R4      \        J d   \        \        P                  R 4      h/ p. p^ pW%,          P                  R4      \        J d
   VR.8X  Egl   W%,          P                  R4      pW%,          P                  R4      pW%,          P                  R4      pV'       d+   VRL9  d"   \        \        P                  RV,          4      hEMVRRRRRRRRRRRR R!R"R#R$R%R&R'R(R)\        R*39   EdZ   VR8X  d-   V P                  '       d   \        \        P                  R+4      hVR8X  d-   V P                  '       d   \        \        P                  R,4      hVRM9   d@   V P                  '       d.   \        \        P                  R-V: R.V P                  : R/24      hVRN9   d-   V P                  '       d   \        \        P                  R04      hVR"8X  d-   V P                  '       d   \        \        P                  R14      hVRO9   d@   V P                  '       d.   \        \        P                  R2V: R.V P                  : R/24      hM!\        \        P                  R3V,          4      h\        V4      ^ 8  d   V\        V4      ^,
          ,          MR4p	V	R48X  d   V'       gn   V'       df   VR8X  d   \        \        P                  R54      hVR8X  d   \        \        P                  R64      h\        \        P                  R7V: R8V: R924      hRV9  d$   \        \        P                  R7V: R:V: R;24      hVP                  R4       E
MgV	R8X  d   VR8X  dB   VRP9  d"   \        \        P                  R<V,          4      h\         P#                  V RV4       E
MVR8X  d$    \         P#                  V R\%        V4      4       E	MV'       d0   VR8X  d   R>p
MR?V: R8V: R92p
\        \        P                  V
4      hVP                  V4       E	MV	R8X  d   VRQ9   d   WV&   E	MVRR9   d   R@VR
&   E	M\         P#                  V R\+        VP                  R4      VP                  R4      VP                  R	4      VP                  R
RA4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R8X  d   VRS9   d   WV&   EMVRR9   d   R@VR
&   EM\         P#                  V R\1        VP                  R4      VP                  R	4      VP                  R
RA4      4      4       VP-                  4        VP/                  4        V^,
          pEMZV	R8X  dT   VR8X  d3   \         P#                  V R\3        V4      4       VP-                  4        EM\        \        P                  RB4      hV	R*8X  dh   VR8X  d   WV&   EM\         P#                  V R\5        VP                  R4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R8X  dT   VR8X  d3   \         P#                  V R\7        V4      4       VP-                  4        EMR\        \        P                  RC4      hV	R8X  dx   VRT9   d   WV&   EM$\         P#                  V R\9        VP                  R4      VP                  R4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R8X  dT   VR8X  d3   \         P#                  V R\;        V4      4       VP-                  4        EMz\        \        P                  RD4      hV	R8X  dT   VR8X  d3   \         P#                  V R\=        V4      4       VP-                  4        EM \        \        P                  RE4      hV	R8X  dK   \         P#                  V R\?        4       4       VP-                  4        VP/                  4        V^,
          pEMV	R8X  d   VRU9   d   WV&   EM\         P#                  V R\A        VP                  R4      VP                  R4      VP                  R4      VP                  R4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R8X  dx   VRT9   d   WV&   EM\         P#                  V R\C        VP                  R4      VP                  R4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R 8X  d   VRV9   d   WV&   EMVR'8X  d   VP                  R'4       EMk\         P#                  V R \E        VP                  R4      VP                  R4      VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R!8X  d   VRW9   d   WV&   EMVR'8X  d   VP                  R'4       EM\         P#                  V R \G        VP                  R4      VP                  R4      VP                  R4      VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEM9V	R"8X  du   VR'8X  d   VP                  R'4       EM\         P#                  V R"\I        VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R#8X  du   VR'8X  d   VP                  R'4       EM\         P#                  V RF\K        VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEMCV	R$8X  du   VR'8X  d   VP                  R'4       EM"\         P#                  V RF\M        VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEMV	R%8X  d   VR8X  d   WV&   EMVR'8X  d   VP                  R'4       EM\         P#                  V RF\O        VP                  R4      VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pEM0V	R&8X  d   VR8X  d   WV&   EMVR'8X  d   VP                  R'4       EM\         P#                  V RF\Q        VP                  R4      VP                  R'4      4      4       VP-                  4        VP/                  4        V^,
          pMV	R'8X  d   VRX9   d	   WRGV 2&   MRHV9  d   \        \        P                  RI4      h\S        VRH,          VP                  RJ4      4      VR'&   VP-                  RHR44       VP-                  RJR44       VP-                  4        V^,
          pV^,           pEK  RK#   \&         d#    \        \        P(                  R=T,          4      hi ; i)Yz
empty ruler,   ruler   r   r$   r"   addressr9   r:   rF   rr   rc   re   to-portto-addrrW   r   r   r   
queue-sizer   r   zbad attribute '%s'r'   r*   service
icmp-block	icmp-typerw   forward-portsource-portr.   r   r0   acceptdropr   markr   notNOTr   zmore than one 'source' elementz#more than one 'destination' elementz-more than one element. There cannot be both 'z' and 'z' in one rule.zmore than one logging elementzmore than one 'audit' elementz6more than one 'action' element. There cannot be both 'zunknown element %sr8   z0'family' outside of rule. Use 'rule family=...'.z4'priority' outside of rule. Use 'rule priority=...'.Z'z.' outside of any element. Use 'rule <element> z= ...'.z!' outside of rule. Use 'rule ... z ...'.zH'family' attribute cannot have '%s' value. Use 'ipv4' or 'ipv6' instead.z(invalid 'priority' attribute value '%s'.zdwrong 'protocol' usage. Use either 'rule protocol value=...' or  'rule [forward-]port protocol=...'.zattribute 'TFzinvalid 'protocol' elementzinvalid 'service' elementzinvalid 'icmp-block' elementzinvalid 'icmp-type' elementr2   zlimit.zlimit.valuezinvalid 'limit' elementzlimit.burstN)r$   r"   r   r9   r:   rF   rr   rc   re   r   r   rW   r   r   r   r   r   r   r   )re   r   rc   r   r   rw   r   r   )r.   r   )r   r   r   r   ipv4Zipv6)r   r9   r:   rF   )r   r   )r   r:   rF   rk   )rc   re   r   r   )r   r   )r   r   r   r   )*r   r   r=   r   ZstripNonPrintableCharactersr   Zgetr   r'   r*   r,   r.   r0   r2   r{   r   r>   r?   r   Z
ValueErrorINVALID_PRIORITYr5   ZpopZclearrR   rq   r~   rT   r\   rx   r}   rv   r   rp   r   r   r   r   r   r   r   r   )r   r   r   ZattrsZin_elementsZindexZcurrent_elementr   r   Z
in_elementZerr_msgs   &&         r   r   ZRich_Rule._import_from_string  s[    3 3\BB88BX&fQimmI.#5 3 3\BB=$$Y/36;6(;R$m//	:O))+6I**<8J  % * (++-AI-M +2 #!  "!#/' 2 '(2t{{{+"//1Q  )M9d>N>N>N+"//1V  (	
 !LLL+"//.> 
 ),<<+"//1P  )G3


+"//1P  (+OO KKK+"//.=  (++-AO-S 
 695E5IC,q01r  R&9 H,+"//N  #j0+"//R 
 ,"//()5 
 ?2'++*O=   &&v.v%(!)99+"//f() 
 &&tXzB*,**4S_M  J. #I /
  ))5   ((;(;WEE&&7x' EE'1)$$6&*E(O&& #!IIi0!IIe,!IIg.!IIh6		  OO%KKM!AIE}, >>'1)$$6&*E(O&&%(!IIi0!IIg.!IIh6  OO%KKM!AIEz)'&&tYj8QROO%'++-I  .''1)$&&i);EIIg<N)O  OO%KKM!AIEy(&&&tYZ8PQOO%'++-H  v% 44'1)$&&!!%))F"3UYYz5JK
  OO%KKM!AIE|+&&&tYz8RSOO%'++-K  {*&&&tYj8QROO%'++-J  |+""4O4EF!	~- JJ'1)$&&!(!IIf-!IIj1!IIi0!IIi0		  OO%KKM!AIE}, 44'1)$&&!'		&(9599Z;PQ
  OO%KKM!AIEu$ 33'1)$$/&&w/&& !IIh/71CUYYwEW  OO%KKM!AIEw& AA'1)$$/&&w/&&"!IIg.!IIh/!IIl3!IIg.		  OO%KKM!AIEw&"g-&&w/&&tWj7AS6TUOO%KKM!AIEx'"g-&&w/&&tX{599WCU7VWOO%KKM!AIEv%"g-&&w/&&tXy7AS7TUOO%KKM!AIEx'&'1)$$/&&w/&& #EIIf$5uyy7IJ
  OO%KKM!AIEv%%'1)$$/&&w/&&h	%))E2BEIIgDV(W  OO%KKM!AIEw& 222<F9+./$E1+"//1J  &0m,eii.F&E'N IImR0IImR0OO%!AIEAIEM <Sh & +"33FS s   	 x' '-yc                s   V P                   '       d7   V P                   R9  d%   \        \        P                  V P                   4      hMV P                  e   V P                  P
                  '       g   V P                  e   \        \        P                  4      h\        V P                  \        4      '       d   \        \        P                  4      hV P                  V P                  8  g   V P                  V P                  8  d8   \        \        P                  RV P                  V P                  3,          4      hV P                  f   V P                  e    V P                  e   V P                  ^ 8X  dp   V P                   f   \        \        P"                  R4      hV P                  f:   V P                  f,   V P                  ^ 8X  d   \        \        P"                  R4      h\%        V P                  4      \&        \        \(        \*        39  dE   V P                  f7   V P,                  f)   V P                   f   \        \        P"                  R4      hV P                  '       d   V P                  P
                  '       d   V P                   '       g   \        \        P                  4      h\.        P0                  ! V P                   V P                  P
                  4      '       g8   \        \        P2                  \5        V P                  P
                  4      4      hV P                  '       d   V P                  P
                  '       ds   \.        P0                  ! V P                   V P                  P
                  4      '       g8   \        \        P2                  \5        V P                  P
                  4      4      h\        V P                  \(        4      '       do   V P                   e   \        \        P"                  R4      hV P                  e7   V P                  P6                  '       d   \        \        P"                  R4      hEM\        V P                  \&        4      '       d/   V P                   '       d   \        \        P"                  R4      hEMQ\        V P                  \        4      '       d   V P                  P8                  R	8w  dj   \.        P:                  ! V P                   V P                  P8                  4      '       g/   \        \        P2                  V P                  P8                  4      hV P                   '       g   \        \        P                  4      hV P                   e   \        \        P"                  R
4      hMY\        V P                  \*        4      '       d:   V P                   e,   \        \        P"                  RV P                   ,          4      hV P,                  eW   \%        V P                   4      \<        \>        \@        39  d.   \        \        PB                  \%        V P                   4      4      h\        V P                   \>        4      '       d   V P                   P$                  '       d   V P                   R9  d   \        \        P"                  R4      hV P                   P$                  \D        V P                   ,          9  d^   RPG                  \D        V P                   ,          4      p\        \        P"                  RV P                   P$                  : RV: R24      hR# R# R# )r   Nz/'priority' attribute must be between %d and %d.zno element, no actionz%no element, no source, no destinationzno action, no log, no auditzmasquerade and actionzmasquerade and mac sourcezicmp-block and actionr8   zforward-port and actionz+tcp-mss-clamp and %s are mutually exclusivez9When using reject type you must specify also rule family.z, zWrong reject type z.
Use one of: Z.r   )$r"   r   r   ZINVALID_FAMILYr'   r7   r*   ZMISSING_FAMILYZ
isinstancer,   r   r$   priority_minpriority_maxr   r.   r2   r=   r   rx   rv   r~   r0   r   Zcheck_addressZINVALID_ADDRr@   r9   r   Zcheck_single_addressr   r   r   ZINVALID_AUDIT_TYPEr   Zjoin)r   Zvalid_typesrH   r   r   ZRich_Rule.checkS  s   ;;;{{"22#F$9$94;;GG 3 'DKK,<,<,<!!-#F$9$9::$,,(899#F$9$9::==4,,,@Q@Q0Q''A$$d&7&789  <<HH!5$--1:L{{"#F$7$79PQQ{{"t'7'7'?DMMUVDV#'')P  	&
 
 xxDJJ$64;;;N#F$7$79VWW;;;4;;+++;;;#F$9$9::**4;;8H8HII#F$7$7T[[=M=M9NOO 0 0 5 5 5**4;;8H8H8M8MNN#F$7$7T=M=M=R=R9STTdllO44{{&#F$7$79PQQ{{&4;;???#F$7$79TUUn55{{{#F$7$79PQQ &677||&&",Y5S5ST\\446 6 $F$7$79P9PQQ;;;#F$9$9::{{&#F$7$79RSS '&899{{&#''ADKKO 
 ::!DKK k9(MM#F$=$=tDKK?PQQdkk;//{{;;&66'++S  ;;##<+DD"&))L,E"FK'++;;++[:  E   0r   c                s   R pV P                   '       d   VRV P                   ,          ,          pV P                  '       d   VRV P                  ,          ,          pV P                  '       d   VRV P                  ,          ,          pV P                  '       d   VRV P                  ,          ,          pV P                  '       d   VRV P                  ,          ,          pV P
                  '       d   VRV P
                  ,          ,          pV P                  '       d   VRV P                  ,          ,          pV P                  '       d   VRV P                  ,          ,          pV# )r   z priority="%d"z family="%s"r   )r$   r"   r'   r*   r,   r.   r0   r2   rG   rH   r   rI   ZRich_Rule.__str__  s    ===#dmm33C;;;>DKK//C;;;54;;&&C54++++C<<<54<<''C8885488##C:::54::%%C;;;54;;&&C
r   c          
      s   < V ^8  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   S[S[,          ;R&   S[;R&   S[;R&   S[;R&   S[;R&   S[S[S[S[	S[
S[S[S[S[.	;R&   S[;R	&   S[;R
&   S[S[S[S[.;R&   # )rJ   r   r   r   r"   r$   r'   r*   r,   r.   r0   r2   )r    r   r   r@   r5   rR   rq   r~   rT   r\   rp   r   rx   r}   rv   r   r   r   r   r   r   rL   rM   r   rN   ZRich_Rule.__annotate___  s     
 3-(  3-'  cl!        "(  	
 
 0 
1 2 3 4 +y)<C5 r   r   i )r   r   r   r   rP   r   r   r   r"   r$   r'   r*   r,   r.   r0   r2   rB   r   Zstaticmethodr   r   r   rI   rQ   r   r   r   r   r   r   r   _  s     5 #)L"'L!HFHF$(K 	  CE?CF8(  $SjYv_  r   r   Ni  iQ )0Ztypingr    Zdataclassesr   r   r   Zfirewallr   Zfirewall.core.ipsetr   Zfirewall.core.baser   r   Zfirewall.errorsr   r	   r
   r   r   r#   r%   r(   r+   r-   r/   r1   r3   r5   rR   rT   r\   rp   rq   rv   rx   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    1 1  0 +  3
( ( j
:&*1;3+/1 $d#)3 )3 $)3X $d#3 3 $3@ $d#1 1 $1 $d#K K $K" $d#R R $R" $d#4 4 $4 $   $d#4 4 $4 $d#3 3 $3 $d## # $#* $d#
 
 $
D 	  $d#? ? $?D $.
 .
 .
b $6
 6
 6
r $F F F  $G G G  $
 
 
, $E E E  $$V $V $VN $a	 a	 a	r   