Your IP : 216.73.216.224


Current Path : /lib/python3/dist-packages/certbot_apache/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/certbot_apache/__pycache__/obj.cpython-38.pyc

U

���]�#�@sJdZddlZddlmZddlmZGdd�dej�ZGdd�de�ZdS)	z8Module contains classes used by the Apache Configurator.�N)�Set)�commoncs`eZdZdZdd�Zdd�Zdd�Z�fdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Z�Z
S)�AddrzRepresents an Apache address.cCs@t||j�r<|j|jkp:|jd|jdko:|��o:|��SdS)zTThis is defined as equivalent within Apache.

        ip_addr:* == ip_addr

        rF)�
isinstance�	__class__�tup�is_wildcard��self�other�r�4/usr/lib/python3/dist-packages/certbot_apache/obj.py�__eq__s��zAddr.__eq__cCs|�|�S�N�rr	rrr
�__ne__szAddr.__ne__cCsdt|j�dS)Nzcertbot_apache.obj.Addr(�))�reprr�r
rrr
�__repr__sz
Addr.__repr__cstt|���Sr)�superr�__hash__r�rrr
rsz
Addr.__hash__cCs|��|��kS)zAReturns if addr.get_addr() is more specific than self.get_addr().)�_rank_specific_addr�r
�addrrrr
�_addr_less_specific"szAddr._addr_less_specificcCs$|��dkrdS|��dkr dSdS)zzReturns numerical rank for get_addr()

        :returns: 2 - FQ, 1 - wildcard, 0 - _default_
        :rtype: int

        Z	_default_r�*��)�get_addrrrrr
r's
zAddr._rank_specific_addrcCs>|�|�rdS|��|��kr:|��s6|��|��kr:dSdS)a�Returns if address could conflict with correct function of self.

        Could addr take away service provided by self within Apache?

        .. note::IP Address is more important than wildcard.
            Connection from 127.0.0.1:80 with choices of *:80 and 127.0.0.1:*
            chooses 127.0.0.1:\*

        .. todo:: Handle domain name addrs...

        Examples:

        =========================================  =====
        ``127.0.0.1:\*.conflicts(127.0.0.1:443)``  True
        ``127.0.0.1:443.conflicts(127.0.0.1:\*)``  False
        ``\*:443.conflicts(\*:80)``                False
        ``_default_:443.conflicts(\*:443)``        True
        =========================================  =====

        TF)rr rZget_portrrrr
�	conflicts4s
zAddr.conflictscCs|jddkp|jdS)z'Returns if address has a wildcard port.rr)rrrrr
rPszAddr.is_wildcardcCs|��r|S|�|�S)z�Returns the least specific address that resolves on the port.

        Examples:

        - ``1.2.3.4:443`` -> ``1.2.3.4:<port>``
        - ``1.2.3.4:*`` -> ``1.2.3.4:*``

        :param str port: Desired port

        )rZget_addr_obj)r
Zportrrr
�get_sni_addrTszAddr.get_sni_addr)�__name__�
__module__�__qualname__�__doc__rrrrrrr!rr"�
__classcell__rrrr
rs
rc@sfeZdZdZe�d�Zddd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zddd�ZdS)�VirtualHosta�Represents an Apache Virtualhost.

    :ivar str filep: file path of VH
    :ivar str path: Augeas path to virtual host
    :ivar set addrs: Virtual Host addresses (:class:`set` of
        :class:`common.Addr`)
    :ivar str name: ServerName of VHost
    :ivar list aliases: Server aliases of vhost
        (:class:`list` of :class:`str`)

    :ivar bool ssl: SSLEngine on in vhost
    :ivar bool enabled: Virtual host is enabled
    :ivar bool modmacro: VirtualHost is using mod_macro
    :ivar VirtualHost ancestor: A non-SSL VirtualHost this is based on

    https://httpd.apache.org/docs/2.4/vhosts/details.html

    .. todo:: Any vhost that includes the magic _default_ wildcard is given the
              same ServerName as the main server.

    z^(?:.+://)?([^ :$]*)NFc

CsH||_||_||_||_|dk	r$|nt�|_||_||_||_|	|_	dS)zInitialize a VH.N)
�filep�path�addrs�name�set�aliases�ssl�enabled�modmacro�ancestor)
r
r)r*r+r/r0r,r.r1r2rrr
�__init__~szVirtualHost.__init__cCs8t�}|�|j�|jdk	r4|�tj�|j�d�|S)zReturn a set of all names.Nr)r-�updater.r,�addr(�
strip_name�findall)r
Z	all_namesrrr
�	get_names�s

zVirtualHost.get_namesc
Cspdj|j|jd�dd�|jD��|jdk	r0|jndd�dd�|jD��|jrPdnd|jr\dnd|j	rhdndd	�S)
Nz�File: {filename}
Vhost path: {vhpath}
Addresses: {addrs}
Name: {name}
Aliases: {aliases}
TLS Enabled: {tls}
Site Enabled: {active}
mod_macro Vhost: {modmacro}�, css|]}t|�VqdSr��str��.0rrrr
�	<genexpr>�sz&VirtualHost.__str__.<locals>.<genexpr>�css|]
}|VqdSrr)r=r,rrr
r>�s�Yes�No)�filenameZvhpathr+r,r.ZtlsZactiver1)
�formatr)r*�joinr+r,r.r/r0r1rrrr
�__str__�s��zVirtualHost.__str__cCs:dj|jd�dd�|jD��d�|���|jr2dndd�S)z5Return a representation of VHost to be used in dialogzBFile: {filename}
Addresses: {addrs}
Names: {names}
HTTPS: {https}
r9css|]}t|�VqdSrr:r<rrr
r>�sz+VirtualHost.display_repr.<locals>.<genexpr>r@rA)rBr+�namesZhttps)rCr)rDr+r8r/rrrr
�display_repr�s��zVirtualHost.display_reprcCsht||j�rd|j|jkob|j|jkob|j|jkob|��|��kob|j|jkob|j|jkob|j|jkSdS)NF)	rrr)r*r+r8r/r0r1r	rrr
r�s
��
�
�
�zVirtualHost.__eq__cCs|�|�Srrr	rrr
r�szVirtualHost.__ne__cCs.t|j|jt|j�t|���|j|j|jf�Sr)	�hashr)r*�tupler+r8r/r0r1rrrr
r�s

�zVirtualHost.__hash__cCs,|D]"}|jD]}|�|�rdSqqdS)aESee if vhost conflicts with any of the addrs.

        This determines whether or not these addresses would/could overwrite
        the vhost addresses.

        :param addrs: Iterable Addresses
        :type addrs: Iterable :class:~obj.Addr

        :returns: If addresses conflicts with vhost
        :rtype: bool

        TF)r+r!)r
r+Zpot_addrrrrr
r!�s



zVirtualHost.conflictscCs�|s.|��|��krdS|jdk	s(|jr8dSn
|jr8dSt|j�t|j�krPdSt�}|jD]L}|jD]:}|��|��krf||krf|��|krf|�|���q\qfdSq\dS)aXDetermines if the vhost is the same 'server'.

        Used in redirection - indicates whether or not the two virtual hosts
        serve on the exact same IP combinations, but different ports.
        The generic flag indicates that that we're trying to match to a
        default or generic vhost

        .. todo:: Handle _default_

        FNT)r8r,r.�lenr+r-r r5)r
ZvhostZgenericZ
already_foundrZ
local_addrrrr
�same_server�s*

�
�zVirtualHost.same_server)NNFN)F)r#r$r%r&�re�compiler6r3r8rErGrrrr!rKrrrr
r(es
�


r()	r&rLZacme.magic_typingrZcertbot.pluginsrr�objectr(rrrr
�<module>s
]