File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/internal/__pycache__/utils.cpython-311.pyc
�
?Ocj�D �
�L � d Z ddlZddlZddlZddlZddlZddlZddlZddlm c m
Z ddlm
Z
ddlmZ ddlmZmZ ddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZ dd lmZ ddl Z dd
l!m"Z" ddl#m$Z$ ddl%m&Z& dd
l'm(Z(m)Z)m*Z*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2 ddl,m3Z3 ddl4m5Z5 ddl6m7Z7 ej8 d� � Z9 e
dddg� � Z:de;de;fd�Z<de;de:fd�Z=dee; fd�Z>dee; fd�Z?dFd�Z@dGd!e;d"eAde;fd#�ZBd$e;de;fd%�ZCdHd'e;d(eDdefd)�ZEde;fd*�ZFdId,e;de;fd-�ZGde;fd.�ZHd/eDdeIfd0�ZJd1e;dee; fd2�ZKdeAfd3�ZLdeAfd4�ZMdeAfd5�ZNd6eAddfd7�ZOdeAfd8�ZPde;fd9�ZQd:e;d;ee;ef deAfd<�ZRd=� ZSedJd>eDddfd?�� � ZTe dKdBeDdCeDd>eDddfdD�� � ZUdAZVdE� ZWdS )Lz>
This module contains helpful utility functions for SSA Agent
� N)�
namedtuple)�contextmanager)�date� timedelta)�LooseVersion)�socket�fromfd�AF_UNIX�SOCK_STREAM�AF_INET�AF_INET6�
SOCK_DGRAM)�Optional�Union)�urlparse)�AtexitIntegration)�LoggingIntegration)�Feature)�is_panel_feature_supported�get_cp_description�is_throttling_supported�is_wp2_environment)�get_kmodlve_module_version�get_username)�get_cl_edition_readable)�get_hostname)�get_rhn_systemid_value� )�
sentry_dsn)�SSAError�utils�URL�domain_name�uri_path�url�returnc �R � t | � � j � dd� � S )u�
The domain string the request processor stores as RequestResult.domain.
This is the single source of truth for a URL's domain attribution: it
operates on the raw netloc and removes every 'www.' substring, exactly as
the stored metric is keyed. The authorizer MUST derive its decision from
this same value (see SimpleAgent._authorize_sender) — any divergence
re-opens cross-tenant metric spoofing.
zwww.� )r �netloc�replace)r% s �I/opt/cloudlinux/venv/lib64/python3.11/site-packages/ssa/internal/utils.py�canonical_stored_domainr, 1 s# � � �C�=�=��'�'���3�3�3� c � � t | � � }|j r
d|j � �nd}|j r|j � |� �nd}t t | � � |� � S )z�
Split URL into domain_name and uripath including query string
:param url: URL of format protocol://domain/path;parameters?query#fragment
:return: namedtuple URL(domain_name, uripath)
�?r( �/)r �query�pathr"