+
    È4iX  ã                   óx   € R t ^ RIt^ RIt^ RIt^ RIHt RtRtRt]t	Rt
RtRtR	t ! R
 R]4      t ! R R4      tR# )z!common.py: common classes for ufwN)ÚdebugÚufwz/lib/ufwz/usr/share/ufwz/etcz/usrz	/usr/sbinTc                   ó0   a € ] tR t^!t o RtR tR tRtV tR# )ÚUFWErrorz$This class represents ufw exceptionsc                ó   € Wn         R # ©N©Úvalue)Úselfr	   s   &&Ú,/usr/lib/python3/dist-packages/ufw/common.pyÚ__init__ÚUFWError.__init__#   s   € ØŽ
ó    c                ó,   € \        V P                  4      # r   )Úreprr	   ©r
   s   &r   Ú__str__ÚUFWError.__str__&   s   € Ü�D—J‘JÓÐr   r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r   !   s   ø‡ € Ù.ò÷ ð  r   r   c                   ó¼   a € ] tR t^*t o RtRR ltR tR tR tR t	R t
RR ltR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )ÚUFWRulez$This class represents firewall rulesc
                óB  € R V n         R V n        R V n        RV n        RV n        RV n        RV n        RV n        R V n        RV n	        RV n
        RV n        ^ V n        RV n        RV n        RV n        RV n        W€n        RV n         V P'                  V4       V P)                  V4       V P+                  V4       V P+                  VR4       V P-                  V4       V P/                  V4       V P1                  V4       V P3                  V	4       R#   \4         d    h i ; i)FÚ ÚsrcN)ÚremoveÚupdatedÚv6Údstr!   ÚdportÚsportÚprotocolÚmultiÚdappÚsappÚactionÚpositionÚlogtypeÚinterface_inÚinterface_outÚ	directionÚforwardÚcommentÚ
set_actionÚset_protocolÚset_portÚset_srcÚset_dstÚset_directionÚset_commentr   )
r
   r,   r(   r&   r%   r'   r!   r1   r2   r3   s
   &&&&&&&&&&r   r   ÚUFWRule.__init__,   s  € ð ˆŒØˆŒØˆŒØˆŒØˆŒØˆŒ
ØˆŒ
ØˆŒØˆŒ
ØˆŒ	ØˆŒ	ØˆŒØˆŒØˆŒØˆÔØˆÔØˆŒØŒØˆŒð
	Ø�O‰O˜FÔ#Ø×Ñ˜hÔ'Ø�M‰M˜%Ô Ø�M‰M˜% Ô'Ø�L‰L˜ÔØ�L‰L˜ÔØ×Ñ˜yÔ)Ø×Ñ˜WÖ%øÜô 	Øð	ús   ÂB	D ÄDc                ó"   € V P                  4       # r   )Úformat_ruler   s   &r   r   ÚUFWRule.__str__O   s   € Ø×ÑÓ!Ð!r   c                ó¸   € RV ,          p\        V P                  4      pVP                  4        V F%  pVRV: RV P                  V,          : 2,          pK'  	  V# )zPrint rule to stdoutz'%s'z, Ú=)ÚlistÚ__dict__Úsort)r
   ÚresÚkeysÚks   &   r   Ú_get_attribÚUFWRule._get_attribR   sI   € à˜�oˆÜ�D—M‘MÓ"ˆØ�	‰	ŒÛˆAÙ£ 4§=¡=°×#3Ð4Õ4ŠCñ àˆ
r   c                óˆ  € \        V P                  V P                  4      pV P                  Vn        V P                  Vn        V P
                  Vn        V P                  Vn        V P                  Vn        V P                  Vn        V P                  Vn	        V P                  Vn
        V P                  Vn        V P                  Vn        V P                  Vn        V P                  Vn        V P                  Vn        V P                   Vn        V P"                  Vn        V P$                  Vn        V P&                  Vn        V# )zReturn a duplicate of a rule)r   r,   r(   r"   r#   r$   r%   r!   r&   r'   r)   r*   r+   r-   r.   r/   r0   r1   r2   r3   )r
   Úrules   & r   Údup_ruleÚUFWRule.dup_rule[   sÜ   € ä�t—{‘{ D§M¡MÓ2ˆØ—k‘kˆŒØ—|‘|ˆŒØ—'‘'ˆŒØ—8‘8ˆŒØ—8‘8ˆŒØ—Z‘ZˆŒ
Ø—Z‘ZˆŒ
Ø—Z‘ZˆŒ
Ø—I‘IˆŒ	Ø—I‘IˆŒ	ØŸ™ˆŒØ—|‘|ˆŒØ ×-Ñ-ˆÔØ!×/Ñ/ˆÔØŸ™ˆŒØ—|‘|ˆŒØ—|‘|ˆŒàˆr   c                ó  € RpV P                   R8w  d   VRV P                   ,          ,          pV P                  R8w  d   VRV P                  ,          ,          pV P                  R8X  d   VR,          pMìVRV P                  ,           ,          pV P                  '       dÁ   VR,          pV P                  R8w  dP   V P
                  R8w  d?   VRV P                  ,           ,          pVR,          pVR	V P
                  ,           ,          pMWV P                  R8w  d   VRV P                  ,           ,          pM+V P
                  R8w  d   VR	V P
                  ,           ,          pV P                  R
8w  d,   V P                  R8w  d   VRV P                  ,           ,          pV P                  '       g,   V P                  R8w  d   VRV P                  ,           ,          pV P                  R
8w  d,   V P                  R8w  d   VRV P                  ,           ,          pV P                  '       g,   V P
                  R8w  d   VRV P
                  ,           ,          pRpV P                  R8w  d   RV P                  ,           pV P                  R8X  d   VRV,          ,          pMnV P                  R8X  d,   VRV,          ,          pV P                  R8X  d
   VR,          pM2V P                  R8X  d   VRV,          ,          pMVRV,          ,          pV P                  R8w  g   V P                  R8w  dÓ   Rp\        P                  ! R4      pV P                  R8w  d+   VRVP                  RV P                  4      ,           ,          pV P                  R8w  d   V P                  R8w  d
   VR,          pV P                  R8w  d+   VRVP                  RV P                  4      ,           ,          pVR ,          pVRV,           ,          pVP                  4       # )!zFormat rule for later parsingr    z -i %sz -o %sÚanyz -p allz -p z -m multiportz
 --dports z
 --sports ú	0.0.0.0/0ú::/0z -d z	 --dport z -s z	 --sport Ú_Úallowz -j ACCEPT%sÚrejectz -j REJECT%sÚtcpz --reject-with tcp-resetÚlimitz -j LIMIT%sz
 -j DROP%sz-m comment --comment 'Ú Údapp_z%20Ú,Úsapp_Ú')r/   r0   r(   r)   r&   r'   r%   r!   r.   r,   r*   r+   ÚreÚcompileÚsubÚstrip)r
   Úrule_strÚlstrr3   Ú	pat_spaces   &    r   r=   ÚUFWRule.format_ruler   s  € àˆà×Ñ Ô"Ø˜ D×$5Ñ$5Õ6Õ6ˆHØ×Ñ Ô#Ø˜ D×$6Ñ$6Õ7Õ7ˆHð �=‰=˜EÔ!Ø˜	Õ!‰Hà˜ §¡Õ.Õ.ˆHà�z�zˆzØ˜OÕ+�Ø—:‘: Ô&¨4¯:©:¸Ô+>Ø ¨t¯z©zÕ 9Õ9�HØ Õ/�HØ ¨t¯z©zÕ 9Õ9‘HØ—Z‘Z 5Ô(Ø ¨t¯z©zÕ 9Õ9‘HØ—Z‘Z 5Ô(Ø ¨t¯z©zÕ 9Õ9�Hà�8‰8�{Ô" t§x¡x°6Ô'9Ø˜ §¡Õ)Õ)ˆHØ�z�zˆz˜dŸj™j¨EÔ1Ø˜ d§j¡jÕ0Õ0ˆHØ�8‰8�{Ô" t§x¡x°6Ô'9Ø˜ §¡Õ)Õ)ˆHØ�z�zˆz˜dŸj™j¨EÔ1Ø˜ d§j¡jÕ0Õ0ˆHàˆØ�<‰<˜2ÔØ˜Ÿ™Õ%ˆDØ�;‰;˜'Ô!Ø˜¨$Õ/Õ/‰HØ�[‰[˜HÔ$Ø˜¨$Õ/Õ/ˆHØ�}‰} Ô%àÐ6Õ6�øØ�[‰[˜GÔ#à˜¨Õ.Õ.‰Hà˜¨Õ-Õ-ˆHà�9‰9˜Œ?˜dŸi™i¨2œoà.ˆGÜŸ
š
 3›ˆIØ�y‰y˜BŒØ˜7 Y§]¡]°5¸$¿)¹)Ó%DÕDÕD�Ø�y‰y˜BŒ 4§9¡9°¤?Ø˜3•�Ø�y‰y˜BŒØ˜7 Y§]¡]°5¸$¿)¹)Ó%DÕDÕD�Ø�s�NˆGà˜˜g�Õ%ˆHà�~‰~ÓÐr   c                ó  € VP                  4       P                  R4      pV^ ,          R8X  g   V^ ,          R8X  g   V^ ,          R8X  d   V^ ,          V n        MRV n        Rp\        V4      ^8”  d
   V^,          pV P	                  V4       R# )zSets action of the rulerQ   rR   rS   rU   Údenyr    N)ÚlowerÚsplitr,   ÚlenÚset_logtype)r
   r,   Útmpr.   s   &&  r   r4   ÚUFWRule.set_actionµ   ss   € à�l‰l‹n×"Ñ" 3Ó'ˆØˆq�6�WÔ  A¥¨(Ô 2°c¸!µfÀÔ6GØ˜a�&ˆD�Kà ˆDŒKàˆÜˆs‹8�aŒ<Ø˜!•fˆGØ×Ñ˜Ö!r   c                ó<  € \        R4      V,          pVR8X  d   EM=VR8X  d   V P                  '       d   EM"VR8X  d   V P                  '       d   EM\        P                  ! RV4      '       g   \        P                  ! RV4      '       d   \        V4      hVP                  R4      VP                  R4      ,           ^8”  d   \        V4      hVP                  R4      p\        V4      ^8”  d   R	V n	        R
pV EFX  p\        P                  ! RV4      '       d€   R	V n	        VP                  R4      pV F.  p\        V4      ^8  g   \        V4      R8”  g   K%  \        V4      h	  \        V^ ,          4      \        V^,          4      8¼  d   \        V4      hM‰\        P                  ! RV4      '       d-   \        V4      ^8  g   \        V4      R8”  d   \        V4      hM@\        P                  ! RV4      '       d    \        P                  ! V4      pM\        V4      hV'       d   VR\        V4      ,           ,          pEKM  \        V4      pEK[  	  TpVR8X  d   \        V4      V n        R# \        V4      V n        R#   \         d    \        T4      hi ; i)z:Sets port and location (destination or source) of the rulezBad port '%s'rN   r%   r!   z^[,:]z[,:]$rX   Ú:Tr    z	^\d+:\d+$iÿÿ  z^\d+$z
^\w[\w\-]+N)rQ   r*   r+   r[   Úmatchr   Úcountrf   rg   r)   ÚintÚsocketÚgetservbynameÚ	ExceptionÚstrr'   r&   )	r
   ÚportÚlocÚerr_msgÚportsri   ÚpÚranÚqs	   &&&      r   r6   ÚUFWRule.set_portÂ   s  € ä�OÓ$¨Õ-ˆØ�5Œ=ÙØ�EŒ\˜dŸiŸi˜iÙØ�EŒ\˜dŸiŸi˜iÙÜ�XŠX�h ×%Ò%¬¯ª°(¸D×)AÒ)AÜ˜7Ó#Ð#Ø�j‰j˜‹o §
¡
¨3£Õ/°2Ô5ä˜7Ó#Ð#à—J‘J˜s“OˆEÜ�5‹z˜AŒ~Ø!�”
àˆCÜ�Ü—8’8˜L¨!×,Ò,à!%�D”JØŸ'™' #›,�CÛ ˜Ü˜q›6 Aœ:¬¨Q«°%®Ü"*¨7Ó"3Ð3ñ !ô ˜3˜q�6“{¤c¨#¨a­&£kÔ1Ü& wÓ/Ð/ð 2ä—X’X˜h¨×*Ò*Ü˜1“v ”z¤S¨£V¨e¤^Ü& wÓ/Ð/ð &4ä—X’X˜m¨Q×/Ò/ð0Ü"×0Ò0°Ó3™ô # 7Ó+Ð+çØ˜3¤ Q£�<Õ'“Cä˜a›&“Cñ1 ð4 ˆDà�%Œ<Ü˜T›ˆDŽJä˜T›ˆDŽJøô %ô 0Ü& wÓ/Ð/ð0ús   ÈJÊJc                óš   € V\         P                  P                  R.,           9   d	   Wn        R# \	        R4      V,          p\        V4      h)zSets protocol of the rulerN   zUnsupported protocol '%s'N)r   ÚutilÚsupported_protocolsr(   rQ   r   )r
   r(   rv   s   && r   r5   ÚUFWRule.set_protocol÷   s;   € à”s—x‘x×3Ñ3°u°gÕ=Ô=Ø$ŽMäÐ3Ó4¸ÕAˆGÜ˜7Ó#Ð#r   c                ó  € V P                   '       d}   V P                  '       d*   V P                  R8X  g   V P                  R8X  d   RV n        V P                  '       d.   V P                  R8X  g   V P                  R8X  d
   RV n        R# R# R# V P                  '       d*   V P                  R8X  g   V P                  R8X  d   RV n        V P                  '       d.   V P                  R8X  g   V P                  R8X  d
   RV n        R# R# R# )zAdjusts src and dst based on v6rN   rO   rP   N)r$   r%   r!   r   s   &r   Ú_fix_anywhereÚUFWRule._fix_anywhereÿ   sµ   € à�7�7ˆ7Ø�x�xˆx˜TŸX™X¨Ô.°$·(±(¸kÔ2IØ!�”Ø�x�xˆx˜TŸX™X¨Ô.°$·(±(¸kÔ2IØ!�–ñ 3J‰xð �x�xˆx˜TŸX™X¨Ô.°$·(±(¸fÔ2DØ&�”Ø�x�xˆx˜TŸX™X¨Ô.°$·(±(¸fÔ2DØ&�–ñ 3E‰xr   c                ó2   € Wn         V P                  4        R# )zESets whether this is ipv6 rule, and adjusts src and dst
accordingly.
N)r$   r�   )r
   r$   s   &&r   Úset_v6ÚUFWRule.set_v6  s   € ð ŒØ×ÑÖr   c                óØ   € VP                  4       pVR8w  d=   \        P                  P                  VR4      '       g   \	        R4      p\        V4      hW n        V P                  4        R# )zSets source address of rulerN   zBad source addressN)re   r   r}   Úvalid_addressrQ   r   r!   r�   ©r
   Úaddrri   rv   s   &&  r   r7   ÚUFWRule.set_src  sQ   € à�j‰j‹lˆà�%Œ<¤§¡× 6Ñ 6°s¸E× BÒ BÜÐ,Ó-ˆGÜ˜7Ó#Ð#ØŒØ×ÑÖr   c                óØ   € VP                  4       pVR8w  d=   \        P                  P                  VR4      '       g   \	        R4      p\        V4      hW n        V P                  4        R# )z Sets destination address of rulerN   zBad destination addressN)re   r   r}   r‡   rQ   r   r%   r�   rˆ   s   &&  r   r8   ÚUFWRule.set_dst  sQ   € à�j‰j‹lˆà�%Œ<¤§¡× 6Ñ 6°s¸E× BÒ BÜÐ1Ó2ˆGÜ˜7Ó#Ð#ØŒØ×ÑÖr   c                ó°  € VR8w  d   VR8w  d   \        R4      p\        V4      hR\        V4      9   d   \        R4      p\        V4      hR\        V4      9   d   \        R4      p\        V4      h\        V4      R8X  g   \        V4      R	8X  d   \        R
4      p\        V4      h\        \        V4      4      ^ 8X  d   \        R4      p\        V4      h\        \        V4      4      ^8”  d   \        R4      p\        V4      h\        P
                  ! R\        V4      4      '       g   \        R4      p\        V4      hVR8X  d	   W n        R# W n        R# )zSets an interface for ruleÚinÚoutzBad interface typeÚ!z+Bad interface name: reserved character: '!'rl   z/Bad interface name: can't use interface aliasesÚ.z..z)Bad interface name: can't use '.' or '..'z+Bad interface name: interface name is emptyz+Bad interface name: interface name too longz^[a-zA-Z0-9_\-\.\+,=%@]+$zBad interface nameN)rQ   r   rs   rg   r[   rm   r/   r0   )r
   Úif_typeÚnamerv   s   &&& r   Úset_interfaceÚUFWRule.set_interface'  s(  € ð �dŒ?˜w¨%Ô/ÜÐ,Ó-ˆGÜ˜7Ó#Ð#ð ”#�d“)ÔÜÐEÓFˆGÜ˜7Ó#Ð#à”#�d“)ÔÜÐIÓJˆGÜ˜7Ó#Ð#äˆt‹9˜Ôœs 4›y¨DÔ0ÜÐCÓDˆGÜ˜7Ó#Ð#ä”�D“	‹N˜aÔÜÐEÓFˆGÜ˜7Ó#Ð#ä”�D“	‹N˜RÔÜÐEÓFˆGÜ˜7Ó#Ð#ô �xŠxÐ4´c¸$³i×@Ò@ÜÐ,Ó-ˆGÜ˜7Ó#Ð#à�dŒ?Ø $Öà!%Ör   c                óÌ   € \        V4      R8w  dD   \        P                  ! R\        V4      4      '       g   \        R4      V,          p\	        V4      h\        V4      V n        R# )zSets the position of the rulez-1z^[0-9]+z,Insert position '%s' is not a valid positionN)rs   r[   rm   rQ   r   ro   r-   )r
   Únumrv   s   && r   Úset_positionÚUFWRule.set_positionW  sJ   € ô
 ˆs‹8�tÔ¤B§H¢H¨Z¼¸S»×$BÒ$BÜÐFÓGÈ3ÕOˆGÜ˜7Ó#Ð#Ü˜C›ˆŽr   c                óÌ   € VP                  4       R8X  g   VP                  4       R8X  g   VR8X  d   VP                  4       V n        R# \        R4      V,          p\        V4      h)zSets logtype of the ruleÚlogzlog-allr    zInvalid log type '%s'N)re   r.   rQ   r   )r
   r.   rv   s   && r   rh   ÚUFWRule.set_logtypea  sL   € à�=‰=‹?˜eÔ# w§}¡}£¸)Ô'CØ�bŒ=Ø"Ÿ=™=›?ˆDŽLäÐ/Ó0°GÕ<ˆGÜ˜7Ó#Ð#r   c                óh   € VR8X  g   VR8X  d	   Wn         R# \        R4      V,          p\        V4      h)zSets direction of the rulerŽ   r�   zUnsupported direction '%s'N)r1   rQ   r   )r
   r1   rv   s   && r   r9   ÚUFWRule.set_directionj  s1   € à˜Ô 	¨UÔ 2Ø&ŽNäÐ4Ó5¸ÕCˆGÜ˜7Ó#Ð#r   c                óT   € \         P                  P                  V P                  4      # )zGet decoded comment of the rule)r   r}   Ú
hex_decoder3   r   s   &r   Úget_commentÚUFWRule.get_commentr  s   € ä�x‰x×"Ñ" 4§<¡<Ó0Ð0r   c                ó   € Wn         R# )zSets comment of the ruleN)r3   )r
   r3   s   &&r   r:   ÚUFWRule.set_commentv  s   € àŽr   c                óž  € RpV P                   '       dL    \        P                  P                  V P                   V P                  4      w  V n         pT'       d   Yn        V P                  '       dL    \        P                  P                  V P                  V P                  4      w  V n	        pT'       d   Yn        V P                  '       dQ   V P                  P                  R4      p\        P                  P                  V4       RP                  V4      V n
        V P                  '       dS   V P                  P                  R4      p\        P                  P                  V4       RP                  V4      V n        R# R#   \
         d    \        R4      p\        T4      hi ; i  \
         d    \        R4      p\        T4      hi ; i)z&Normalize src and dst to standard formFz"Could not normalize source addressz'Could not normalize destination addressrX   N)r!   r   r}   Únormalize_addressr$   rr   rQ   r   r#   r%   r&   rf   Ú
human_sortÚjoinr'   )r
   Úchangedrv   rw   s   &   r   Ú	normalizeÚUFWRule.normalizez  sW  € àˆØ�8�8ˆ8ð(Ü&)§h¡h×&@Ñ&@ÀÇÁØAEÇÁó'JÑ#�”˜7÷ Ø&”à�8�8ˆ8ð(Ü&)§h¡h×&@Ñ&@ÀÇÁØCGÇ7Á7ó'LÑ#�”˜7÷ Ø&”à�:�:ˆ:Ø—J‘J×$Ñ$ SÓ)ˆEÜ�H‰H×Ñ Ô&ØŸ™ %›ˆDŒJà�:�:ˆ:Ø—J‘J×$Ñ$ SÓ)ˆEÜ�H‰H×Ñ Ô&ØŸ™ %›ˆDŽJñ øô/ ô (ÜÐ@ÓA�Ü˜wÓ'Ð'ð(ûô ô (ÜÐEÓF�Ü˜wÓ'Ð'ð(ús   –<F Á3<F* Æ"F'Æ*"Gc                ó~  € V '       d	   V'       g   \        4       hRV : RV: R2pV P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P
                  VP
                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8w  d   \        V4       ^# V P                  VP                  8X  dO   V P                  VP                  8X  d4   V P                   VP                   8X  d   \#        R4      p\        V4       ^ # V P                  VP                  8X  dO   V P                  VP                  8X  d4   V P                   VP                   8w  d   \#        R4      p\        V4       R# \#        R4      RV P                  RVP                  R	V P                  R
VP                  RV P                   RVP                   /,          p\        V4       R# )zŠCheck if rules match
Return codes:
  0  match
  1  no match
 -1  match all but action, log-type and/or comment
 -2  match all but comment
z
No match 'z' 'rZ   zFound exact matchz$Found exact match, excepting commentzZFound non-action/non-logtype/comment match (%(xa)s/%(ya)s/'%(xc)s' %(xl)s/%(yl)s/'%(yc)s')ÚxaÚyaÚxlÚylÚxcÚycéþÿÿÿéÿÿÿÿ)Ú
ValueErrorr&   r   r'   r(   r!   r%   r$   r*   r+   r/   r0   r1   r2   r,   r.   r3   rQ   )ÚxÚyÚdbg_msgs   && r   rm   ÚUFWRule.match�  s=  € ÷ ŸÜ“,Ðð ó +,«QÐ/ˆØ�7‰7�a—g‘gÔÜ�'ŒNÙØ�7‰7�a—g‘gÔÜ�'ŒNÙØ�:‰:˜Ÿ™Ô#Ü�'ŒNÙØ�5‰5�A—E‘EŒ>Ü�'ŒNÙØ�5‰5�A—E‘EŒ>Ü�'ŒNÙØ�4‰4�1—4‘4Œ<Ü�'ŒNÙØ�6‰6�Q—V‘VÔÜ�'ŒNÙØ�6‰6�Q—V‘VÔÜ�'ŒNÙØ�>‰>˜QŸ^™^Ô+Ü�'ŒNÙØ�?‰?˜aŸo™oÔ-Ü�'ŒNÙØ�;‰;˜!Ÿ+™+Ô%Ü�'ŒNÙØ�9‰9˜Ÿ	™	Ô!Ü�'ŒNÙØ�8‰8�q—x‘xÔ A§I¡I°·±Ô$:Ø—	‘	˜QŸY™YÔ&ÜÐ+Ó,ˆGÜ�'ŒNÙØ�8‰8�q—x‘xÔ A§I¡I°·±Ô$:Ø—	‘	˜QŸY™YÔ&ÜÐ>Ó?ˆGÜ�'ŒNØˆIäð Fó Gà˜AŸH™H d¨A¯H©HØ˜AŸI™I t¨Q¯Y©YØ˜AŸI™I t¨Q¯Y©Yð8õ9ˆô
 	ˆgŒØˆ	r   c                ó¶	  € R pV '       d	   V'       g   \        4       hV P                  V4      ^ 8X  d   ^ # RV : RV P                  : RV: RVP                  : R2	pVP                  R8w  d   \	        RV,           R,           4       ^# VP
                  V P
                  8w  d   \	        VR	,           4       ^# V P                  VP                  8w  d&   VP                  R
8w  d   \	        RV,           4       ^# VP                  R
8w  d8   V! V P                  VP                  4      '       g   \	        RV,           4       ^# VP                  R8X  Ed;   V P                  R8X  d$   V P                  V P                  4      '       d   EM”V P                  VP                  8w  d&   RVP                  9  d   \	        RV,           4       ^# V P                  VP                  8w  dª   RVP                  9   d™   V P                  VP                  8X  d~   \        P                  P                  V P                  VP                  V P                  4      '       g9   \	        RV,           RV P                  : RVP                  : R2,           4       ^# EMŽV P                  R8w  dT   V P                  VP                  8w  d9   \	        RV,           RV P                  : RVP                  : R2,           4       ^#  \        P                  P                  VP                  V P                  4      pTP                  T8w  d@   RTP                  9  d/   \	        RT,           RTP                  : RT: R2,           4       ^# TP                  T8w  d•   RTP                  9   d„   T P                  TP                  8X  di   \        P                  P                  YAP                  T P                  4      '       g/   \	        RT,           RT: RTP                  : R2,           4       ^# V P                  VP                  8w  d9   \	        RV,           RV P                  : RVP                  : R2,           4       ^# \	        RV : RV P                  : RV: RVP                  : R2	4       R#   \         d/    \	        RT,           RTP                  ,          ,           4        ^# i ; i)a`  This will match if x is more specific than y. Eg, for protocol if x
is tcp and y is all or for address if y is a network and x is a
subset of y (where x is either an address or network). Returns:

 0  match
 1  no match
-1  fuzzy match

This is a fuzzy destination match, so source ports or addresses
are not considered, and (currently) only incoming.
c                ó  € RV 9   g   RV 9   d   W8X  d   R# R# VP                  R4       F_  pW8X  d    R# RV9   g   K  VP                  R4      w  r4\        V 4      \        V4      8¼  g   KC  \        V 4      \        V4      8:  g   K^   R# 	  R# )z:Returns True if p is an exact match or within a multi rulerX   rl   TF)rf   ro   )Útest_pÚto_matchrt   ÚlowÚhighs   &&   r   Ú_match_portsÚ-UFWRule.fuzzy_dst_match.<locals>._match_portsì  ss   € à�fŒ}  v¤ØÔ%ÙÙà Ÿ™ sÖ+�Ø”>ÚØ˜$–;Ø"&§*¡*¨S£/‘K�SÜ˜6“{¤c¨#£hÖ.´3°v³;Ä#ÀdÃ)Ö3KÚ#ñ ,ñ r   zNo fuzzy match 'z (v6=z)' 'z)'rŽ   z(direction) z (not incoming)z (forward does not match)rN   z(protocol) z(dport) r    Ú/z(dst) z ('z' not in network 'z')z(interface) z (z != Ú)z %s does not existz(v6) z(fuzzy match) 'r´   )rµ   rm   r$   r1   r   r2   r(   r&   r/   Ú_is_anywherer%   r   r}   Ú
in_networkÚget_ip_from_ifÚIOError)r¶   r·   rÀ   r¸   Úif_ips   &&   r   Úfuzzy_dst_matchÚUFWRule.fuzzy_dst_matchà  sU  € ò	÷" ŸÜ“,Ðð �7‰7�1‹:˜Œ?Ùð ó �q—t”t›Q §¤ð&ˆð �;‰;˜$ÔÜ�. 7Õ*Ð->Õ>Ô?Ùð �9‰9˜Ÿ	™	Ô!Ü�'Ð7Õ7Ô8Ùð �:‰:˜Ÿ™Ô#¨¯
©
°eÔ(;Ü�- 'Õ)Ô*Ùð �7‰7�eÔ¡L°·±¸!¿'¹'×$BÒ$BÜ�*˜wÕ&Ô'Ùà�>‰>˜RÕð �~‰~ Ô#¨¯©°q·u±u×(=Ò(=ñ Ø—‘˜!Ÿ%™%” C¨q¯u©uÔ$4Ü�h Õ(Ô)ÙØ—‘˜!Ÿ%™%” C¨1¯5©5¤L°Q·T±T¸Q¿T¹T´\Ü—8‘8×&Ñ& q§u¡u¨a¯e©e°Q·T±T×:Ò:Ü�h Ö(Ø—u”u˜aŸeœeð,%õ %ô &áùð �~‰~ Ô#¨¯©¸!¿.¹.Ô(HÜ�n wÖ.Ø—~”~ q§~¤~ð27õ 7ô 8áðÜŸ™×/Ñ/°·±ÀÇÁÓE�ð �u‰u˜Œ~ #¨Q¯U©UÔ"2Ü�n wÖ.Ø—u”u›eð2%õ %ô &áØ—‘˜%” C¨1¯5©5¤L°Q·T±T¸Q¿T¹T´\Ü—8‘8×&Ñ& u¯e©e°Q·T±T×:Ò:Ü�n wÖ.Û7<¸a¿e¼eÐDõEô Fáà�4‰4�1—4‘4Œ<Ü�'˜GÖ#°q·u´u¸a¿e¼eÐ&DÕDÔEÙõ 	»1¸a¿d¼dÃAÀqÇtÄtÐLÔMØˆ	øô+ ô Ü�n wÕ.Ð1EØ—~‘~õ2'õ 'ô (âðús   Ë14R Ò5SÓSc                ó&   € VR8X  g   VR8X  d   R# R# )zCheck if address is anywhererP   rO   TF© )r
   r‰   s   &&r   rÄ   ÚUFWRule._is_anywhereN  s   € à�6Œ>˜T [Ô0ÙÙr   c                ó  € RpV P                   R8w  g   V P                  R8w  Edb   V P                   : RV P                  : RV P                  : RV P                  : 2pV P                   R8X  d:   V P                  : RV P                  : RV P                  : RV P                  : 2pV P                  R8X  d:   V P                   : RV P                  : RV P
                  : RV P                  : 2pV P                  R8X  d.   V P                  R8X  d   VRV P                  ,          ,          pV# V P                  R8w  d   VRV P                  ,          ,          pV P                  R8w  d   VRV P                  ,          ,          pV# )a{  Returns a tuple to identify an app rule. Tuple is:
  dapp dst sapp src direction_iface|direction
or
  dport dst sapp src direction_iface|direction
or
  dapp dst sport src direction_iface|direction

where direction_iface is of form 'in_eth0', 'out_eth0' or
'in_eth0 out_eth0' (ie, both interfaces used). If no interfaces are
specified, then tuple ends with the direction instead.
r    rV   z %sz in_%sz out_%s)	r*   r+   r%   r!   r&   r'   r/   r0   r1   )r
   Útupls   & r   Úget_app_tupleÚUFWRule.get_app_tupleT  s  € ð ˆØ�9‰9˜Œ?˜dŸi™i¨2�oØ$(§I¤I¨t¯x¬x¸¿¼ÀDÇHÃHÐMˆDØ�y‰y˜BŒØ(,¯
¬
°D·H´H¸d¿i¼iØ)-¯«ð3�à�y‰y˜BŒØ(,¯	¬	°4·8´8¸T¿Z¼ZØ)-¯«ð3�ð × Ñ  BÔ&¨4×+=Ñ+=ÀÔ+CØ˜ §¡Õ0Õ0�ð ˆð ×$Ñ$¨Ô*Ø˜H¨×(9Ñ(9Õ:Õ:�DØ×%Ñ%¨Ô+Ø˜I¨×);Ñ);Õ<Õ<�Dàˆr   c                óP  € V P                   R8w  dJ   V P                  R8w  g   V P                  R8w  d(   \        R4      V P                   ,          p\	        V4      hV P                   \
        P                  P                  9   d/   VR8X  d(   \        R4      V P                   ,          p\	        V4      hV P                   \
        P                  P                  9   dL   V P                  R8w  g   V P                  R8w  d(   \        R4      V P                   ,          p\	        V4      hR# R# )zVerify rulerN   r    z3Improper rule syntax ('%s' specified with app rule)r$   z'Invalid IPv6 address with protocol '%s'zInvalid port with protocol '%s'N)r(   r+   r*   rQ   r   r   r}   Úipv4_only_protocolsÚportless_protocolsr&   r'   )r
   Úrule_iptyperv   s   && r   ÚverifyÚUFWRule.verifyv  sà   € ð �=‰=˜EÔ!Ø�I‰I˜ŒO˜tŸy™y¨BœÜÐMÓNØŸ=™=õ*ˆGä˜7Ó#Ð#à�=‰=œCŸH™H×8Ñ8Ô8Ø˜$ÔäÐAÓBØŸ™õ(ˆGä˜7Ó#Ð#à�=‰=œCŸH™H×7Ñ7Ô7Ø�z‰z˜UÔ" d§j¡j°EÔ&9ÜÐ=Ó>Ø!Ÿ]™]õ,�ä˜wÓ'Ð'ñ ':ñ 8r   )r,   r3   r*   r1   r&   r%   r2   r/   r0   r.   r)   r-   r(   r"   r+   r'   r!   r#   r$   N)rN   rO   rN   rO   rŽ   Fr    )r%   )r   r   r   r   r   r   r   rG   rK   r=   r4   r6   r5   r�   r„   r7   r8   r”   r˜   rh   r9   r¡   r:   rª   rm   rÉ   rÄ   rÐ   rÖ   r   r   r   s   @r   r   r   *   s�   ø‡ € Ù.ô!òF"òòò.A òF"ô3#òj$ò'òòòò.&ò`!ò$ò$ò1òò!)òFAòFlò\ò ÷D(ð (r   r   )r   r[   rp   Úufw.utilr   r   ÚprogramNameÚ	state_dirÚ	share_dirÚ	trans_dirÚ
config_dirÚ
prefix_dirÚiptables_dirÚ	do_checksrr   r   r   rÌ   r   r   Ú<module>rá      sV   ðÙ 'ó" 
Û Û Ý à€Ø€	Ø€	Ø€	Ø€
Ø€
Ø€Ø€	ô ˆyô  ÷`	(ó `	(r   