Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/commons/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/lvestats/lib/commons/__pycache__/litespeed.cpython-311.pyc

�

)�fA����ddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
Gd�de��ZGd�de��ZGd	�d
e��ZGd�de��ZGd
�de��ZdS)�)�absolute_importN)�etree)�get_all_user_domains�normalize_domainc��eZdZdS)�LiteSpeedExceptionN��__name__�
__module__�__qualname__����/builddir/build/BUILDROOT/lve-stats-4.2.8-1.el8.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/commons/litespeed.pyrr��������Drrc��eZdZdS)�LiteSpeedDisabledExceptionNr	r
rrrrrrrc��eZdZdS)�LiteSpeedInvalidCredentialsNr	r
rrrrrrrc��eZdZdZdZdZdZdS)�LiteSpeedDataMapping����N)r
rr�TIME�HOST�REQUEST�	TOTAL_LENr
rrrr s"�������D��D��G��I�I�Irrc��eZdZdgZdZdZdZdZd�Ze	d���Z
e	d���Zd	�Zd
�Z
d�Zdefd
�Zd�Ze	d���ZdS)�	LiteSpeeds_AdminVHostz/tmp/lshttpd/lshttpd.pidz&/usr/local/lsws/admin/htpasswds/status�z+/usr/local/lsws/admin/conf/admin_config.xmlc�"�||_||_dS)N)�login�password)�selfr#r$s   r�__init__zLiteSpeed.__init__/s����
� ��
�
�
rc�r�tj�tj��r�tj�tj��rdt
tj��5}|����tj	��cddd��S#1swxYwYdSdS)zX
        Returns pid that is stored in litespeed's pidfile
        :return: str
        N)
�os�path�isfiler �
PID_FILE_PATH�
HTPASSWD_PATH�open�readline�rstrip�linesep)�fs r�_get_litespeed_pidzLiteSpeed._get_litespeed_pid3s����7�>�>�)�1�2�2�	�r�w�~�~�i�F]�7^�7^�	��i�-�.�.�
7�!��z�z�|�|�*�*�2�:�6�6�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7�
7����
7�
7�
7�
7�
7�
7��4s�,1B*�*B.�1B.c�8�t���duS)zG
        Checks whether pid is not None.
        :return: bool
        N)r r2r
rr�is_litespeed_runningzLiteSpeed.is_litespeed_running?s���+�+�-�-�T�9�9rc	��	tjt|j�������}|�d��d}|j�d��dS#tttttf$r:}td�|jt|�������d}~wwxYw)z}
        Retrives current LiteSpeed webadmin console port
        :return: LiteSpeed webadmin console port as string
        zlistenerList/listener/addressr�:�zJCan't determine current LiteSpeed webadmin console port from config {}: {}N)r�parser-�LS_ADMIN_CONFIG�getroot�xpath�text�split�AttributeError�
IndexError�
ValueError�OSError�IOErrorr�format�str)r%�
ls_adm_cfg�data�es    r�_get_litespeed_webadmin_portz&LiteSpeed._get_litespeed_webadmin_portGs���
	K���T�$�*>�%?�%?�@�@�H�H�J�J�J��#�#�$C�D�D�Q�G�D��9�?�?�3�'�'��*�*���
�J���I�	K�	K�	K�$�%q�%+�V�D�,@�#�a�&�&�%I�%I�K�K�
K�����	K���s�A2A5�5#C�5C
�
Cc�R�d�|�����}tj�|��}tjd|j���|j	���fz��}|�
dd|z��	tj�||jtj��������}ny#tjj$r9}|jdvrt'd���t)t+|�����d}~wt,$r!}t)t+|�����d}~wwxYwd	�|�t0j�����D��}|S)
z�
        Get info about connections from litespeed
        and returns array of rows with data
        :return: list
        :raise: [LiteSpeedInvalidCredentials, LiteSpeedDisabledException]
        z&http://localhost:{}/status?rpt=detailss%s:%ss
AuthorizationsBasic %s)�timeout�context)i�i�zILitespeed login / password invalid. Please, try restart lvestats service.Nc�B�g|]}|���dk�|��S)r)�strip)�.0�rows  r�
<listcomp>z+LiteSpeed._get_requests.<locals>.<listcomp>ws+��[�[�[�#��	�	���WZ�HZ�HZ�#�HZ�HZ�HZr)rCrH�urllib�request�Request�base64�	b64encoder#�encoder$�
add_header�urlopen�HTTP_TIMEOUT�ssl�_create_unverified_context�read�error�	HTTPError�coderrrD�	Exceptionr=r(r0)r%�
status_urlrR�base64string�responserG�results       r�
_get_requestszLiteSpeed._get_requests^s���>�D�D�T�Ef�Ef�Eh�Eh�i�i�
��.�(�(��4�4���'��D�J�4E�4E�4G�4G���I]�I]�I_�I_�3`�(`�a�a�����+�[�<�-G�H�H�H�		5��~�-�-�g�t�?P�69�6T�6V�6V�.�X�X�X\�X\�X^�X^�
�H���|�%�	5�	5�	5��v��#�#�1�3Z�[�[�[�,�S��V�V�4�4�4������	5�	5�	5�,�S��V�V�4�4�4�����	5����\�[�����
�0A�0A�0C�0C�!D�!D�[�[�[���
s%�(A
C3�3E)�4D;�;
E)�E$�$E)c�H�|���}|r||jvrdSdS)z`
        Check whether host is not empty.
        :type host: str
        :return: bool
        TF)rM�IGNORE_HOSTS)r%�hosts  r�__is_host_validzLiteSpeed.__is_host_validzs0���z�z�|�|���	�D�� 1�1�1��4��urrRc���|�d�����}t|��dkr|\}}}nt|��dkr|\}}d}ndS|||fS)z4
        :return: method, url, http_version
        �"rr!rN)rMr=�len)r%rR�request_info�method�url�http_versions      r�_parse_request_infozLiteSpeed._parse_request_info�sw���}�}�T�*�*�0�0�2�2���|����!�!�(4�%�F�C���
��
�
�!�
#�
#�&�K�F�C��L�L��4��s�L�(�(rc	��d}|���}t|��}ttt|����}|���}g}|D]�}|�|��}	t|	��tj	kr�5|	tj
}
|	tj}|�|	tj
��}|�|
��r[t	|
�����|vr8|�|��}|�!|\}
}}|�||
|
|||f����|S)z�
        Returns information about processed by user pages.
        :param username:
        :return list[list]:
        list of the lists
        [[Pid, Domain, Http type, Path, Http version, Time],...]
        :raises: LiteSpeedDownException
        �	)r2r�set�maprrer=rlrrrr�to_floatr�_LiteSpeed__is_host_valid�decoderq�append)r%�username�data_delimiter�pid�all_domains�normalized_domains�requests�litespeed_requestsrRrmrh�request_time�request_datarnrorps                r�
get_user_datazLiteSpeed.get_user_data�sL�����%�%�'�'��*�8�4�4�� ��%5�{�!C�!C�D�D���%�%�'�'�����	d�	d�G�"�=�=��8�8�L��<� � �#7�#A�A�A��� 4� 9�:�D�"�#7�#?�@�G� �=�=��6J�6O�)P�Q�Q�L��#�#�D�)�)�
d�$�T�[�[�]�]�3�3�7I�I�I�#�7�7��@�@���+�0<�-�F�C��&�-�-�s�D�&�#�|�Ua�.b�c�c�c��!�!rc�D�	t|��S#t$rYdSwxYw)zl
        Converts str to float, if can't return -1.
        :type string: str
        :rtype: float
        g�)�floatr@)�strings rrvzLiteSpeed.to_float�s5��	���=�=� ���	�	�	��3�3�	���s��
�N)r
rrrgr+r,rYr9r&�staticmethodr2r4rHrerw�bytesrqr�rvr
rrr r (s�������"�#�L�.�M�<�M��L�C�O�!�!�!��	�	��\�	��:�:��\�:�K�K�K�.���8	�	�	�)�5�)�)�)�)�%"�%"�%"�N�	�	��\�	�	�	rr )�
__future__rrT�urllib.requestrQ�urllib.error�urllib.parserZr(�lxmlr�lvestats.lib.commons.funcrrr`rrr�objectrr r
rr�<module>r�sj��'�&�&�&�&�&�
�
�
�
�������������
�
�
�
�	�	�	�	�������L�L�L�L�L�L�L�L�	�	�	�	�	��	�	�	�	�	�	�	�	�!3�	�	�	�	�	�	�	�	�"4�	�	�	������6����\�\�\�\�\��\�\�\�\�\r

Hacked By AnonymousFox1.0, Coded By AnonymousFox