HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3/dist-packages/twisted/web/__pycache__/vhost.cpython-38.pyc
U

s�@g��@s�dZddlmZmZzddlmZWn ek
rDddlmZYnXddl	m
Z
ddlmZGdd�de
j
�ZGdd	�d	ej�ZGd
d�dej�ZGdd
�d
ej�ZdS)z&
I am a virtual hosts implementation.
�)�division�absolute_import)�escape)�roots)�resourcec@s>eZdZdZejZdd�Zdd�Zdd�Z	dd	�Z
d
d�ZdS)
�VirtualHostCollectionzWWrapper for virtual hosts collection.

    This exists for configuration purposes.
    cCs
||_dS�N)�nvh)�selfr	�r�3/usr/lib/python3/dist-packages/twisted/web/vhost.py�__init__szVirtualHostCollection.__init__cCs|jj��Sr)r	�hosts�items�r
rrr�listStaticEntitiessz(VirtualHostCollection.listStaticEntitiescCs|jj�|�Sr)r	r�get�r
�namerrr�getStaticEntity"sz%VirtualHostCollection.getStaticEntitycCs|j�||�dSr)r	�addHost)r
rZentityrrr�reallyPutEntity%sz%VirtualHostCollection.reallyPutEntitycCs|j�|�dSr)r	�
removeHostrrrr�	delEntity(szVirtualHostCollection.delEntityN)�__name__�
__module__�__qualname__�__doc__r�ResourceZ
entityTyper
rrrrrrrrrsrc@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)�NameVirtualHostz:I am a resource which represents named virtual hosts.
    NcCstj�|�i|_dS)zInitialize.
        N)rrr
rrrrrr
2szNameVirtualHost.__init__cCstj�|�dt|�fgS�Nz
Virtual Hosts)rrrrrrrrr8sz"NameVirtualHost.listStaticEntitiescCs"|dkrt|�Stj�||�SdSr )rrrrrrrrr;szNameVirtualHost.getStaticEntitycCs||j|<dS)a�Add a host to this virtual host.

        This will take a host named `name', and map it to a resource
        `resrc'.  For example, a setup for our virtual hosts would be::

            nvh.addHost('divunal.com', divunalDirectory)
            nvh.addHost('www.divunal.com', divunalDirectory)
            nvh.addHost('twistedmatrix.com', twistedMatrixDirectory)
            nvh.addHost('www.twistedmatrix.com', twistedMatrixDirectory)
        N�r)r
r�resrcrrrrAszNameVirtualHost.addHostcCs|j|=dS)zRemove a host.Nr!rrrrrNszNameVirtualHost.removeHostcCsZ|�d�}|dkr |jpt��S|���dd�d}|j�||j�pXt�dtt	|���S)zD(Internal) Get the appropriate resource for the given host.
        shostN�:�rzhost %s not in vhost map)
Z	getHeader�defaultrZ
NoResource�lower�splitrr�html_escape�repr)r
�requestZ
hostHeader�hostrrr�_getResourceForRequestRs
�z&NameVirtualHost._getResourceForRequestcCs|�|�}|�|�S)z=Implementation of resource.Resource's render method.
        )r,�render)r
r*r"rrrr-]s
zNameVirtualHost.rendercCs:|�|�}|jr*|j�d|j�d��|S|�||�SdS)z?Implementation of resource.Resource's getChild method.
        r���N)r,ZisLeaf�postpath�insert�prepath�popZgetChildWithDefault)r
�pathr*r"rrr�getChildcs

zNameVirtualHost.getChild)
rrrrr%r
rrrrr,r-r4rrrrr,s
rc@seZdZdd�ZdS)�
_HostResourcecCs�d|kr"|�dd�\}}t|�}n
|d}}|�||�d|��dt|�t|jd�}dd�|j�|_|j	|d�|_	|jdd�=|j
�|�S)Nr#r$�P������/)r'�intZsetHost�isSecure�lenr1�joinr/r3ZuriZsiteZgetResourceFor)r
r3r*r+ZportZ	prefixLenrrrr4os

�z_HostResource.getChildN)rrrr4rrrrr5msr5c@seZdZdZdd�ZdS)�VHostMonsterResourcea.
    Use this to be able to record the hostname and method (http vs. https)
    in the URL without disturbing your web site. If you put this resource
    in a URL http://foo.com/bar then requests to
    http://foo.com/bar/http/baz.com/something will be equivalent to
    http://foo.com/something, except that the hostname the request will
    appear to be accessing will be "baz.com". So if "baz.com" is redirecting
    all requests for to foo.com, while foo.com is inaccessible from the outside,
    then redirect and url generation will work correctly
    cCs,|dkrdd�|_n|dkr&dd�|_t�S)NshttpcSsdS)Nrrrrrr�<lambda>��z/VHostMonsterResource.getChild.<locals>.<lambda>shttpscSsdS)Nr$rrrrrr@�rA)r<r5)r
r3r*rrrr4�s

zVHostMonsterResource.getChildN)rrrrr4rrrrr?~s
r?N)rZ
__future__rrZhtmlrr(�ImportErrorZcgiZtwisted.pythonrZtwisted.webrZ
Homogenousrrrr5r?rrrr�<module>sA