Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/mail/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/mail/__pycache__/protocols.cpython-310.pyc
o

�b&0�@s�dZddlmZddlmZddlmZmZddlm	Z	ddl
mZmZddl
mZmZmZddlmZeej�Gd	d
�d
��ZGdd�de�ZGd
d�de�ZGdd�dej�ZGdd�de�ZGdd�dej�ZGdd�dej�ZdS)z
Mail protocol support.
�)�implementer)�longversion)�CramMD5Credentials�UsernamePassword)�UnauthorizedLogin)�defer�protocol)�pop3�relay�smtp)�logc@sHeZdZUdZdZdZeed<ej	fdd�Z
dd�Zd	d
�Zdd�Z
dS)
�DomainDeliveryBaseaN
    A base class for message delivery using the domains of a mail service.

    @ivar service: See L{__init__}
    @ivar user: See L{__init__}
    @ivar host: See L{__init__}

    @type protocolName: L{bytes}
    @ivar protocolName: The protocol being used to deliver the mail.
        Sub-classes should set this appropriately.
    Nsnot-implemented-protocol�protocolNamecCs||_||_||_dS)z�
        @type service: L{MailService}
        @param service: A mail service.

        @type user: L{bytes} or L{None}
        @param user: The authenticated SMTP user.

        @type host: L{bytes}
        @param host: The hostname.
        N)�service�user�host)�selfrrr�r�8/usr/lib/python3/dist-packages/twisted/mail/protocols.py�__init__%s
zDomainDeliveryBase.__init__c	Cs�d}}|jrd|j�d�}|drd|d}d|dd|dd	||}d
|jd|jdt�d
�d}dd�tt|��dt�	�}d|d|d|S)a�
        Generate a received header string for a message.

        @type helo: 2-L{tuple} of (L{bytes}, L{bytes})
        @param helo: The client's identity as sent in the HELO command and its
            IP address.

        @type origin: L{Address}
        @param origin: The origination address of the message.

        @type recipients: L{list} of L{User}
        @param recipients: The destination addresses for the message.

        @rtype: L{bytes}
        @return: A received header string.
        �s auth=�xtextrs helo=sfrom s ([��]sby s with s (�ascii�)sfor <� s> s
Received: s
	)
r�encoderrr�join�map�bytesr�
rfc822date)	r�helo�origin�
recipients�authStr�heloStr�fromUser�by�forUserrrr�receivedHeader4s.$�������
�z!DomainDeliveryBase.receivedHeadercCsX|jr|jjr|jj�|jjd�}|durt�|jd�}n|jj|jj}t	�
|j|�S)a9
        Validate the address for which a message is destined.

        @type user: L{User}
        @param user: The destination address.

        @rtype: L{Deferred <defer.Deferred>} which successfully fires with
            no-argument callable which returns L{IMessage <smtp.IMessage>}
            provider.
        @return: A deferred which successfully fires with a no-argument
            callable which returns a message receiver for the destination.

        @raise SMTPBadRcpt: When messages cannot be accepted for the
            destination address.
        NT)rr�queue�domains�get�dest�domainr
�DomainQueuerr�
maybeDeferred�exists)rr�drrr�
validateToYs�zDomainDeliveryBase.validateTocCs8|s	t�|dd��|jdkr|jdkrt�|dd��|S)a�
        Validate the address from which a message originates.

        @type helo: 2-L{tuple} of (L{bytes}, L{bytes})
        @param helo: The client's identity as sent in the HELO command and its
            IP address.

        @type origin: L{Address}
        @param origin: The origination address of the message.

        @rtype: L{Address}
        @return: The origination address.

        @raise SMTPBadSender: When messages cannot be accepted from the
            origination address.
        i�zWho are you?  Say HELO first.ri�z#Sender address must contain domain.)r�
SMTPBadSender�localr/)rr"r#rrr�validateFromrs
zDomainDeliveryBase.validateFrom)�__name__�
__module__�__qualname__�__doc__rrr �__annotations__r�DNSNAMErr*r4r7rrrrr
s
%r
c@�eZdZdZdZdS)�SMTPDomainDeliveryzA
    A domain delivery base class for use in an SMTP server.
    ssmtpN�r8r9r:r;rrrrrr?��r?c@r>)�ESMTPDomainDeliveryzB
    A domain delivery base class for use in an ESMTP server.
    sesmtpNr@rrrrrB�rArBc@s,eZdZdZejZdZddd�Zdd�Z	dS)�SMTPFactorya;
    An SMTP server protocol factory.

    @ivar service: See L{__init__}
    @ivar portal: See L{__init__}

    @type protocol: no-argument callable which returns a L{Protocol
        <protocol.Protocol>} subclass
    @ivar protocol: A callable which creates a protocol.  The default value is
        L{SMTP}.
    NcCstj�|�||_||_dS)z�
        @type service: L{MailService}
        @param service: An email service.

        @type portal: L{Portal <twisted.cred.portal.Portal>} or
            L{None}
        @param portal: A portal to use for authentication.
        N)rrCrr�portal)rrrDrrrr�s	
zSMTPFactory.__init__cCs2t�d|���tj�||�}|j|_|j|_|S)a
        Create an instance of an SMTP server protocol.

        @type addr: L{IAddress <twisted.internet.interfaces.IAddress>} provider
        @param addr: The address of the SMTP client.

        @rtype: L{SMTP}
        @return: An SMTP protocol.
        zConnection from )r�msgrrC�
buildProtocolrrD�r�addr�prrrrF�s

zSMTPFactory.buildProtocol)N)
r8r9r:r;r�SMTPrrDrrFrrrrrC�s

rCc@s*eZdZdZejZdZdd�Zdd�Z	dS)�ESMTPFactorya
    An ESMTP server protocol factory.

    @type protocol: no-argument callable which returns a L{Protocol
        <protocol.Protocol>} subclass
    @ivar protocol: A callable which creates a protocol.  The default value is
        L{ESMTP}.

    @type context: L{IOpenSSLContextFactory
        <twisted.internet.interfaces.IOpenSSLContextFactory>} or L{None}
    @ivar context: A factory to generate contexts to be used in negotiating
        encrypted communication.

    @type challengers: L{dict} mapping L{bytes} to no-argument callable which
        returns L{ICredentials <twisted.cred.credentials.ICredentials>}
        subclass provider.
    @ivar challengers: A mapping of acceptable authorization mechanism to
        callable which creates credentials to use for authentication.
    NcGs tj|g|�R�dti|_dS)zk
        @param args: Arguments for L{SMTPFactory.__init__}

        @see: L{SMTPFactory.__init__}
        sCRAM-MD5N)rCrr�challengers)r�argsrrrr�szESMTPFactory.__init__cCs t�||�}|j|_|j|_|S)a
        Create an instance of an ESMTP server protocol.

        @type addr: L{IAddress <twisted.internet.interfaces.IAddress>} provider
        @param addr: The address of the ESMTP client.

        @rtype: L{ESMTP}
        @return: An ESMTP protocol.
        )rCrFrL�context�ctxrGrrrrF�s
zESMTPFactory.buildProtocol)
r8r9r:r;r�ESMTPrrNrrFrrrrrK�s	rKc@s0eZdZdZdZdZdd�Zdd�Zdd	�ZdS)
�VirtualPOP3a[
    A virtual hosting POP3 server.

    @type service: L{MailService}
    @ivar service: The email service that created this server.  This must be
        set by the service.

    @type domainSpecifier: L{bytes}
    @ivar domainSpecifier: The character to use to split an email address into
        local-part and domain. The default is '@'.
    N�@cCsZ|�|�\}}z|j�|�}Wntyt�t��YSw|�t�	|j
||�dtj�S)a1
        Perform APOP authentication.

        Override the default lookup scheme to allow virtual domains.

        @type user: L{bytes}
        @param user: The name of the user attempting to log in.

        @type digest: L{bytes}
        @param digest: The challenge response.

        @rtype: L{Deferred} which successfully results in 3-L{tuple} of
            (L{IMailbox <pop3.IMailbox>}, L{IMailbox <pop3.IMailbox>}
            provider, no-argument callable)
        @return: A deferred which fires when authentication is complete.
            If successful, it returns an L{IMailbox <pop3.IMailbox>} interface,
            a mailbox and a logout function. If authentication fails, the
            deferred fails with an L{UnauthorizedLogin
            <twisted.cred.error.UnauthorizedLogin>} error.
        N)�lookupDomainr�lookupPortal�KeyErrorr�failr�loginr	�APOPCredentials�magic�IMailbox)rr�digestr/rDrrr�authenticateUserAPOPs��z VirtualPOP3.authenticateUserAPOPcCsT|�|�\}}z|j�|�}Wntyt�t��YSw|�t||�dt	j
�S)aY
        Perform authentication for a username/password login.

        Override the default lookup scheme to allow virtual domains.

        @type user: L{bytes}
        @param user: The name of the user attempting to log in.

        @type password: L{bytes}
        @param password: The password to authenticate with.

        @rtype: L{Deferred} which successfully results in 3-L{tuple} of
            (L{IMailbox <pop3.IMailbox>}, L{IMailbox <pop3.IMailbox>}
            provider, no-argument callable)
        @return: A deferred which fires when authentication is complete.
            If successful, it returns an L{IMailbox <pop3.IMailbox>} interface,
            a mailbox and a logout function. If authentication fails, the
            deferred fails with an L{UnauthorizedLogin
            <twisted.cred.error.UnauthorizedLogin>} error.
        N)rSrrTrUrrVrrWrr	rZ)rr�passwordr/rDrrr�authenticateUserPASS+s�z VirtualPOP3.authenticateUserPASScCsXz|�|jd�\}}Wntyd}Ynw||jjvr(t�d�|�d����||fS)a�
        Check whether a domain is among the virtual domains supported by the
        mail service.

        @type user: L{bytes}
        @param user: An email address.

        @rtype: 2-L{tuple} of (L{bytes}, L{bytes})
        @return: The local part and the domain part of the email address if the
            domain is supported.

        @raise POP3Error: When the domain is not supported by the mail service.
        rrzno such domain {}zutf-8)	�split�domainSpecifier�
ValueErrorrr,r	�	POP3Error�format�decode)rrr/rrrrSHs�zVirtualPOP3.lookupDomain)	r8r9r:r;rr`r\r^rSrrrrrQ�srQc@s(eZdZdZeZdZdd�Zdd�ZdS)�POP3Factorya
    A POP3 server protocol factory.

    @ivar service: See L{__init__}

    @type protocol: no-argument callable which returns a L{Protocol
        <protocol.Protocol>} subclass
    @ivar protocol: A callable which creates a protocol.  The default value is
        L{VirtualPOP3}.
    NcCs
||_dS)zY
        @type service: L{MailService}
        @param service: An email service.
        N)r)rrrrrrns
zPOP3Factory.__init__cCstj�||�}|j|_|S)a
        Create an instance of a POP3 server protocol.

        @type addr: L{IAddress <twisted.internet.interfaces.IAddress>} provider
        @param addr: The address of the POP3 client.

        @rtype: L{POP3}
        @return: A POP3 protocol.
        )r�
ServerFactoryrFrrGrrrrFus
zPOP3Factory.buildProtocol)	r8r9r:r;rQrrrrFrrrrre_sreN)r;�zope.interfacer�twisted.copyrightr�twisted.cred.credentialsrr�twisted.cred.errorr�twisted.internetrr�twisted.mailr	r
r�twisted.pythonr�IMessageDeliveryr
r?rBrCrK�POP3rQrfrerrrr�<module>s u.1f

Spamworldpro Mini