ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/__pycache__/daemon.cpython-311.pyc

�

�2�f�~���ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZmZm
Z
mZddlmZddlmZddlmZmZddlmZddlmZmZmZmZmZmZddl m!Z!m"Z"m#Z#m$Z$dd	l%m&Z&m'Z'm(Z(m)Z)ddl*m+Z+dd
l,m-Z-ddl.m/Z/ddl0m1Z1dd
l2m3Z3edgd���Z4ej5e6��Z7ed���Z8dejfd�Z9edefd���Z:dde;deee;e;ffd�Z<Gd�de-��Z=dS)�N)�Optional�Dict�Tuple�List)�contextmanager)�
namedtuple)�Lock�Thread)�gettext)�cpusers�get_domains_php_info�docroot�get_installed_php_versions�get_main_username_by_uid�cpinfo)�get_process_pid�remove_pid_file�write_pid_file�is_litespeed_running)�is_user_redis_alive�kill_all_users_redises�reload_redis_for_user_thread�
parse_redises)�WposDaemonBase)�WPOS_DAEMON_SOCKET_FILE)�WposDaemonLockError)�PendingSubscriptionWatcher�	User_data��	redis_pid�lock�last_reload_timec#�bK�tjd��}dV�tj|��dS)z,
    Context manager for dropping umask
    rN)�os�umask)�prevs �D/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/daemon.py�_umask_0r(4s/����
�8�A�;�;�D�	�E�E�E��H�T�N�N�N�N�N��returnc���t��5tjtj��}|�t��|���|cddd��S#1swxYwYdS)zr
    Create world-writable socket in given sock_location
    or reuse existing one
    :return: socket object
    N)r(�socket�AF_UNIX�bindr�listen)�sockobjs r'�_create_socketr1>s���
������-���/�/�����,�-�-�-��������	��������������������s�AA*�*A.�1A.r!c#��K�|�d���sttd������	|V�|���dS#|���wxYw)z=
    Non-blocking lock implementation for with statement
    F)�blockingz/Can't acquire lock. May be it already acquired.)�messageN)�acquirer�_�release)r!s r'�non_blocking_lockr8Ksj����
�<�<��<�'�'�`�!�!�,]�*^�*^�_�_�_�_���
�
�
�������������������s�A�A'�function�input_parametersc���|rd�|���D��ng}tjdd|g|�d���}tj|j�����dS)Nc�"�g|]\}}|�d|����
S)�=�)�.0�key�values   r'�
<listcomp>zwhmapi1.<locals>.<listcomp>Ys*��\�\�\�Z�S�%�3� 0� 0�� 0� 0�\�\�\r)z/usr/sbin/whmapi1z
--output=jsonT)�capture_output�data)�items�
subprocess�run�json�loads�stdout�decode)r9r:�input_parameters_as_list�results    r'�whmapi1rNXs}��`p�x�\�\�CS�CY�CY�C[�C[�\�\�\�\�vx��
�^�0�/�8�g�Nf�g�+/�1�1�1�F��:�f�m�*�*�,�,�-�-�f�5�5r)c�l��eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
Zeeeee	e
ee
eeegZee
eeeegZdZdZ�fd�Zd8dedededefd�Zdedefd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d9d!efd"�Z"e#de$fd#���Z%d$e&j&de'eee(ee(e$effd%�Z)d$e&j&d&ed'efd(�Z*d)edefd*�Z+	d8d$e&j&d&ed'ed+edef
d,�Z,e#d:d.ede-fd/���Z.d$e&j&fd0�Z/d$e&j&d.efd1�Z0d$e&j&fd2�Z1d$e&j&fd3�Z2d$e&j&fd4�Z3d$e&j&fd5�Z4d$e&j&dd-fd6�Z5d7�Z6�xZ7S);�
WposDaemonzW
    AccelerateWP daemon main class. Socket operations, redis process control, etc
    z/var/lve/wpos_reload�reloadzget-redis-statuszget-litespeed-status�php_get_vhost_versions�php_get_installed_versions�get_upgrade_link�
get_unique_id�suite_allowed_callback�daemon_register_upgrade�daemon_get_upgrade_status�&daemon_get_supported_suites_by_license��c����t�����i|_g|_d|_d|_d|_d|_t��|_	dS)NrT)
�super�__init__�_monitoring_users_dict�_username_list_to_process�_socket�_reload_uid�_socket_thread�_socket_thread_workr�_suite_watcher)�self�	__class__s �r'r^zWposDaemon.__init__�s^���
��������
=?��#�)+��&�04������04���#'�� �8�:�:����r)�no�user_uid�is_store_last_reload_time�force_reloadr*c�H�	|j�|��}|�d}n|j}tj|��j}t�d||��t|||��\}}|ddkr|S|rK|j	j
r|sd}	ntj��}	t|t��|	���|j|<n||jvr|j|=nB#t$r5}
t�|
��dt!|
��icYd}
~
Sd}
~
wwxYwddiS)aP
        Starts/stops redis for user and updates dict for monitoring (self._monitoring_users_dict)
        :param user_uid: uid to reload redis
        :param is_store_last_reload_time: True -  write last reload time to user data, False - write 0
        :return: dict {"result": "success"} / {"result": "error", "context": {}}
        Nz.Reloading redis for user: %s, force reload: %srM�successrr)r_�getr �pwd�getpwuid�pw_name�logger�infor�_config�enable_reload_rate_limit�timerr	�	Exception�	exception�str)rfrirjrk�userdata�
old_redis_pid�username�
new_redis_pid�result_dictr"�es           r'�_reload_redis_for_userz!WposDaemon._reload_redis_for_user�su��	&��2�6�6�x�@�@�H��� $�
�
� (� 2�
��|�H�-�-�5�H��K�K�H� �,�
0�
0�
0�)E��-��*7�*7�&�M�;��8�$�	�1�1�"�"��
>��|�<�3�D]�3�'(�$�$�'+�y�{�{�$�8A�M�`d�`f�`f�Sc�9e�9e�9e��+�H�5�5��t�:�:�:��3�H�=����	&�	&�	&����Q�����c�!�f�f�%�%�%�%�%�%�%�����	&�����)�$�$s%�A<C�?AC�
D�(*D�D�Dc��|j|}d}	t|j��5t|��\}}}|s	ddd��dS|r	ddd��dSt	j|��j}t||j|j��\}}|�	ddd��dSt||jd���|j|<ddd��n#1swxYwYne#t$r,}t�d|j
||��Yd}~n4d}~wt$r$}t�|��Yd}~nd}~wwxYwdS)a"
        One user monitoring actions
        :param user_uid: uid to reload redis
        :return: User remove flag:
         True - user has stopped his redis (or user absent in system), remove it from monitoring list
         False - redis still active, should be monitored again
        �NTFrrzSLock error: %s. User %s (uid=%d) is working with his redis, skip monitoring actions)r_r8r!rrorprqrr rrrr�debugr4rwrx)	rfri�	user_datar|�is_redis_alive�is_user_presentr6r rs	         r'�_user_monitoringzWposDaemon._user_monitoring�sZ�� $�:�8�D�	���	 �"�9�>�2�2�
V�
V�5H��5R�5R�2����&� ��
V�
V�
V�
V�
V�
V�
V�
V�"�!� �
V�
V�
V�
V�
V�
V�
V�
V��<��1�1�9��;���/��9�C� E� E��	�1��$��
V�
V�
V�
V�
V�
V�
V�
V�9B�I�\e�\j�ST�9V�9V�9V��+�H�5�
V�
V�
V�
V�
V�
V�
V�
V�
V�
V�
V����
V�
V�
V�
V���"#�	>�	>�	>��L�L�n� �y�(�H�
>�
>�
>�
>�
>�
>�
>�
>������	 �	 �	 ����Q�������������	 �����usi�C�C�C�	C�C�?C�C�%C�C�C�C�C�C�
D>�&"D
�

D>�D9�9D>c���g}t|j�����D].}|�|��}|r|�|���/|D]}||jvr|j|=�dS)z,
        Working redises monitoring
        N)�listr_�keysr��append)rf�user_ids_list_to_remove�user_id�	is_removes    r'�_redises_monitoringzWposDaemon._redises_monitoring�s���#%���D�7�<�<�>�>�?�?�	8�	8�G��-�-�g�6�6�I��
8�'�.�.�w�7�7�7��.�	9�	9�G��$�5�5�5��/��8��	9�	9r)c���|jrbd|_t��D]N}	tj|��j}n#t
$rY�)wxYw||jvr|�|d���MdSdS)zC
        Process all requests - start/stop redis for users
        FN)�_reload_config_needrro�getpwnam�pw_uid�KeyErrorr_r�)rfr|r�s   r'�_reload_all_userszWposDaemon._reload_all_users�s����#�
	@�',�D�$�#�I�I�
@�
@���!�l�8�4�4�;�G�G�������H������$�"=�=�=��/�/���?�?�?��
	@�
	@�
@�
@s�:�
A�Ac	�J�d}t��}t�d|��|D]F}|j�|dt|dt
��d���i���G|js�	|���|�	��|jrdStjd��|dz
}||jj
kr|���d}n,#t$rt�dd���YnwxYw|j��dSdS)NrzFound existing redises: %s�rz,Cloudlinux AccelerateWP daemon general errorT��exc_info)rrrr�r_�updaterr	�
_is_terminate�
_force_reloadr�rv�sleeprt�monitoring_intervalr�rwrx)rf�i�existing_redises�items    r'�_main_cyclezWposDaemon._main_cyclesa��
��(�?�?�����1�3C�D�D�D�$�	y�	y�D��'�.�.��Q���T�RS�W�[_�[a�[a�tu�9v�9v�9v�/w�x�x�x�x��$�	`�

`��"�"�$�$�$��&�&�(�(�(��%���E��
�1�
�
�
��Q����t�|�7�7�7��,�,�.�.�.��A����
`�
`�
`�� � �!O�Z^� �_�_�_�_�_�
`�����$�	`�	`�	`�	`�	`s�=/C.�.?C.�.&D�Dc�l�t|j���|_|j���dS)z;
        Create and start socket processing thread
        )�targetN)r
�_process_socket_connectionsrc�start�rfs r'�_create_and_start_socket_threadz*WposDaemon._create_and_start_socket_threads5��%�D�,L�M�M�M�����!�!�#�#�#�#�#r)c�^�t|j���"t�d|j��dStj�t��r|���	t��|_
nI#ttf$r5}d}t�|t|����Yd}~dSd}~wwxYwt�d��|���t!|j��|���|���|���d|_|j���|���t/|j��t�d��dS)z+
        Main work daemon function
        NzCPID file %s existing. Cloudlinux AccelerateWP daemon already works?z5Can't create AccelerateWP daemon socket. Error is: %sz&Cloudlinux AccelerateWP daemon startedFz)Cloudlinux AccelerateWP daemon terminated)r�
_PID_FILENAMErr�warningr$�path�existsr�_remove_socketr1ra�OSError�IOErrorryrs�_setup_signalsrrQr�r�rdrc�joinr)rfrr4s   r'rGzWposDaemon.run&s����4�-�.�.�:��N�N�`�bf�bt�u�u�u��F�
�7�>�>�1�2�2�	"����!�!�!�	�)�+�+�D�L�L����!�	�	�	�M�G��N�N�7�C��F�F�+�+�+��F�F�F�F�F�����		����
	���<�=�=�=��������t�)�*�*�*����
�
�
��,�,�.�.�.�������#(�� ��� � �"�"�"���������*�+�+�+����?�@�@�@�@�@s�0B�C
�*C�C
c���tj�|j��rH|���	tj|j��dS#ttf$rYdSwxYwdS)z%
        Force reload daemon
        N)r$r��isfile�_WPOS_DAEMON_RELOAD_FILErQ�remover�r�r�s r'r�zWposDaemon._force_reloadHsy��
�7�>�>�$�7�8�8�	��K�K�M�M�M�
��	�$�7�8�8�8�8�8���W�%�
�
�
����
����	�	s�A�A*�)A*c��	t�dt��|j�|j���tjt��t�dt��dS#ttf$r9}t�	dtt|����Yd}~dSd}~wwxYw)z-
        Remove daemon's socket file
        zRemoving socket %sNzSocket %s removedz!Can't remove socket %s. Error: %s)rrrsrra�closer$r�r�r�r�ry)rfrs  r'r�zWposDaemon._remove_socketUs���	a��K�K�,�.E�F�F�F��|�'���"�"�$�$�$��I�-�.�.�.��K�K�+�-D�E�E�E�E�E����!�	a�	a�	a��N�N�>�@W�Y\�]^�Y_�Y_�`�`�`�`�`�`�`�`�`�����	a���s�A9A=�=C�.C�CFr��gracefulc�J�t|j��}|�rG	t�d|��t	j|tj��n3#t$r&}t�d||��Yd}~nd}~wwxYwd}||kra	t	j|d��n+#t$rt�d|��Yn�wxYw||z
}tj
|��||k�at�d|��	t	j|tj��n3#t$r&}t�d||��Yd}~nd}~wwxYw|rtt��t|j��t�d��dS)z0
        Stops a working daemon process
        zKilling process with PID %sz4Process with pid %s is not possible to be killed: %sNrz#Process with pid %s is finally deadz:Process with pid %s did not exit in timeout, sigkilling itz&Cloudlinux AccelerateWP daemon stopped)rr�rrrsr$�kill�signal�SIGTERMr�rvr��SIGKILLrr)rfr��timeout�interval�pidrr�s       r'�stopzWposDaemon.stopbs����d�0�1�1���	`�
\����9�3�?�?�?����V�^�,�,�,�,���
\�
\�
\����R�TW�YZ�[�[�[�[�[�[�[�[�����
\�����A��g�+�+���G�C��O�O�O�O�������K�K� E�s�K�K�K��E������X�
���
�8�$�$�$��g�+�+����X�Z]�^�^�^�`��G�C���0�0�0�0���`�`�`��K�K� V�X[�]^�_�_�_�_�_�_�_�_�����`�����	+�"�6�*�*�*���*�+�+�+����<�=�=�=�=�=sA�:A�
B�A?�?B�B&�&%C�
C�D,�,
E�6E�Ec�H�dtj��t��d�S)zy
        Get litespeed webserver status: running or not.
        :return: Dict to send to clwpos-user via socket
        rm)rM�	timestamp�status)rvrr>r)r'�_get_litespeed_statusz WposDaemon._get_litespeed_status�s!��$�$�)�+�+�I]�I_�I_�`�`�`r)�client_socket_objc�0�tj|��}	t|��}n=#t$r0tj|dd|itj��d���YdSwxYw	tj|��}nE#tjtj	tjtjttf$rd}YnwxYw|�tj|dd|id���dSd	|vr+tj|d
tj��d���dS|d	|jvr+tj|dtj��d���dS|d
kr�d|vr+tj|dtj��d���dS|d}	t|��}n=#t$r0tj|dd|itj��d���YdSwxYw|d	|jvr+tj|dtj��d���dSd|||dfSd|||dfS)a,
        Validate socket connection. Check:
         - root connections
         - connection user presense
         - command validity
        :return: tuple(is_connection_valid, uid, username, user_request_dict, is_root_query)
          is_connection_valid:
           True - Socket connection valid, should be processed. uid, username and user_request_dict filled
           False - invalid connection, should be skipped. uid == -1, username and user_request_dict = None
          is_root_query - True - root query, do not check reload interval
        zNo user uid=%(uid)d�uid)rM�contextr�)F���NNFNz>User %(username)s sent invalid query to CL AccelerateWP daemonr|�rMr��commandz0Daemon received malformed query (command absent))rMr�zDaemon received invalid commandrz)Root request to daemon should contain uidTF)�socket_utils�get_uid_from_socketrr��(send_dict_to_socket_connection_and_closerv�'read_unpack_response_from_socket_daemonr,�errorr�rH�JSONDecodeError�struct�AttributeError�UnicodeDecodeError�_DAEMON_VALID_COMMANDS�_DAEMON_VALID_COMMANDS_FOR_ROOT)rfr��_uidr|�user_requests     r'�_validate_socket_connectionz&WposDaemon._validate_socket_connection�s ���/�0A�B�B��	0�/��5�5�H�H���	0�	0�	0��A�BS�Mb�OT�VZ�m�PT�PY�P[�P[�C]�C]�
^�
^�
^�0�/�/�	0����	 �+7�+_�`q�+r�+r�L�L����f�n�d�.B�F�L�R`�bt�u�	 �	 �	 ��L�L�L�	 �������A�BS�Nf�OY�[c�Nd�Cf�Cf�
g�
g�
g�0�/��L�(�(��A�BS�N_�PT�PY�P[�P[�C]�C]�
^�
^�
^�0�/��	�"�$�*E�E�E��A�BS�Mn�PT�PY�P[�P[�C]�C]�
^�
^�
^�0�/��1�9�9��L�(�(��E�FW�R_�TX�T]�T_�T_�Ga�Ga�b�b�b�4�3���&�D�
4�3�D�9�9�����
4�
4�
4��E�FW�Qf�SX�Z^�R_�TX�T]�T_�T_�Ga�Ga�b�b�b�4�3�3�
4�����I�&�d�.R�R�R��E�FW�Qr�TX�T]�T_�T_�Ga�Ga�b�b�b�4�3���x��t�;�;��T�8�\�5�8�8s3�&�6A �A �$A9�9?B;�:B;�F�6G
�G
r|r�c�*�|j�|d��}|�tj|dd|id���dS|j5t|��\}}}|ddkr||d<tj||��ddd��dS#1swxYwYdS)z�
        Get redis status for user (socket query)
        :param client_socket_obj: Client socket connection
        :param username: User name
        :param uid: User uid
        Nz"User %(username)s has no redis yetr|r�rMrmr�)r_rnr�r�r!r)rfr�r|r�r�r�r6r~s        r'�_socket_user_get_redis_statusz(WposDaemon._socket_user_get_redis_status�s(�� $�:�>�>�s�D�I�I�	����A�BS�Mq�OY�[c�Nd�Cf�Cf�
g�
g�
g�
g�
g���
f�
f�1D�S�1I�1I�.���;��x�(�I�5�5�,:�K��)��E�FW�Yd�e�e�e�
f�
f�
f�
f�
f�
f�
f�
f�
f�
f�
f�
f����
f�
f�
f�
f�
f�
fs�:B�B�Br"c�L�|dkptj��|z
|jkS)zv
        Checks is reload available by checking time
        :return: True - available, False - not available
        r)rv�_MIN_ALLOWED_RELOAD_PERIOD)rfr"s  r'�_is_reload_availablezWposDaemon._is_reload_available�s(��
 �1�$�h��	���6F�(F��Ih�(h�hr)�
is_root_queryc��|j�|��}|�a|�|d|���}tj��|d<t	j||��t�d||��dS|j}|sK|�	|��s6tj��d||j
d�d�}t	j||��dS|j5|�|d��}tj��|d<t	j||��t�d	||��ddd��dS#1swxYwYdS)
a>
        Reload redis for user (socket query)
        :param client_socket_obj: Client socket connection
        :param username: User name
        :param uid: User uid
        :param is_root_query: True - reload redis by root, do not check reload interval
          False - user reload, check reload interval
        NT)rkr�zX[Redis user data not found] Cloudlinux AccelerateWP daemon reloaded for user %s (uid=%d)zSCan't reload redis for user %(user)s. Last reload was less than %(sec)s seconds ago)�user�sec)r�rMr�zT[Redis user data found] Cloudlinux AccelerateWP daemon reloaded for user %s (uid=%d))r_rnr�rvr�r�rrr�r"r�r�r!)	rfr�r|r�r�rkr�r~r"s	         r'�_socket_user_redis_reloadz$WposDaemon._socket_user_redis_reload�s��� $�:�>�>�s�C�C�	����5�5�c�4�l�5�[�[�K�'+�y�{�{�K��$��A�BS�U`�a�a�a��L�L�^�_g�il�
n�
n�
n��F�$�5���	�T�%>�%>�?O�%P�%P�	�)-�	���&3�/7��@_�&`�&`�b�b�K�
�A�BS�U`�a�a�a��F�
�^�	n�	n��5�5�c�4�@�@�K�'+�y�{�{�K��$��A�BS�U`�a�a�a��L�L�^�_g�il�
n�
n�
n�		n�	n�	n�	n�	n�	n�	n�	n�	n�	n�	n�	n����	n�	n�	n�	n�	n�	ns�AE�E�EN�accountc���dtdtdtfd�}|p
t��}|r#|�dt|������ �fd�|���D��}g}|���D]~\}}	|�||d|d||d	|d
��t|��dd����W#t$r|r|�d
|��Y�{wxYw|S)N�handler_name�
version_idr*c�2�|dkrdSd|vrdS|rd|vrdS|S)N�fpmzphp-fpmz
x-httpd-lsphp�lsapi�lsphpr>)r�r�s  r'�_castz1WposDaemon._php_get_vhost_versions.<locals>._cast%s?���u�$�$� �y� �J�.�.��w��
�'�\�"9�"9��w��r)z[PHP vhost info]: %sc�4��i|]\}}|d�k�||��S)r|r>)r?r@rAr�s   �r'�
<dictcomp>z6WposDaemon._php_get_vhost_versions.<locals>.<dictcomp>5s8���<�<�<�*�#�u�#�J�/�7�:�:���:�:�:r)r|�display_version�handler_type�php_version_idr)�vhostr��version�handler�documentrootz)Error on getting php version for %s, skip)ryr
rsrEr�rrwrx)r�rr�php_vhost_datar��vhosts_datarMr@rAs`       r'�_php_get_vhost_versionsz"WposDaemon._php_get_vhost_versions"sr���		 ��		 ��		 ��		 �		 �		 �		 �%�>�(<�(>�(>���	B��K�K�.��K�0@�0@�A�A�A���<�<�<�<��8I�8I�8K�8K�<�<�<�K���%�+�+�-�-�	�	�J�C��

��
�
�!�e�J�.?� %�&7� 8� %��e�N�&;�U�CS�=T� U� U�%,�S�\�\�!�_�6�6�7�7�7�7��
�
�
�
��W��$�$�%P�RU�V�V�V���	
�����
s�AC�"D�Dc�X�|���}tj||��dS)z/
        Get litespeed status for user
        N)r�r�r�)rfr�rMs   r'�_socket_user_litespeed_statusz(WposDaemon._socket_user_litespeed_statusHs0��
�1�1�3�3���=�>O�QW�X�X�X�X�Xr)c���	|�|t���}d|d�}n)#t$r}dt|��d�}Yd}~nd}~wwxYwt	j||��dS)N)rrrm�rMrDz)Daemon cannot get vhosts data: %(reason)sr�)r�rrrwryr�r�)rfr�r��
vhost_data�responsers      r'�#_socket_user_php_get_vhost_versionsz.WposDaemon._socket_user_php_get_vhost_versionsPs���	��5�5�g�f�5�M�M�J�$�"���H�H��
�	�	�	�E��q�6�6���H�H�H�H�H�H�����	����	�=�>O�QY�Z�Z�Z�Z�Zs�$�
A
�A�A
c�R�dt��d�}tj||��dS)Nrmr�)rr�r�)rfr�rs   r'�'_socket_user_php_get_installed_versionsz2WposDaemon._socket_user_php_get_installed_versions_s7���.�0�0�
�
��	�=�>O�QY�Z�Z�Z�Z�Zr)c��ddlm}|��}d|�|t|d���dd|���d�}t	j||��dS)Nr)�get_server_wide_optionsrm)�dns)�keyls)r|�domain�feature)rM�upgrade_url)�clwpos.utilsr�get_upgrade_url_for_userrr�r�)rfr�r|r	r�server_optionsrs       r'�_get_upgrade_linkzWposDaemon._get_upgrade_linkfs���	9�8�8�8�8�8�0�0�2�2���)�B�B�!��h�h�7�7�7��:�1�=��C���
�
��	�=�>O�QY�Z�Z�Z�Z�Zr)c�X�ddlm}d||��d�}tj||��dS)zI
        Get unique identifier which we use as user's auth token
        r)�get_or_create_unique_identifierrm)rM�	unique_idN)�clwpos.billingrr�r�)rfr�r|rrs     r'�_get_unique_idzWposDaemon._get_unique_idwsQ��	C�B�B�B�B�B��8�8��B�B�
�
��	�=�>O�QY�Z�Z�Z�Z�Zr)c�b�ddlm}|��\}}d||d�}tj||��dS)Nr)�get_suites_status_from_licenserm)rM�accelerate_wp_premium�accelerate_wp_cdn)rrr�r�)rfr�r�awp_premium_status�awp_cdn_statusrs      r'� _get_supported_suites_by_licensez+WposDaemon._get_supported_suites_by_license�sZ��?�?�?�?�?�?�-K�-K�-M�-M�*��N��%7�!/�
�
��
	�=�>O�QY�Z�Z�Z�Z�Zr)c��	|�|��\}}}}}|sdSt�dt|����|d|jkr|�|||��dS|d|jkr1|�dd��}|�|||||��dS|d|j	kr|�
|��dS|d|jkr|�||��dS|d|j
kr|�|��dS|d|jkr-|�|||�dd����dS|d|jkr|�||��dS|d|jkr|j�|��dS|d|jkr|j�|||��dS|d|jkr2|j�|||�dd����dS|d|jkr|�|��dSdS#t8$r t�dd	�
��YdSwxYw)z�
        Process client's socket connection (Works in thread)
        :param client_socket_obj: Client socket connection
        NzIncome user request=%sr�rkrhr	�object_cachez"Socket connection processing errorTr�)r�rrrsry� _DAEMON_GET_REDIS_STATUS_COMMANDr��_DAEMON_RELOAD_COMMANDrnr��$_DAEMON_GET_LITESPEED_STATUS_COMMANDr��%DAEMON_PHP_GET_VHOST_VERSIONS_COMMANDr�)DAEMON_PHP_GET_INSTALLED_VERSIONS_COMMANDr�DAEMON_GET_UPGRADE_LINK_COMMANDr�DAEMON_GET_UNIQUE_ID_COMMANDr�DAEMON_SUITE_ALLOWED_CALLBACKrerV�DAEMON_REGISTER_UPGRADE_ATTEMPT�add_pending_upgrade_task�!DAEMON_GET_UPGRADE_ATTEMPT_STATUS�get_upgrade_task_status�&DAEMON_GET_SUPPORTED_SUITES_BY_LICENSErrwrx)rfr��is_connection_validr�r|r�r�rks        r'� _handle_client_socket_connectionz+WposDaemon._handle_client_socket_connection�s��
&	R��0�0�1B�C�C�
L���h��m�&�
����K�K�0�#�l�2C�2C�D�D�D��I�&�$�*O�O�O��2�2�3D�h�PS�T�T�T�T�T��i�(�D�,G�G�G�+�/�/���E�E���.�.�/@�(�C�Q^�`l�m�m�m�m�m��i�(�D�,U�U�U��2�2�3D�E�E�E�E�E��i�(�D�,V�V�V��8�8�9J�H�U�U�U�U�U��i�(�D�,Z�Z�Z��<�<�=N�O�O�O�O�O��i�(�D�,P�P�P��&�&�'8�(�'3�'7�'7�	�>�'R�'R�T�T�T�T�T��i�(�D�,M�M�M��#�#�$5�x�@�@�@�@�@��i�(�D�,N�N�N��#�:�:�;L�M�M�M�M�M��i�(�D�,P�P�P��#�<�<�=N�P\�^a�b�b�b�b�b��i�(�D�,R�R�R��#�;�;�<M�s�<H�<L�<L�Y�Xf�<g�<g�i�i�i�i�i��i�(�D�,W�W�W��5�5�6G�H�H�H�H�H�X�W���	R�	R�	R����A�D��Q�Q�Q�Q�Q�Q�	R���sU�I�AI�3AI�5&I�'I�&I�.<I�,'I�+I�-I�1AI�4&I�&J�Jc��t�d��|jr�tj|jgggd��\}}}|D]v}	|���\}}t
|j|f���}|����F#tj
$rt�dd���Y�swxYw|j��t�d��dS)	z>
        Process socket connections (works in thread)
        z4Cloudlinux AccelerateWP daemon socket thread startedr�)r��argszSocket connection errorTr�z4Cloudlinux AccelerateWP daemon socket thread stoppedN)rrrsrd�selectra�acceptr
r+r�r,r�rx)rf�readabler6�_sock_objectr��ts      r'r�z&WposDaemon._process_socket_connections�s��	���J�K�K�K��&�	O�#�]�D�L�>�2�r�1�E�E�N�H�a�� (�
O�
O��O�+7�+>�+>�+@�+@�(�%�q��d�&K�Sd�Rf�g�g�g�A��G�G�I�I�I�I���|�O�O�O��$�$�%>��$�N�N�N�N�N�O�����&�	O�	���J�K�K�K�K�Ks�AB�+B9�8B9)rh)FrZr�)NNN)8�__name__�
__module__�__qualname__�__doc__r�rrrr r!r"r#r$r%r'r)r�r�r��_REDIS_SOCKET_WAIT_TIMEOUTr^�int�boolryrr�r�r�r�r�r�rGr�r�r��staticmethod�dictr�r,rrr�r�r�r�r�r�r�rrrrrr+r��
__classcell__)rgs@r'rPrP`sM��������� 6��%��'9�$�+A�(�,D�)�0L�-�&8�#�#2� �$<�!�&?�#�(C�%�-U�*��(�,�-�1�'�$�'�)�%�.���	�'�$�)�%�.�
'�#�"$��!#��;�;�;�;�;� (%�(%�s�(%�t�(%�cf�(%�rv�(%�(%�(%�(%�T"��"��"�"�"�"�H
9�
9�
9�@�@�@� `�`�`�.$�$�$� A� A� A�D���a�a�a�#>�#>�T�#>�#>�#>�#>�P�a�4�a�a�a��\�a�K9�V�]�K9�u�UY�[^�`h�il�`m�U]�^b�Uc�ei�Vj�Pk�K9�K9�K9�K9�Zf�v�}�f�X[�f�be�f�f�f�f�,i�S�i�T�i�i�i�i�ei�$n�$n�6�=�$n�,/�$n�69�$n�JN�$n�^a�$n�$n�$n�$n�L�#�#��#�Z^�#�#�#��\�#�JY�v�}�Y�Y�Y�Y�
[�V�]�
[�]`�
[�
[�
[�
[�[���[�[�[�[�[�6�=�[�[�[�[�"	[��
�	[�	[�	[�	[�[�&�-�[�[�[�[�+R�&�-�+R�TX�+R�+R�+R�+R�ZL�L�L�L�L�L�Lr)rP)N)>�loggingr$r�rFrvrHr,r.ror��typingrrrr�
contextlibr�collectionsr�	threadingr	r
�clwposrr6�clcommon.cpapirr
rrrr�clcommon.utilsrrrr�clwpos.daemon_redis_librrrr�clwpos.socket_utilsr��clwpos.daemon_baser�clwpos.constantsr�clwpos.cl_wpos_exceptionsr�"clwpos.daemon_subscription_handlerrr�	getLoggerr3rrr(r1r8ryrNrPr>r)r'�<module>rLs�������	�	�	�	�
�
�
�
�������������
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�.�.�.�.�.�.�.�.�.�.�.�.�%�%�%�%�%�%�"�"�"�"�"�"�"�"�"�"�"�"�"�"�����������������������������������������������+�*�*�*�*�*�-�-�-�-�-�-�4�4�4�4�4�4�9�9�9�9�9�9�I�I�I�I�I�I��J�{�$M�$M�$M�N�N�	�	��	�8�	$�	$��������
��
�
�
�
�
��	�D�	�	�	���	�6�6�c�6�X�d�3��8�n�-E�6�6�6�6�g	L�g	L�g	L�g	L�g	L��g	L�g	L�g	L�g	L�g	Lr)

Zerion Mini Shell 1.0