ok

Mini Shell

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

�

�2�f����ddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddl
mZddlmZmZddlmZmZmZmZmZddlmZdd	lmZmZmZmZmZdd
lm Z Gd�de
��Z!ee!j"ee!j"ee!j#iZ$d
�Z%d�Z&d�Z'eGd�d����Z(eGd�d����Z)d�Z*d�Z+d�Z,d�Z-dS)�N)�	dataclass�asdict)�Enum)�drop_privileges)�cpinfo)�List�Dict)�get_allowed_modules�get_admin_suites_config�write_suites_allowed�
ALL_SUITES�get_allowed_suites)�CDNSuitePro)�OBJECT_CACHE_FEATURE�CRITICAL_CSS_FEATURE�IMAGE_OPTIMIZATION_FEATURE�CDN_FEATURE�Feature)�
UserConfigc��eZdZdZdZdZdZdS)�BillingFeaturezA
    Backwards-compatible list of features that we bill for.
    zAccelerateWP PremiumzAccelerateWP CDN FreezAccelerateWP CDN ProN)�__name__�
__module__�__qualname__�__doc__�ACCELERATE_WP_PREMIUM�ACCELERATE_WP_CDN�ACCELERATE_WP_CDN_PRO���E/opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/billing.pyrr s.��������3��/��2���r rc��|tkrt�|��Stj|vrt
jSt�|��S)N)r�FEATURE_TO_BILLING_FEATURE�getr�namerr)�feature�allowed_suitess  r!�billing_feature_by_awp_featurer(/sL���+���)�-�-�g�6�6�6���>�)�)��3�3�%�)�)�'�2�2�2r c�8�|�dStjd|��duS)z-
    Checks that string has uuid4 format
    NFzK[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})�re�match)�values r!�
is_valid_uuidr-8s(��
�}��u�
�8�a�ch�i�i�qu�u�ur c�R�tj��rt��Stj|��}t|j��}|j}|�t|��s@ttj����|_t|j|j
|��|jS)z�
    We need some unique identifier which user can
    use as his token on our provisioning server.

    We use uuid4 to make it somehow hard to bruteforce
    and still unique (hopefully as we don't check that :P)
    )�os�geteuid�get_unique_identifier_as_user�pwd�getpwnamr�pw_uid�	unique_idr-�str�uuid�uuid4r�pw_gid)�username�pw�configr5s    r!�get_or_create_unique_identifierr=As���
�z�|�|�/�,�.�.�.�	��h�	�	�B�
$�R�Y�
/�
/�F�� �I���
�i� 8� 8���t�z�|�|�,�,����R�Y��	�6�:�:�:���r c�8�eZdZUeed<eed<eed<eed<dS)�
FeatureRecordr%�
purchase_date�
attributes�activeN)rrrr6�__annotations__r	�boolrr r!r?r?Vs:�������

�I�I�I����������L�L�L�L�Lr r?c�D�eZdZUeed<eed<eed<eeed<dS)�
UserRecordr:�primary_domain�id�featuresN)rrrr6rCrr?rr r!rFrF_sA��������M�M�M������G�G�G��=�!�!�!�!�!�!r rFc�j�g}td���D]�\}}	tj|��j}n%#t$rtjd|��Y�AwxYw	t|||��}n%#t$rtj	d|��Y�ywxYw|�
t|������|S)z�
    Collect report about billable users.

    Look for all users with allowed feature and add them
    to list for the further processing on CLN side.

    legacy argument changes format so it
    is accepted by older CLN versions
    )�cplogin�dns)�keylszHUser %s does not have system uid; Malformed control panel configuration?z%CLN billing report for user %s failed)rr2r3r4�KeyError�logging�warning�_single_user_report�	Exception�	exception�appendr)�report�user�domain�uid�user_records     r!�
get_reportrZgs����F��%7�8�8�8�+�+���f�	��,�t�$�$�+�C�C���	�	�	��O�f�hl�m�m�m��H�	����	�-�c�4��@�@�K�K���	�	�	���E�t�L�L�L��H�	����	�
�
�f�[�)�)�*�*�*�*��Ms!�3�A�A�A+�+B
�B
c	���t|��}t|��}t|���t|��}�fd�|D��}�fd�|D��}t	��}|D]�}	t|	|��}
|
��|
j|vr�t|
j|�|	��rt||	��n>ttj����
d�����|�|	i��|	|v���||
j<��||
jjp|	|v||
j_��t||t!|��t#|��������S)Nc�p��i|]2}t|jD]}|�j�|�����3Sr)r
rI�purchase_datesr$��.0�suiter&�suites_admin_configs   �r!�
<dictcomp>z'_single_user_report.<locals>.<dictcomp>�s\�������!�%�(�1���
�	�$�3�7�7��>�>����r c	���i|]?}t|jD]*}|�j�|t	������+�@Sr)r
rIrAr$�dictr^s   �r!rbz'_single_user_report.<locals>.<dictcomp>�sb�������!�%�(�1���
�	�$�/�3�3�E�4�6�6�B�B����r �)�day)r%r@rArB)r:rGrHrI)r
�_get_enabled_modulesrrrdr(r,r?r$r6�datetime�date�today�replacerBrFr=�list�values)rXr:rWrI�enabled_featuresr'�feature_purchase_dates�feature_attributes�billable_featuresr&�billing_featureras           @r!rQrQ�s����1�#�6�6�H�+�H�5�5��1�#�6�6��'��,�,�N�����#���������#����������a�a��8��.�Q�Q���"��� �(9�9�9�7D�$�*�.�1�1�'�:�:�>�C�.�w�7�8�8�8���
�+�+�-�-�5�5�!�5�<�<�=�=�-�1�1�'�2�>�>��"2�2�8�8�8��o�3�4�4�$"�/�"7�8�?�`�G�O_�D_�
�o�3�4�;�;���!�.�x�8�8��+�2�2�4�4�5�5�	
�
�
�
r c��t|��5d�t|������D��cddd��S#1swxYwYdS)Nc��h|]\}}}|��	Srr)r_�_�modules   r!�	<setcomp>z'_get_enabled_modules.<locals>.<setcomp>�s*��.�.�.�<�1�a���.�.�.r )r:)rr�enabled_modules)rVs r!rgrg�s���	��	�	�.�.�.�.�:��,�,�,�*�?�,�,�.�.�.�.�.�.�.�.�.�.�.�.�.�.�.����.�.�.�.�.�.s�,A	�	A
�A
c�N�ddlm}ddlm}|d|ji��d}|S)z4
    Get unique identifier for current end-user
    r)�daemon_communicate)�
WposDaemon�commandr5)�clwpos.utilsrz�
clwpos.daemonr{�DAEMON_GET_UNIQUE_ID_COMMAND)rzr{r5s   r!r1r1�sW��0�/�/�/�/�/�(�(�(�(�(�(�"�"��:�:�$�����I��r ).rhrOr/r2r*r7�dataclassesrr�enumr�clcommon.clpwdr�clcommon.cpapir�typingrr	�clwpos.feature_suitesr
rrr
rr�clwpos.optimization_featuresrrrrr�clwpos.user.configrrrrr#r(r-r=r?rFrZrQrgr1rr r!�<module>r�s�����������	�	�	�	�
�
�
�
�	�	�	�	�����)�)�)�)�)�)�)�)�������*�*�*�*�*�*�!�!�!�!�!�!�����������������������.�-�-�-�-�-���������������*�)�)�)�)�)�3�3�3�3�3�T�3�3�3��.�>��� D���1���3�3�3�v�v�v����*������������"�"�"�"�"�"�"���"����25
�5
�5
�n.�.�.�
�
�
�
�
r 

Zerion Mini Shell 1.0