HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/site-packages/zmq/auth/__pycache__/thread.cpython-36.pyc
3

VS�_��@s�dZddlZddlmZmZddlZddlmZddlm	Z	m
Z
ddlZddlm
Z
Gdd	�d	e�Zd
d�ZeGdd
�d
e��Zd
gZdS)z>ZAP Authenticator in a Python Thread.

.. versionadded:: 14.1
�N)�Thread�Event)�jsonapi)�b�u�)�
Authenticatorcs:eZdZdZd�fdd�	Zdd�Zdd	�Zd
d�Z�ZS)
�AuthenticationThreadziA Thread for running a zmq Authenticator

    This is run in the background by ThreadedAuthenticator
    �utf-8Ncsztt|�j�|ptjj�|_||_|p0tj	d�|_
}t�|_|pPt
|||d�|_|jtj�|_d|j_|jj|�dS)Nzzmq.auth)�encoding�logr)�superr	�__init__�zmq�Context�instance�contextr�loggingZ	getLoggerrr�startedr�
authenticator�socket�PAIR�pipe�lingerZconnect)�selfrZendpointrrr)�	__class__��/usr/lib64/python3.6/thread.pyrszAuthenticationThread.__init__cCs|jj�|jj�|jj}tj�}|j|jtj	�|j|tj	�x�yt
|j��}Wntjk
rlPYnX|j|kr�||jtj	kr�xBy|jj
tjd�}Wntjk
r�PYnX|j|�}|r�Pq�W|r�P||krD||tj	krD|j�qDW|jj�|jj�dS)z*Start the Authentication Agent thread task)�flagsN)r�startr�set�
zap_socketrZPoller�registerrZPOLLIN�dictZpollZZMQError�recv_multipartZNOBLOCKZAgain�_handle_pipe�_handle_zap�close�stop)rZzapZpollerZsocks�msg�	terminaterrr�run&s4



zAuthenticationThread.runcCs$|jjj�}|sdS|jj|�dS)z7
        Handle a message from the ZAP socket.
        N)rr!r$Zhandle_zap_message)rr)rrrr&Isz AuthenticationThread._handle_zapc	s�d}|dkrd}|S|d}�jjd|�|dkr��fdd�|d	d�D�}y�jj|�Wn0tk
r�}z�jjd
|�WYdd}~XnXn�|dkr��fdd�|d	d�D�}y�jj|�Wn0tk
r�}z�jjd
|�WYdd}~XnXn�|dk�r.t|d	�j�}|d}�jj	|t
j|��nX|dk�rht|d	�j�}t|d�j�}�jj||�n|dk�rxd}n�jj
d|�|S)z6
        Handle a message from front-end API.
        FNTrzauth received API command %rsALLOWcsg|]}t|�j��qSr)rr)�.0�m)rrr�
<listcomp>_sz5AuthenticationThread._handle_pipe.<locals>.<listcomp>rzFailed to allow %ssDENYcsg|]}t|�j��qSr)rr)r,r-)rrrr.fszFailed to deny %ssPLAIN�sCURVEs	TERMINATEz!Invalid auth command from API: %r)r�debugr�allow�	ExceptionZ	exception�denyrr�configure_plainr�loads�configure_curve�error)	rr)r*Zcommand�	addresses�e�domainZjson_passwords�locationr)rrr%Qs<""


z!AuthenticationThread._handle_pipe)r
NN)	�__name__�
__module__�__qualname__�__doc__rr+r&r%�
__classcell__rr)rrr	s

#r	cCsLxF|jj�D]8\}}|jd�st|�r*qtt|d�}|js|j|_qW|S)zAinherit docstrings from Authenticator, so we don't duplicate them�_N)�__dict__�items�
startswith�callable�getattrrr?)�cls�name�methodZupstream_methodrrr�_inherit_docstrings�srJc@s�eZdZdZdZdZdZdZdZdZ	dZ
ddd�Zdd�Zd	d
�Z
dd�Zd
d�Zddd�Zd dd�Zd!dd�Zdd�Zdd�Zdd�Zdd�ZdS)"�ThreadAuthenticatorz-Run ZAP authentication in a background threadN��utf-8cCs<|ptjj�|_||_||_d|_djt|��|_	d|_
dS)Nzinproc://{0}.inproc)rrrrrrr�format�id�
pipe_endpoint�thread)rrrrrrrr�szThreadAuthenticator.__init__cCsJx4|g|jj�D] }||jkrtj|||�dSqWt|jj||�dS)N)r�mrorB�object�__setattr__�setattrrQr)r�key�value�objrrrrT�s

zThreadAuthenticator.__setattr__cCs4ytj||�Wntk
r.t|jj|�SXdS)N)rS�__getattr__�AttributeErrorrFrQr)rrVrrrrY�szThreadAuthenticator.__getattr__cs$�jjdg�fdd�|D��dS)NsALLOWcsg|]}t|�j��qSr)rr)r,�a)rrrr.�sz-ThreadAuthenticator.allow.<locals>.<listcomp>)r�send_multipart)rr8r)rrr1�szThreadAuthenticator.allowcs$�jjdg�fdd�|D��dS)NsDENYcsg|]}t|�j��qSr)rr)r,r[)rrrr.�sz,ThreadAuthenticator.deny.<locals>.<listcomp>)rr\)rr8r)rrr3�szThreadAuthenticator.deny�*cCs(|jjdt||j�tj|pi�g�dS)NsPLAIN)rr\rrr�dumps)rr:Z	passwordsrrrr4�sz#ThreadAuthenticator.configure_plaincCs.t||j�}t||j�}|jjd||g�dS)NsCURVE)rrrr\)rr:r;rrrr6�sz#ThreadAuthenticator.configure_curvecCs|jjj||d�dS)N)�credentials_provider)rQr�configure_curve_callback)rr:r_rrrr`�sz,ThreadAuthenticator.configure_curve_callbackcCs�|jjtj�|_d|j_|jj|j�t|j|j|j	|j
d�|_|jj�t
jd	krf|jjjdd�n|jjjdd�s~td��dS)
zStart the authentication threadr)rrr/��
)Ztimeoutz$Authenticator thread failed to startN)r/ra)rrrrrrZbindrPr	rrrQr�sys�version_infor�wait�RuntimeError)rrrrr�s

zThreadAuthenticator.startcCs>|jr:|jjd�|j�r$|jj�d|_|jj�d|_dS)zStop the authentication threads	TERMINATEN)r�send�is_aliverQ�joinr')rrrrr(�s

zThreadAuthenticator.stopcCs|jr|jj�rdSdS)z$Is the ZAP thread currently running?TF)rQrh)rrrrrh�szThreadAuthenticator.is_alivecCs|j�dS)N)r()rrrr�__del__�szThreadAuthenticator.__del__)NrMN)r]N)r]rL)r]N)r<r=r>r?rrrrrPrQZauthrrTrYr1r3r4r6r`rr(rhrjrrrrrK�s(





rK)r?rZ	threadingrrrZ	zmq.utilsrZzmq.utils.strtypesrrrc�baserr	rJrSrK�__all__rrrr�<module>so
T