+
    È4i€  ã                   óH  € R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIt^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtHt RtRt. R6Ot. R7OtRR.tR tR	 tR
 tR tR tR8R ltR t R t!R t"R t#R9R lt$R t%R t&R t'R9R lt(R t)]PT                  R3R lt+R t,R t-R t.R t/]	P`                  ! 4       3R lt1]	P`                  ! 4       3R lt2R  t3R! t4R" t5R# t6R$ t7R% t8R& t9R' t:R:R( lt;R;R) lt<R* t=R<R+ lt>R, t?R- t@R. tAR/ tBR0 tCR1 tDR2 tER3 tFR=R4 ltGR5 tHR# )>z"util.py: utility functions for ufw)Úprint_functionN)Úreduce)ÚmkstempÚmktempFÚipv6Úigmpc                ó  € Rp \         P                  ! V 4        \         P                  ! T R4       Rp \         P                  ! T R4       TR8X  d   RpT# Rp T#   \         d    h i ; i  \         d     LEi ; i  \         d     T# i ; i)z8Get the protocol for a specified port from /etc/servicesÚ ÚtcpÚudpÚany)ÚsocketÚgetservbynameÚ	Exception)ÚportÚprotos   & Ú*/usr/lib/python3/dist-packages/ufw/util.pyÚget_services_protor   .   s©   € à€EðÜ×Ò˜TÔ"ðÜ×Ò˜T 5Ô)ØˆðÜ×Ò˜T 5Ô)Ø�EŒ>ØˆEð €Lð	 ‰Eð €Løô% ô Øðûô ô Ùðûô ô Øà€Lðús3   „A ›A, µ A= ÁA= ÁA)Á,A:Á9A:Á=BÂBc                ó0  € RpRpV P                  R4      p\        V4      ^8X  d   V^ ,          pRpW3# \        V4      ^8X  d?   V^ ,          pV^,          pV\        9   d   \        RV,          4      p\	        V4      h W3# \        R4      p\	        V4      h)zParse port or port and protocolr	   Ú/r   zInvalid port with protocol '%s'zBad port)ÚsplitÚlenÚportless_protocolsÚ_Ú
ValueError)Úp_strr   r   ÚtmpÚerr_msgs   &    r   Úparse_port_protor   H   s¥   € à€DØ€EØ
�+‰+�cÓ
€CÜ
ˆ3ƒx�1„}Ø�1�vˆØˆð ˆ=Ðô 
ˆS‹�QŒØ�1�vˆØ�A•ˆØÔ&Ô&ÜÐ9¸EÕAÓBˆGÜ˜WÓ%Ð%ð 'ð ˆ=Ðô �J“-ˆÜ˜Ó!Ð!ó    c                óÄ  € \         P                  '       g   \        R4       R# \        V 4      ^+8”  g   \        P
                  ! RV 4      '       g   R# V P                  R4      p \         P                  ! \         P                  V^ ,          4       \        T4      ^8”  d   R# \        T4      ^8X  d   \        T^,          R4      '       g   R# R#   \         d     R# i ; i)zVerifies if valid IPv6 addressz"python does not have IPv6 support.Fz^[a-fA-F0-9:\./]+$r   T)r   Úhas_ipv6Úwarnr   ÚreÚmatchr   Ú	inet_ptonÚAF_INET6r   Ú_valid_cidr_netmask©ÚaddrÚnets   & r   Úvalid_address6r+   \   s¨   € ä�?�?ˆ?ÜÐ1Ô2Ùô ˆ4ƒy�2„~œRŸXšXÐ&;¸T×BÒBÙà
�*‰*�S‹/€CðÜ×ÒœŸ™¨#¨a­&Ô1ô ˆ3ƒx�!„|ÙÜ	ˆS‹�QŒä" 3 q¥6¨4×0Ò0Ùáøô ô Úðús   Á%,C ÃCÃCc                ó¶  € \        V 4      ^8”  g   \        P                  ! RV 4      '       g   R# V P                  R4      p \        P
                  ! \        P                  V^ ,          4       \        V^ ,          R4      '       g   R#  \        T4      ^8”  d   R# \        T4      ^8X  d   \        T^,          R4      '       g   R# R#   \         d     R# i ; i)zVerifies if valid IPv4 addressz^[0-9\./]+$Fr   T)
r   r#   r$   r   r   r%   ÚAF_INETÚ_valid_dotted_quadsr   Úvalid_netmaskr(   s   & r   Úvalid_address4r0   v   s«   € ô ˆ4ƒy�2„~œRŸXšX n°d×;Ò;Ùà
�*‰*�S‹/€CðÜ×ÒœŸ™¨¨Q­Ô0ä" 3 q¥6¨5×1Ò1Ùð 2ô
 ˆ3ƒx�!„|ÙÜ	ˆS‹�QŒä˜S �V U×+Ò+Ùáøô ô Úðús   ÁAC	 Ã	CÃCc                ó>   € \        W4      ;'       g    \        W4      # )z(Verifies if valid cidr or dotted netmask)r'   r.   )ÚnmÚv6s   &&r   r/   r/   �   s   € ä˜rÓ&×EÐEÔ*=¸bÓ*EÐEr   c                ó    € VR8X  d   \        V 4      # VR8X  d   \        V 4      # VR8X  d   \        V 4      ;'       g    \        V 4      # \        h)zValidate IP addressesÚ6Ú4r   )r+   r0   r   )r)   Úversions   &&r   Úvalid_addressr8   š   sL   € à�#„~Ü˜dÓ#Ð#Ø	�CŒÜ˜dÓ#Ð#Ø	�EÔ	Ü˜dÓ#×;Ð;¤~°dÓ';Ð;ä
Ðr   c                ó€  € . pRpRp\         P                  pV'       d   Rp\         P                  pRV 9   dT   V P                  R4      pV'       d   V^,          R8X  d   V^ M9V'       g    V^,          R8X  g   V^,          R8X  d   V^ MVP	                  V 4       V'       gA   \        V4      ^8X  d1   \        V^,          V4      '       d    \        V^,          V4      V^&   V^ ,          p\         P                  ! V\         P                  ! WV4      4      pWb^ ,          8w  d   Rp\        V4      ^8X  dK   VRV^,          ,           ,          pV'       g,   \        V4      pWv8w  d   R	V: R
V: R2p\        V4       TpRp\        Wd4      '       g   RV,          p\        V4       \        hWc3#   \         d     LØi ; i)z¼Convert address to standard form. Use no netmask for IP addresses. If
netmask is specified and not all 1's, for IPv4 use cidr if possible,
otherwise dotted netmask and for IPv6, use cidr.
Fr6   r5   r   Ú128Ú32z255.255.255.255TzUsing 'z' for address 'Ú'zInvalid address '%s')r   r-   r&   r   Úappendr   r.   Ú_dotted_netmask_to_cidrr   Ú	inet_ntopr%   Ú_address4_to_networkÚdebugr8   r   )	Úorigr3   r*   Úchangedr7   Ús_typer)   ÚnetworkÚdbg_msgs	   &&       r   Únormalize_addressrG   ¦   sy  € ð
 €CØ€GØ€GÜ�^‰^€Fß	ØˆÜ—‘ˆà
ˆd„{Ø�j‰j˜‹oˆç�#�a•&˜E”/Ø�A‘ß˜˜Q� 4œ¨3¨q­6Ð5FÔ+FØ�A�øà�
‰
�4Ôç”#�c“(˜a”-Ô$7¸¸A½À×$CÒ$Cð	Ü,¨S°­V°RÓ8ˆC�‰Fð
 ˆq�6€Dô ×Ò˜F¤F×$4Ò$4°VÓ$BÓC€DØ�1�v„~Øˆä
ˆ3ƒx�1„}Ø��c˜!•f•ÕˆßÜ*¨4Ó0ˆGØ�Û;BÃDÐI�Ü�g”Ø�Ø�ä˜×'Ò'Ø(¨DÕ1ˆÜˆgŒÜÐàˆ?Ðøô5 ô 	áð	ús   ÃF/ Æ/F=Æ<F=c                ó   € \        V R4      # )z"Opens the specified file read-onlyÚr)Úopen)Úfns   &r   Úopen_file_readrL   Ý   s   € ä��C‹=Ðr   c                ó†   € \        V 4      p \        4       w  r#RTRT RTRT/#   \         d    TP                  4        h i ; i)z=Opens the specified file read-only and a tempfile read-write.rB   Úorignamer   Útmpname)rL   r   r   Úclose)rK   rB   r   rO   s   &   r   Ú
open_filesrQ   â   sP   € ä˜"Ó€DðÜ ›‰ˆð
 �T˜: r¨5°#°yÀ'ÐKÐKøô	 ô Ø�
‰
ŒØðús	   �# £A c                óÖ  € VR8X  d   R# V '       g   \        \        P                  R4      h\        '       d;   V \        P
                  P                  4       8X  d   \        P                  V4       R# Rp\        P                  ^ ,          ^8¼  d#   \        P                  ! V \        VR4      4      pM\        P                  ! W4      pV^ 8:  d   \        \        P                  R4      hR# )zwWrite to the file descriptor and error out of 0 bytes written. Intended
to be used with open_files() and close_files().r	   NzNot a valid file descriptorÚasciiz"Could not write to file descriptoréÿÿÿÿ)ÚOSErrorÚerrnoÚENOENTÚ
msg_outputÚsysÚstdoutÚfilenoÚwriteÚversion_infoÚosÚbytesÚEIO)ÚfdÚoutÚrcs   && r   Úwrite_to_filerd   ï   sª   € ð ˆb„yÙçÜ”e—l‘lÐ$AÓBÐB÷ ƒz�bœCŸJ™J×-Ñ-Ó/Ô/Ü×Ñ˜ÔÙà	€Bä
×Ñ˜Õ˜aÔÜ�XŠX�bœ%  WÓ-Ó.‰ä�XŠX�bÓˆà	ˆQ„wÜ”e—i‘iÐ!EÓFÐFñ r   Tc                óL  € V R,          P                  4        \        P                   ! V R,          4       V'       dK   \        P                  ! V R,          V R,          4       \        P                  ! V R,          V R,          4       \        P
                  ! V R,          4       R# )zjCloses the specified files (as returned by open_files), and update
original file with the temporary file.
rB   r   rN   rO   N)rP   r^   ÚshutilÚcopystatÚcopyÚunlink)ÚfnsÚupdates   &&r   Úclose_filesrl     sc   € ð ˆ…K×ÑÔÜ‡H‚HˆS��ZÔçÜ�Š˜˜J�¨¨Y­Ô8Ü�Š�C˜	•N C¨
¥OÔ4ä‡I‚Iˆc�)�nÖr   c                ó,  € \        V 4        \        P                  ! V \        P                  \        P                  RR7      pTP                  4       ^ ,          pTP                  \        T4      .#   \
         d   p^\        T4      .u Rp?# Rp?ii ; i)z!Try to execute the given command.T)rZ   ÚstderrÚuniversal_newlinesN)	rA   Ú
subprocessÚPopenÚPIPEÚSTDOUTrU   ÚstrÚcommunicateÚ
returncode)ÚcommandÚspÚexrb   s   &   r   Úcmdrz     sx   € ä	ˆ'„NðÜ×Ò˜g¬j¯o©oÜ%/×%6Ñ%6Ø15ô7ˆð �.‰.Ó
˜1Õ
€CØ�M‰Mœ3˜s›8Ð$Ð$øô	 ô Ø”S˜“Wˆ~Õûðús   �6A1 Á1BÁ<BÂBÂBc                ó8  €  \         P                  ! V \         P                  R7      p\         P                  ! WP                  R7      pTP                  4       ^ ,          pTP                  \        T4      .#   \         d   p^\        T4      .u Rp?# Rp?ii ; i)z#Try to pipe command1 into command2.)rZ   )ÚstdinN)rp   rq   rr   rZ   rU   rt   ru   rv   )Úcommand1Úcommand2Úsp1Úsp2ry   rb   s   &&    r   Úcmd_piper�   $  sw   € ðÜ×Ò˜x´
·±Ô@ˆÜ×Ò˜x¯z©zÔ:ˆð �/‰/Ó
˜AÕ
€CØ�N‰NœC ›HÐ%Ð%øô	 ô Ø”S˜“Wˆ~Õûðús   ‚AA7 Á7BÂBÂBÂBc                óv  €  V P                   p VP                  RR4      p\        '       d=   \        P
                  ! \        P                  4      '       d   VP                  V4       MVP                  \        V4      4       V P                  4        R#   \         d    T p L–i ; i  \         d    Tp L–i ; i)zJImplement our own print statement that will output utf-8 when
appropriate.úutf-8ÚignoreN)Úbufferr   ÚencoderX   ÚinspectÚisclassÚioÚStringIOr\   r_   Úflush)ÚoutputÚsÚwriterrb   s   &&  r   Ú_printr�   2  s�   € ðØ—‘ˆðØ�h‰h�w Ó)ˆ÷
 ƒz”g—o’o¤b§k¡k×2Ò2Ø�‰�Q�à�‰”U˜3“ZÔ Ø
‡L�L†Nøô ô ØŠðûô ô ØŠðús"   ‚B �B( ÂB%Â$B%Â(B8Â7B8c                ó¬   €  \        \        P                  RV ,          4       V'       d   \        P                  ! ^4       R# R#   \         d     L/i ; i)zPrint error message and exitz
ERROR: %s
N)r�   rY   rn   ÚIOErrorÚexit)rb   Údo_exits   &&r   Úerrorr”   G  sC   € ðÜŒs�z‰z˜=¨3Õ.Ô/÷ Ü�Š�Žñ øô ô Ùðús   ‚!A ÁAÁAc                ón   €  \        \        P                  RV ,          4       R#   \         d     R# i ; i)zPrint warning messagez	WARN: %s
N)r�   rY   rn   r‘   ©rb   s   &r   r"   r"   R  s,   € ðÜŒs�z‰z˜<¨#Õ-Ö.øÜô Úðús   ‚!% ¥4³4c                óÚ   € \         '       d   V\        P                  8X  d   \         p V'       d   \        VRV ,          4       R# \        VRV ,          4       R#   \         d     R# i ; i)zPrint messagez%s
ú%sN)rX   rY   rZ   r�   r‘   )rb   rŒ   Únewlines   &&&r   Úmsgrš   Z  sM   € çƒz�f¤§
¡
Ô*ÜˆðßÜ�6˜6 C�<Ö(ä�6˜4 #�:Ö&øÜô Úðús   ©A ±A ÁA ÁA*Á)A*c                óŠ   € \         '       d%    \        \        P                  RV ,          4       R# R#   \         d     R# i ; i)zPrint debug messagez
DEBUG: %s
N)Ú	DEBUGGINGr�   rY   rn   r‘   r–   s   &r   rA   rA   h  s8   € çƒyð	Ü”3—:‘:˜}¨sÕ2Ö3ñ øô ô 	Úð	ús   Ž!3 ³AÁAc                ó@   € \        V3R lV P                  R4      4      # )z¡
    A word-wrap function that preserves existing line breaks
    and most spaces in the text. Expects that existing line
    breaks are posix newlines (
).
    c           	      óÆ   € V : R \        V 4      V P                  R4      ,
          ^,
          \        VP                  R^4      ^ ,          4      ,           V8¬  ,          : V: 2# )z 
Ú
)r   Úrfindr   )ÚlineÚwordÚwidths   &&&r   Ú<lambda>Úword_wrap.<locals>.<lambda>w  sT   € ÚØœ#˜d›) D§J¡J¨tÓ$4Õ4°qÕ8Ü˜dŸj™j¨¨qÓ1°!Õ4Ó5õ6Ø9>ñ?÷ Aâñ	3r   Ú )r   r   )Útextr£   s   &&r   Ú	word_wrapr¨   q  s%   € ô ¨5ó ð
 —*‘*˜S“/óð r   c                ó   € \        V ^K4      # )zWord wrap to a specific width)r¨   )r§   s   &r   Ú	wrap_textrª   €  s   € ä�T˜2ÓÐr   c                ó:   a€ R oV P                  V3R lR7       R# )zýSorts list of strings into numeric order, with text case-insensitive.
Modifies list in place.

Eg:
[ '80', 'a222', 'a32', 'a2', 'b1', '443', 'telnet', '3', 'http', 'ZZZ']

sorts to:
['3', '80', '443', 'a2', 'a32', 'a222', 'b1', 'http', 'telnet', 'ZZZ']
c                 ód   € V P                  4       '       d   \        V 4      # V P                  4       # ©N)ÚisdigitÚintÚlower)Úts   &r   r¤   Úhuman_sort.<locals>.<lambda>�  s    € ˜qŸy™yŸ{š{”S˜“VÐ9°·±³	Ð9r   c                 óh   <€ \         P                  ! R V 4       Uu. uF  pS! V4      NK  	  up# u upi )z([0-9]+))r#   r   )ÚkÚcÚnorms   & €r   r¤   r²   �  s(   ø€ ¬b¯hªh°zÀ1Ô.EÓFÑ.E¨™T !žWÑ.EÒFùÒFs   ›/)ÚkeyN)Úsort)Úlstr¶   s   &@r   Ú
human_sortrº   …  s   ø€ ñ :€DØ‡H�HÔF€HÖGr   c                ó¾  €  \        V 4      p\        P                  P                  R\        T4      R4      p\        P                  P                  T4      '       g   \        RT,          4      h\        T4      P                  4       ^ ,          P                  R^4      ^,          P                  4       ^,          p\        T4      #   \         d    \        R4      hi ; i)zYFinds parent process id for pid based on /proc/<pid>/stat. See
'man 5 proc' for details.
zpid must be an integerú/procÚstatúCouldn't find '%s'Ú))r¯   r   r   r^   ÚpathÚjoinrt   Úisfiler‘   rJ   Ú	readlinesÚrsplitr   )ÚmypidÚpidÚnameÚppids   &   r   Úget_ppidrÉ   “  s°   € ð3Ü�%‹jˆô �7‰7�<‰<˜¤ S£¨6Ó2€DÜ�7‰7�>‰>˜$×ÒÜÐ*¨dÕ3Ó4Ð4ô �‹:×ÑÓ! !Õ$×+Ñ+¨C°Ó3°AÕ6×<Ñ<Ó>¸qÕA€Däˆt‹9Ðøô ô 3ÜÐ1Ó2Ð2ð3ús   ‚C ÃCc                óÒ  €  \        V 4      pT ^8X  g   T^8:  d   R# \        P                  P                  R\        T4      R4      p\        P                  P                  T4      '       g   \        R4      T,          p\        T4      h \        T4      P                  4       ^ ,          P                  4       ^,          p\        RT,          4       TR	8X  d   R
# \        T4      #   \         d    \        R4      p\        T4        R# \         d(    \        R4      \        T 4      ,          p\        T4      hi ; i  \         d    \        R4      T,          p\        T4      hi ; i)z1Determine if current process is running under sshz%Couldn't find pid (is /proc mounted?)Fz!Couldn't find parent pid for '%s'r¼   r½   r¾   z"Could not find executable for '%s'zunder_ssh: exe is '%s'z(sshd)T)rÉ   r‘   r   r"   r   rt   r   r^   rÀ   rÁ   rÂ   rJ   rÃ   r   rA   Ú	under_ssh)rÆ   rÈ   Úwarn_msgr   rÀ   Úexes   &     r   rË   rË   ª  s2  € ð"Ü˜‹}ˆð ˆa„x�4˜1”9Ùä�7‰7�<‰<˜¤ T£¨FÓ3€DÜ�7‰7�>‰>˜$×ÒÜÐ(Ó)¨TÕ2ˆÜ˜Ó!Ð!ð"Ü�4‹j×"Ñ"Ó$ QÕ'×-Ñ-Ó/°Õ2ˆô 
Ð
" cÕ
*Ô+ð ˆh„Ùä˜‹Ðøô; ô ÜÐ<Ó=ˆÜˆXŒÚÜô "ÜÐ7Ó8¼CÀ»HÕEˆÜ˜Ó!Ð!ð"ûô  ô "ÜÐ8Ó9¸TÕBˆÜ˜Ó!Ð!ð"ús#   ‚C% Â
5D= Ã%!D:Ä	D:Ä(D:Ä=)E&c                óœ   € ^ pV'       d   ^€p\         P                  ! RV 4      '       d!   \        V 4      ^ 8  g   \        V 4      V8”  d   R# R# )zVerifies cidr netmasksú^[0-9]+$FT)r#   r$   r¯   )r2   r3   Únums   && r   r'   r'   Ñ  s:   € à
€Cß	Øˆä�8Š8�K ×$Ò$¬¨B«°!¬´s¸2³wÀ´}Ùár   c                ó  € V'       d   R# \         P                  ! RV 4      '       dZ   V P                  R4      p\        V4      ^8w  d   R# V F.  pV'       d#   \	        V4      ^ 8  g   \	        V4      ^ÿ8”  g   K-   R# 	  R# R# )z.Verifies dotted quad ip addresses and netmasksFz^[0-9]+\.[0-9\.]+$Ú.T)r#   r$   r   r   r¯   )r2   r3   ÚquadsÚqs   &&  r   r.   r.   Ý  sc   € ç	Ùä�8Š8Ð)¨2×.Ò.Ø—H‘H˜S“MˆEÜ�5‹z˜QŒÙÛ�ßœC ›F QœJ¬#¨a«&°3®,Ú ñ ñ ñ r   c           	     óX  € RpV'       d   \         h\        W4      '       g   \         h^ p \        \        P                  ! R\
        P                  ! V 4      4      ^ ,          4      pRp\        ^ 4       F0  pWF,	          ^,          ^8X  d   RpK  V'       d   Rp MV^,          pK2  	  V^ 8¼  d   V^ 8:  d   \        ^ V,
          4      p\        W!4      '       g   \         hV#   \         d?    \        \        P                  ! R\
        P                  ! T 4      4      ^ ,          4      p LÂi ; i)z@Convert netmask to cidr. IPv6 dotted netmasks are not supported.r	   ú>LFTrT   )r   r.   ÚlongÚstructÚunpackr   Ú	inet_atonÚ	NameErrorr¯   Úrangert   r'   )r2   r3   ÚcidrÚmbitsÚbitsÚ	found_oneÚns   &&     r   r>   r>   ö  s÷   € à€Dß	ÜÐä" 2×*Ò*ÜÐàˆð
	EÜœŸš d¬F×,<Ò,<¸RÓ,@ÓAÀ!ÕDÓEˆDð ˆ	Ü�r–ˆAØ•	˜Q� !Ô#Ø ’	çØ�EÙà˜Q•J’Eñ ð �AŒ:˜% 2œ+Ü�r˜E•z“?ˆDä˜t×(Ò(ÜÐà€Køô) ô 	EÜ”v—}’} T¬6×+;Ò+;¸BÓ+?Ó@ÀÕCÓDŠDð	Eús   «;C  Ã AD)Ä(D)c                óŒ  € RpV'       d   \         h\        W4      '       g   \         h \        ^ 4      p\	        ^ 4       F,  pV\        V 4      8  g   K  V^^V,
          ,          ,          pK.  	  \        P                  ! \        P                  ! RV4      4      p\        W!4      '       g   \         hV#   \         d    ^ p LŽi ; i)z<Convert cidr to netmask. IPv6 dotted netmasks not supported.r	   rÖ   )r   r'   r×   rÛ   rÜ   r¯   r   Ú	inet_ntoarØ   Úpackr.   )rÝ   r3   r2   rß   rá   s   &&   r   Ú_cidr_to_dotted_netmaskrå   $  s§   € à	€Bß	ÜÐä" 4×,Ò,ÜÐð
	Ü˜“7ˆDô �r–ˆAØ”3�t“9Ž}Ø˜˜R !�V�Õ#’ñ ô ×ÒœfŸkšk¨$°Ó5Ó6ˆô ˜r×&Ò&ÜÐà€Iøô ô 	ØŠDð	ús   ©B3 Â3CÃCc           	     ó‚  € RV 9  d   \        R4       V # V P                  R4      p\        V4      ^8w  g   \        V^ ,          R4      '       g   \        hV^ ,          pV^,          pTp\        VR4      '       d   \        VR4      p \        \        P                  ! R\        P                  ! V4      4      ^ ,          4      p\        \        P                  ! R\        P                  ! V4      4      ^ ,          4      pWV,          p\        P                  ! \        P                  ! RV4      4      pV: RV: 2#   \         dz    \        \        P                  ! R\        P                  ! T4      4      ^ ,          4      p\        \        P                  ! R\        P                  ! T4      4      ^ ,          4      p L¿i ; i)z8Convert an IPv4 address and netmask to a network addressr   z8_address4_to_network: skipping address without a netmaskFrÖ   )rA   r   r   r.   r   r'   rå   r×   rØ   rÙ   r   rÚ   rÛ   r¯   rã   rä   )	r)   r   ÚhostÚorig_nmr2   Ú	host_bitsÚnm_bitsÚnetwork_bitsrE   s	   &        r   r@   r@   A  sS  € à
�$„ÜÐHÔIØˆà
�*‰*�S‹/€CÜ
ˆ3ƒx�1„}Ô/°°Aµ¸×>Ò>ÜÐàˆq�6€DØ�!�f€Gà	€BÜ˜2˜u×%Ò%Ü$ R¨Ó/ˆðDÜœŸš t¬V×-=Ò-=¸dÓ-CÓDÀQÕGÓHˆ	Ü”v—}’} T¬6×+;Ò+;¸BÓ+?Ó@ÀÕCÓDˆð
 Õ&€LÜ×ÒœvŸ{š{¨4°Ó>Ó?€GãšwÐ'Ð'øô ô DÜœŸš d¬F×,<Ò,<¸TÓ,BÓCÀAÕFÓGˆ	Ü”f—m’m D¬&×*:Ò*:¸2Ó*>Ó?ÀÕBÓCŠðDús   ÂA6D: Ä:BF>Æ=F>c                óÊ  € R pRV 9  d   \        R4       V # V P                  R4      p\        V4      ^8w  g   \        V^,          R4      '       g   \        hV^ ,          pV^,          p\
        P                  ! R\        P                  ! \        P                  V4      4      p \        ^ 4      p\        ^4       F_  pV! WW,          ^4      p\        ^4       F>  p	V^\        W‰,          4      ,          ^V	,
          V^,          ,
          ,          ,          pK@  	  Ka  	   \        ^ 4      p
\        ^€4       F,  pV\        V4      8  g   K  V
^^V,
          ,          ,          p
K.  	  Wj,          p. p\        ^4       F=  pVP                  \        V! V^€4      V^,          V^,          ^,            ^4      4       K?  	  \        P                  ! \        P                  \
        P                   ! RV^ ,          V^,          V^,          V^,          V^,          V^,          V^,          V^,          4	      4      pV: RV: 2#   \         d    ^ p EL�i ; i  \         d    ^ p
 EL7i ; i)z8Convert an IPv6 address and netmask to a network addressc           	     óž   € RP                  \        V^,
          RR4       Uu. uF  p\        W,	          ^,          4      NK  	  up4      # u upi )zDecimal to binaryr	   rT   )rÁ   rÜ   rt   )rÐ   ÚcountÚys   && r   Údec2binÚ%_address6_to_network.<locals>.dec2binf  s=   € à�w‰w´U¸5À½7ÀBÈÔ5KÓLÑ5K°œ˜S�X¨�NÖ+Ñ5KÑLÓMÐMùÒLs   ¢!A
r   z8_address6_to_network: skipping address without a netmaskTz>8H)rA   r   r   r/   r   rØ   rÙ   r   r%   r&   r×   rÛ   rÜ   r¯   r=   r?   rä   )r)   rð   r   Ú	orig_hostÚnetmaskÚunpackedré   Úirá   Újrê   r*   r¹   rE   s   &             r   Ú_address6_to_networkr÷   d  s  € òNð �$„ÜÐHÔIØˆà
�*‰*�S‹/€CÜ
ˆ3ƒx�1„}œM¨#¨a­&°$×7Ò7ÜÐà�A•€IØ�!�f€Gä�}Š}˜U¤F×$4Ò$4´V·_±_Ø5>ó%@ó A€HðÜ˜“Gˆ	ô �1ŽXˆÙ�H•K Ó$ˆÜ�r–ˆAØ˜!œc !¥$›i�-¨S°­U°1°Rµ4­ZÕ8Õ8ŠIó ñ ðÜ�q“'ˆô �3ŽZˆØŒs�7‹|ÖØ�q˜W¨�MÕ)Õ)ŠGñ ð
 Õ
€Cð €CÜ�1ŽXˆØ�
‰
”3‘w˜s CÓ(¨¨2­¨a°­d°2­gÐ6¸Ó:Ö;ñ ô ×ÒœvŸ™Ü%Ÿ{š{¨5°#°aµ&¸#¸a½&Ø+.¨q­6°3°qµ6¸3¸q½6Ø+.¨q­6°3°qµ6¸3¸q½6ó CóD€Gó
 šwÐ'Ð'øôA ô Ø‹	ðûô ô Ø‹ðús$   Â%H= ÄI È=IÉIÉI"É!I"c                óä  € VP                  R4      p\        V4      ^8w  g   \        V^,          V4      '       g   \        hV^ ,          pV^,          pVR8X  g   VR8X  d   R# T pRV9   dJ   VP                  R4      p\        V4      ^8w  g   \        V^,          V4      '       g   \        hV^ ,          pVR8X  g   VR8X  d   R# V'       d*   \	        V4      '       d   \	        V4      '       g   \        hM(\        V4      '       d   \        V4      '       g   \        h\        WR4      '       d   V'       g   \        WR4      pV'       dU   \        V: RV: 24      P                  R4      ^ ,          p\        V: RV: 24      P                  R4      ^ ,          pW‡8H  # \        V: RV: 24      P                  R4      ^ ,          p\        V: RV: 24      P                  R4      ^ ,          pW‡8H  # )z&Determine if address x is in network yr   z0.0.0.0z::T)
r   r   r/   r   r+   r0   r'   rå   r÷   r@   )	Ú
tested_addÚ
tested_netr3   r   rò   ró   ÚaddressÚorig_networkrE   s	   &&&      r   Ú
in_networkrý   ž  s¹  € à
×
Ñ
˜3Ó
€CÜ
ˆ3ƒx�1„}œM¨#¨a­&°"×5Ò5ÜÐà�A•€IØ�!�f€Gà�IÔ ¨dÔ!2Ùà€GØ
ˆg„~Ø�m‰m˜CÓ ˆÜˆs‹8�qŒ=¤¨c°!­f°b× 9Ò 9ÜÐØ�a•&ˆà�)Ô˜w¨$œÙç	Ü˜g×&Ò&¬n¸Y×.GÒ.GÜÐð /Hô ˜g×&Ò&¬n¸Y×.GÒ.GÜÐä˜7×'Ò'·Ü)¨'Ó6ˆ÷ 
Ü+Û-6ºð-Aó BßBGÁ%ÈÃ*ÈQõPˆä&Û(/²ð(:ó ;ß;@¹5À»:ÀaõIˆð Ñ"Ð"ô ,Û-6ºð-Aó BßBGÁ%ÈÃ*ÈQõPˆä&Û(/²ð(:ó ;ß;@¹5À»:ÀaõIˆð Ñ"Ð"r   c                  óð   € R p R FL  p\         P                  P                  VR4      p \         P                  P                  V 4      '       d    MR p KN  	  V R 8X  d   \	        \
        P                  R4      hV # )r	   ÚiptableszCould not find iptables)z/sbinz/binz	/usr/sbinz/usr/binz/usr/local/sbinz/usr/local/bin)r^   rÀ   rÁ   ÚexistsrU   rV   rW   )rÍ   Úds     r   Ú_find_system_iptablesr  Ò  sd   € Ø
€Có3ˆô �g‰g�l‰l˜1˜jÓ)ˆÜ�7‰7�>‰>˜#×ÒÙàŠCñ3ð ˆb„yÜ”e—l‘lÐ$=Ó>Ð>Ø€Jr   c                óê   € V f   \        4       p \        V R.4      w  rV^ 8w  d"   \        \        P                  RV ,          4      hVP                  4       p\        P                  ! RRV^,          4      # )zReturn iptables versionz-VzError running '%s'z^vr	   )r  rz   rU   rV   rW   r   r#   Úsub)rÍ   rc   rb   r   s   &   r   Úget_iptables_versionr  á  s_   € à
‚{Ü#Ó%ˆä�S˜$�KÓ �I€RØ	ˆQ„wÜ”e—l‘lÐ$8¸CÕ$@ÓAÐAØ
�)‰)‹+€CÜ�6Š6�$˜˜C �FÓ#Ð#r   c                ój  € R pV'       d5   \         P                  ! 4       ^ 8w  d   \        \        P                  R4      hV f   \        4       p . pRpV P                  R4      '       d   RpV\        RRR7      ,          p\        V RV.4      w  rVV^ 8w  d   \        \        P                  V4      hV! W. RO4      '       d   VP                  R	4       V! W. RO4      '       d   VP                  R
4       \        V RV.4       \        V RV.4      w  rVV^ 8w  d   \        \        P                  V4      hV# )zTReturn capabilities set for netfilter to support new features. Callers
must be root.c                 óH   € V R V.p\        W2,           4      w  rEV^ 8X  d   R# R# )z-ATF)rz   )rÍ   ÚchainÚruleÚargsrc   rb   s   &&&   r   Útest_capÚ,get_netfilter_capabilities.<locals>.test_capñ  s)   € Ø�T˜5Ð!ˆÜ˜�Ó$‰	ˆØ�Œ7ÙÙr   zMust be rootzufw-caps-testÚ	ip6tableszufw6-caps-testr	   )ÚprefixÚdirz-Nz
recent-setzrecent-updatez-Fz-X)ú-mÚ	conntrackú	--ctstateÚNEWr  Úrecentz--set)r  r  r  r  r  r  z--updatez	--secondsÚ30z
--hitcountr5   )r^   ÚgetuidrU   rV   ÚEPERMr  Úendswithr   rz   rW   r=   )rÍ   Ú	do_checksr  Úcapsr  rc   rb   s   &&     r   Úget_netfilter_capabilitiesr  î  s  € ò÷ ”R—Y’Y“[ AÔ%Ü”e—k‘k >Ó2Ð2à
‚{Ü#Ó%ˆà€Dà€EØ
‡|�|�K× Ò Ø ˆð 
ŒV˜2 2Ô&Õ&€Eô �S˜$ Ð&Ó'�I€RØ	ˆQ„wÜ”e—l‘l CÓ(Ð(ñ �ò 6÷ 7ò 7à�‰�LÔ!ñ �ò 0÷ 1ò 1ð 	�‰�OÔ$ô ˆˆd�EÐÔÜ�S˜$ Ð&Ó'�I€RØ	ˆQ„wÜ”e—l‘l CÓ(Ð(à€Kr   c                ó  € \        V 4      p\        4       pVP                  4        EFb  pVP                  R4      '       g   VP                  R4      '       g   K4  VP	                  4       pV^ ,          pV^,          P	                  R4      R,          p\        4       pRP                  V^,          P	                  R4      RR 4      VR&   V^,          VR&   V^,          P	                  R4      ^ ,          VR&   VR,          R	8X  d   VR,          VR
&   M"V^,          P	                  R4      ^,          VR
&   WR9  d   \        4       W%&   . W%,          V&   MWbV,          9  d   . W%,          V&   W%,          V,          P                  V4       EKe  	  V# )z:Get and parse netstat the output from get_netstat_output()r
   r   Ú:NÚladdrÚuidr   rÆ   Ú-rÍ   rT   )Úget_netstat_outputÚdictÚ
splitlinesÚ
startswithr   rÁ   r=   )r3   Únetstat_outputr  r¡   r   r   r   Úitems   &       r   Úparse_netstat_outputr'  '  sE  € ô (¨Ó+€Nä‹€AØ×)Ñ)×+ˆØ�‰˜u×%Ò%¨d¯o©o¸e×.DÒ.DÙà�j‰j‹lˆà�A•ˆØ�1�v�|‰|˜CÓ  Õ$ˆä‹vˆØŸ™  Q¥§¡¨cÓ!2°3°BÐ!7Ó8ˆˆW‰Ø˜!•fˆˆU‰Ø˜!•f—l‘l 3Ó'¨Õ*ˆˆU‰Ø��;˜#ÔØ˜u�+ˆD�ŠKà˜a�&Ÿ,™, sÓ+¨AÕ.ˆD�‰KàŒ>Ü“vˆA‰HØˆA�H�TŠNà˜U�8Ô#Ø!#�•˜‘Ø	���×Ñ˜d×#ñ1 ,ð4 €Hr   c                ó.  € RpV'       Ed;   Rp\         P                  P                  V4      '       g"   \        \        P
                  RV,          4      h\        V4      P                  4        F³  pVP                  4       pW^,          8X  g   K"  RP                  \        ^ \        V^ ,          4      ^4       Uu. uF  qe^ ,          Wf^,            NK  	  up4      pV^,          P                  4       R8w  g   K‹  V: R\        V^,          P                  4       ^4      : 2pKµ  	  VR8X  d   \        \        P                  R4      hM‘\         P                   ! \         P"                  \         P$                  4      p \         P&                  ! \(        P*                  ! VP-                  4       R\.        P0                  ! R	V R
,          4      4      R,          4      p\5        W!4      ^ ,          # u upi   \2         d    \        \        P                  R4      hi ; i)zGet IP address for interfacer	   ú/proc/net/if_inet6ú'%s' does not existr  Ú80r   úNo such devicei‰  Ú256s:Né   N:é   é   N)r^   rÀ   r   rU   rV   rW   rJ   rÃ   r   rÁ   rÜ   r   r°   r¯   r‘   ÚENODEVr   r-   Ú
SOCK_DGRAMrã   ÚfcntlÚioctlr[   rØ   rä   r   rG   )Úifnamer3   r)   Úprocr¡   r   rõ   r�   s   &&      r   Úget_ip_from_ifr7  M  s”  € à€D÷ 
€rØ#ˆÜ�w‰w�~‰~˜d×#Ò#Üœ%Ÿ,™,Ð(=ÀÕ(DÓEÐEä˜“J×(Ñ(Ö*ˆDØ—*‘*“,ˆCØ˜Q�ÖØ—x‘xÜ38¸¼CÀÀAÅ»KÈÔ3KÓLÑ3K¨a �F 1 q¥S›MÑ3KÑLóN�ð �q•6—<‘<“> TÖ)Û&*¬C°°Aµ·±³ÀÕ,CÐD’Dñ +ð �2Œ:Üœ%Ÿ,™,Ð(8Ó9Ð9ð ô �MŠMœ&Ÿ.™.¬&×*;Ñ*;Ó<ˆð	:Ü×#Ò#¤E§K¢K°·±³
¸FÜ$*§K¢K°¸¸s½Ó$Dó%FØFKõ%Mó NˆDô
 ˜TÓ& qÕ)Ð)ùò Møô ô 	:Üœ%Ÿ,™,Ð(8Ó9Ð9ð	:ús   Â9G)
Å:AG. Ç.&Hc           
     ó,  € RpRp\        V 4      '       d   RpRpM+\        V 4      '       g   \        \        P                  R4      h\
        P                  P                  V4      '       g"   \        \        P                  RV,          4      hRpV'       Ed    \        V4      P                  4        Fß  pVP                  4       pV^,          P                  4       pRP                  \        ^ \!        V^ ,          4      ^4       Uu. uF  qu^ ,          Ww^,            NK  	  up4      pV^,          P#                  4       R	8w  d)   V: R
\%        V^,          P#                  4       ^4      : 2pW8X  g   R
V9   g   KÈ  \'        WR4      '       g   KÜ  Tp V# 	   V# \        V4      P                  4        FJ  pRV9  d   K  VP                  R4      ^ ,          P                  4       p \)        VR4      p	Y�8X  g   KG  Tp T# 	  V# u upi   \         d     Kc  i ; i)zGet interface for IP addressFz/proc/net/devTr)  r,  r*  r	   r  r+  r   )r+   r0   r‘   rV   r1  r^   rÀ   r   rU   rW   rJ   rÃ   r   ÚstriprÁ   rÜ   r   r°   r¯   rý   r7  )
r)   r3   r6  Úmatchedr¡   r   r5  rõ   Útmp_addrÚips
   &         r   Úget_if_from_ipr=  m  sÁ  € à	€BØ€DÜ�d×ÒØˆØ#‰Ü˜D×!Ò!Ü”e—l‘lÐ$4Ó5Ð5ä�7‰7�>‰>˜$×ÒÜ”e—l‘lÐ$9¸DÕ$@ÓAÐAà€Gç	€rÜ˜“J×(Ñ(Ö*ˆDØ—*‘*“,ˆCØ˜•V—\‘\“^ˆFà—x‘xÜ38¸¼CÀÀAÅ»KÈÔ3KÓLÑ3K¨a �F 1 q¥S›MÑ3KÑLóNˆHà�1�v�|‰|‹~ Ô%Û&.´°C¸µF·L±L³NÀBÕ0GÐH�àÔØ�x–¤J¨t¸t×$DÔ$DØ �Øð  €Nò9 +ð8 €Nô ˜“J×(Ñ(Ö*ˆDØ˜$ŒÙØ—Z‘Z “_ QÕ'×-Ñ-Ó/ˆFðÜ# F¨EÓ2�ð ŽzØ �Øà€Nñ +ð €Nùò/ Møô  ô Úðús   ÄG?
Ç"HÈHÈHc                 ó‚  € \         P                  ! R4      p V P                  4        \        P                  ! R4      p\        4       pV  EF;  pVP                  V4      '       g   K  \         P                  P                  RVR4      p\         P                  ! V\         P                  \         P                  ,          4      '       g   K€  Rp \         P                  ! \         P                  P                  RVR4      4      p \         P                  ! V4      pT Ff  p \         P                  ! \         P                  P                  YG4      4      ^,          pT: R\         P                  P                  T4      : 2Y(&   Kh  	  EK>  	  V#   \         d     L—i ; i  \         d     EKb  i ; i  \         d     K£  i ; i)zGet inodes of files in /procr¼   rÏ   ra   r   rÍ   r   )r^   Úlistdirr¸   r#   Úcompiler"  r$   rÀ   rÁ   ÚaccessÚF_OKÚR_OKÚreadlinkr   r½   Úbasename)	Ú
proc_filesÚpatÚinodesrõ   Úfd_pathÚexe_pathÚdirsrö   Úinodes	            r   Ú_get_proc_inodesrM  œ  sM  € ä—’˜GÓ$€JØ‡O�OÔÜ
�*Š*�[Ó
!€CÜ‹V€FÜˆØ�y‰y˜�|Š|Ùä—'‘'—,‘,˜w¨¨4Ó0ˆô �yŠy˜¤"§'¡'¬B¯G©GÕ"3×4Ò4Ùàˆð	Ü—{’{¤2§7¡7§<¡<°¸¸EÓ#BÓCˆHð	Ü—:’:˜gÓ&ˆDó ˆAðÜŸš¤§¡§¡¨WÓ 8Ó9¸!Õ<�ó ()¬"¯'©'×*:Ñ*:¸8Õ*DÐEˆF‹Mô ñ+ ð8 €Møô ô 	Ùð	ûô
 ô 	Ûð	ûô ô Úðús6   Ã5FÄFÄ:F/ÆFÆFÆF,Æ+F,Æ/F>Æ=F>c                ó  € ^R^R^R^R^R^R^R^R^	R	^
R
^R/pR^R^R^R^	/p\         P                  P                  RV 4      p\         P                  ! V\         P                  \         P
                  ,          4      '       g   \        h. pRp\        V4      P                  4       pV FÖ  pVP                  4       pV'       g   RpK  V\        W‚R,          ,          ^4      ,          p	V P                  R4      '       d   Rp	M V P                  R4      '       d
   V	R
8w  d   Ky  W‚R,          ,          P                  R4      w  r«W‚R,          ,          pW‚R,          ,          pVP                  V
\        V^4      WÍV	34       KØ  	  V# )z=Read /proc/net/(tcp|udp)[6] file and return a list of tuples ÚESTABLISHEDÚSYN_SENTÚSYN_RECVÚ	FIN_WAIT1Ú	FIN_WAIT2Ú	TIME_WAITÚCLOSEÚ
CLOSE_WAITÚLAST_ACKÚLISTENÚCLOSINGÚ
local_addrÚstater  rL  z	/proc/netFTr   ÚNAr
   r  )r^   rÀ   rÁ   rA  rB  rC  r   rJ   rÃ   r   r¯   r$  r=   )ÚprotocolÚ
tcp_statesÚproc_net_fieldsrK   r¹   Úskipped_firstÚlinesr¡   Úfieldsr[  r  r   r  rL  s   &             r   Ú_read_proc_net_protocolrc  Á  ss  € à�mØ�jØ�jØ�kØ�kØ�kØ�gØ�lØ�jØ�xØ�yð€Jð % aØ Ø˜qØ ð€Oô 
�‰�‰�k 8Ó	,€Bä�9Š9�RœŸ™¤2§7¡7Õ*×+Ò+ÜÐà
€CØ€MÜ�‹H×ÑÓ €EÛˆØ—‘“ˆßØ ˆMÙØœ3˜v°gÕ&>Õ?ÀÓDÕEˆØ×Ñ˜u×%Ò%Ø‰EØ× Ñ  ×'Ò'¨E°XÔ,=ÙØ¨\Õ:Õ;×AÑAÀ#ÓF‰ˆØ UÕ+Õ,ˆØ wÕ/Õ0ˆØ�
‰
�Eœ3˜t R›=¨#°eÐ<Ö=ñ ð €Jr   c                ó   € Rp\        V 4      ^8”  d¸   Rp\        ^ ^ ^4       FF  pTRP                  \        V^,           VR4       Uu. uF  q@V^,
          V NK  	  up4      ,          pKH  	  \        RP                  \        ^ \        V4      ^4       Uu. uF  qBWD^,            P	                  4       NK  	  up4      R4      ^ ,          pV# . p\        ^^ R4       Uu. uF  q@V^,
          V NK  	  up F'  pVP                  \        \        V^4      4      4       K)  	  \        RP                  V4      R4      ^ ,          pV# u upi u upi u upi )zDConvert an address from /proc/net/(tcp|udp)* to a normalized addressr	   r  TrÒ   Féþÿÿÿ)r   rÜ   rÁ   rG   r°   r=   rt   r¯   )ÚpaddrÚ	convertedr   rõ   rö   s   &    r   Úconvert_proc_addressrh  ð  s.  € à€IÜ
ˆ5ƒz�A„~ØˆÜ�q˜"˜a–ˆAØ�2—7‘7´5¸¸1½¸aÀÔ3DÓFÑ3D¨a 1 Q¥3 q›\Ñ3DÑFÓGÕGŠCñ !ä% c§h¡hÜ,1°!´S¸³X¸qÔ,AÓBÑ,A q�A˜•c�
× Ñ Ö"Ñ,AÑBó'Dàóàõˆ	ð Ðð ˆÜ).¨q°!°R¬Ó:© A˜˜1�˜Q“<©Ô:ˆAØ�J‰J”sœ3˜q "›:“Ö'ñ ;ä% c§h¡h¨s£m°UÓ;¸AÕ>ˆ	àÐùò GùâBùò ;s   ÁEÂ!EÃEc                ó,  € \        4       pRR.pV '       d   VRR.,          pV F  p \        V4      W&   K  	  \        4       p\        VP                  4       4      pVP                  4        RpV Fq  pW,           Fb  w  r‰r«p\        V4      pRp\        V4      V9   d   V\        V4      ,          pWs:R R	V: R
V	: 2:R R	V:R R	V
:R R	V:R R	V: R2,          pKd  	  Ks  	  V#   \         d"    \        RT,          4      p\	        T4        Kî  i ; i)z5netstat-style output, without IPv6 address truncationr
   r   Útcp6Úudp6z!Could not get statistics for '%s'r	   r   Ú5r¦   r  Ú46Ú11rŸ   )r"  rc  r   r   r"   rM  ÚlistÚkeysr¸   rh  r¯   )r3   Úproc_net_datar   ÚprÌ   rH  Ú	protocolsr�   r  r   r  rL  r[  r)   rÍ   s   &              r   r!  r!    s  € ä“F€MØ�EˆN€Eß	Ø�&˜&Ð!Õ!ˆÛˆð	Ü6°qÓ9ˆMÓñ ô Ó€Fä�]×'Ñ'Ó)Ó*€IØ‡N�NÔà
€AÛˆØ0=×0@Ð0@Ñ,ˆU˜# eÜ'¨Ó.ˆDàˆCÜ�5‹z˜VÔ#àœS ›ZÕ(�Ø³qÛBFÊÔ7MÜ7<¼cÄ5Ë#ðOõ OŠAó 1Añ ð €Høô/ ô 	ÜÐ<ÀÕBÓCˆHÜ�ŒNÚð	ús   ¨C'Ã'(DÄDc                óø   € Vf   V # V P                  R4      '       d>   \        V 4      ^8  d   TpV# \        P                  P	                  WR,          4      p V# \        P                  P	                  W4      pV# )zAdd prefix to dirr   :é   NN)r$  r   r^   rÀ   rÁ   )r  r  Únewdirs   && r   Ú	_findpathrw  &  sj   € à‚~Øˆ
Ø
‡~�~�c×ÒÜˆs‹8�aŒ<ØˆFð
 €Mô —W‘W—\‘\ &¨b­'Ó2‰Fð €Mô —‘—‘˜fÓ*ˆØ€Mr   c                óÔ   € \         P                  ^ ,          ^8  d   \        P                  ! V R4      # \        P
                  ! V P                  RRR7      4      P                  R4      # )z,Take a string and convert it to a hex stringÚhexrƒ   r„   )ÚerrorsrS   )rY   r]   Úcodecsr†   ÚbinasciiÚhexlifyÚdecode)r�   s   &r   Ú
hex_encoder  4  sQ   € ä
×Ñ˜Õ˜QÔÜ�}Š}˜Q Ó&Ð&ô ×Ò˜AŸH™H W°X˜HÓ>Ó?×FÑFÀwÓOÐOr   c                ó  € \         P                  ^ ,          ^8  d"   V P                  RR7      P                  R4      # \        P                  ! R\        V 4      ^,          '       d   V RR MT ,          4      P                  RR4      # )z,Take a hex string and convert it to a stringry  )Úencodingrƒ   r˜   NÚbackslashreplacerT   )rY   r]   r~  r|  Ú	unhexlifyr   )Úhs   &r   Ú
hex_decoder…  =  sp   € ä
×Ñ˜Õ˜QÔØ�x‰x ˆxÓ'×.Ñ.¨wÓ7Ð7ô ×Ò˜d´°A³¸·
´
 a¨¨¡fÀÕBÓC×JÑJØÐ#óð r   c                ó|   € RpV'       g2   \        V R4      p\        P                  ! V\        P                  4       V# )zCreate a blocking lockfileNÚw)rJ   r3  ÚlockfÚLOCK_EX)ÚlockfileÚdryrunÚlocks   && r   Úcreate_lockr�  L  s-   € à€DßÜ�H˜cÓ"ˆÜ�Š�Dœ%Ÿ-™-Ô(Ø€Kr   c                ó¢   € V f   R#  \         P                  ! V \         P                  4       V P                  4        R#   \         d     R# i ; i)z(Free lockfile created with create_lock()N)r3  rˆ  ÚLOCK_UNrP   r   )rŒ  s   &r   Úrelease_lockr�  U  s>   € à‚|ÙðÜ�Š�Dœ%Ÿ-™-Ô(Ø�
‰
ŽøÜô ò 	ðús   ˆ5? ¿AÁA)r
   r   r   ÚespÚahr   ÚgreÚvrrp)r   r‘  r’  r   r“  r”  )r   )Tr­   )NT)F)z/run/ufw.lockF)IÚ__doc__Ú
__future__r   r|  r{  rV   r3  r‰   r‡   r^   r#   rf   r   rØ   rp   rY   Ú	functoolsr   Útempfiler   r   rœ   rX   Úsupported_protocolsr   Úipv4_only_protocolsr   r   r+   r0   r/   r8   rG   rL   rQ   rd   rl   rz   r�   r�   r”   r"   rZ   rš   rA   r¨   rª   rº   ÚgetpidrÉ   rË   r'   r.   r>   rå   r@   r÷   rý   r  r  r  r'  r7  r=  rM  rc  rh  r!  rw  r  r…  r�  r�  © r   r   Ú<module>r�     sr  ðÙ (õ" &Û Û Û Û Û 	Û Û 	Û 	Û Û Û Û Û 
å ß $à€	Ø€
ò QÐ ÚAÐ Ø˜vÐ&Ð òò4ò(ò4ò2Fô	ò4ònò

LòGô2ò%ò	&òô*òð —J‘J¨ô òòòò
Hð —9’9“;ô ð. —)’)“+ô !òN	òò2$ò\ò: (òF7(òt,#òhô	$ô6òr#ôL*ò@,ò^"òJ,ò^ò& òFòPòôô
r   