%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/mail/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/mail/__pycache__/tap.cpython-312.pyc

�

Ϫ�f�1���dZddlZddlmZddlmZmZddlmZddl	m
Z
mZmZm
Z
mZddlmZGd�d	ej"ej$�ZGd
�d�Zd�Zy)
z0
Support for creating mail servers with twistd.
�N)�internet)�checkers�strcred)�	endpoints)�alias�mail�maildir�relay�relaymanager)�usagec���eZdZdZdZgd�gd�gZgd�gd�gd�gd�gZd	d
d�Zejdej�i�
�ZdZd�Z
d�Zd�ZeZd�ZeZd�ZeZd�ZeZd�ZeZd�ZeZd�ZeZd�Zd�Zy)�Optionsa�
    An options list parser for twistd mail.

    @type synopsis: L{bytes}
    @ivar synopsis: A description of options for use in the usage message.

    @type optParameters: L{list} of L{list} of (0) L{bytes}, (1) L{bytes},
        (2) L{object}, (3) L{bytes}, (4) L{None} or
        callable which takes L{bytes} and returns L{object}
    @ivar optParameters: Information about supported parameters.  See
        L{Options <twisted.python.usage.Options>} for details.

    @type optFlags: L{list} of L{list} of (0) L{bytes}, (1) L{bytes} or
        L{None}, (2) L{bytes}
    @ivar optFlags: Information about supported flags.  See
        L{Options <twisted.python.usage.Options>} for details.

    @type _protoDefaults: L{dict} mapping L{bytes} to L{int}
    @ivar _protoDefaults: A mapping of default service to port.

    @type compData: L{Completions <usage.Completions>}
    @ivar compData: Metadata for the shell tab completion system.

    @type longdesc: L{bytes}
    @ivar longdesc: A long description of the plugin for use in the usage
        message.

    @type service: L{MailService}
    @ivar service: The email service.

    @type last_domain: L{IDomain} provider or L{None}
    @ivar last_domain: The most recently specified domain.
    z	[options])r
�RNz[Relay messages according to their envelope 'To', using the given path as a queue directory.)�hostname�HNz.The hostname by which to identify this server.)�esmtp�Ez!Use RFC 1425/1869 SMTP extensions)�disable-anonymousNz+Disallow non-authenticated SMTP connections)zno-pop3Nz Disable the default POP3 server.)zno-smtpNz Disable the default SMTP server.i�iY)�pop3�smtpr)�
optActionsa�
    An SMTP / POP3 email server plugin for twistd.

    Examples:

    1. SMTP and POP server

    twistd mail --maildirdbmdomain=example.com=/tmp/example.com
    --user=joe=password

    Starts an SMTP server that only accepts emails to joe@example.com and saves
    them to /tmp/example.com.

    Also starts a POP mail server which will allow a client to log in using
    username: joe@example.com and password: password and collect any email that
    has been saved in /tmp/example.com.

    2. SMTP relay

    twistd mail --relay=/tmp/mail_queue

    Starts an SMTP server that accepts emails to any email address and relays
    them to an appropriate remote SMTP server. Queued emails will be
    temporarily stored in /tmp/mail_queue.
    c��tjj|�tj�|_d|_|jD]}g||<�	y)z:
        Parse options and create a mail service.
        N)rr�__init__r�MailService�service�last_domain�_protoDefaults)�selfrs  �2/usr/lib/python3/dist-packages/twisted/mail/tap.pyrzOptions.__init__ksL��	�
�
���t�$��'�'�)�������*�*�	�G��D��M�	�c�`�ddlm}||jtj||��y)a
        Add an endpoint to a service.

        @type service: L{bytes}
        @param service: A service, either C{b'smtp'} or C{b'pop3'}.

        @type description: L{bytes}
        @param description: An endpoint description string or a TCP port
            number.
        r��reactorN)�twisted.internetr#�appendr�serverFromString)rr�descriptionr#s    r�addEndpointzOptions.addEndpointus&��	-��W�
���Y�7�7���M�Nr c�(�|jd|�y)z�
        Add a POP3 port listener on the specified endpoint.

        You can listen on multiple ports by specifying multiple --pop3 options.
        rN�r(�rr's  r�opt_pop3zOptions.opt_pop3����	
�����-r c�(�|jd|�y)z�
        Add an SMTP port listener on the specified endpoint.

        You can listen on multiple ports by specifying multiple --smtp options.
        rNr*r+s  r�opt_smtpzOptions.opt_smtp�r-r c��|jr'|jjd|j�ytjd��)zM
        Make the most recently specified domain the default domain.
        �z2Specify a domain before specifying using --defaultN)rr�	addDomainr�
UsageError�rs r�opt_defaultzOptions.opt_default�s9������L�L�"�"�2�t�'7�'7�8��"�"�#W�X�Xr c�B�	|jd�\}}t	j
|jtjj|��|_
|jj||j�y#t$rtjd��wxYw)a;
        Generate an SMTP/POP3 virtual domain.

        This option requires an argument of the form 'NAME=PATH' where NAME is
        the DNS domain name for which email will be accepted and where PATH is
        a the filesystem path to a Maildir folder.
        [Example: 'example.com=/tmp/example.com']
        �=z>Argument to --maildirdbmdomain must be of the form 'name=path'N)�split�
ValueErrorrr3r	�MaildirDirdbmDomainr�os�path�abspathrr2)r�domain�namer<s    r�opt_maildirdbmdomainzOptions.opt_maildirdbmdomain�s���	����c�*�J�D�$�#�6�6��L�L�"�'�'�/�/�$�/�
���	
�����t�T�%5�%5�6���	��"�"�P��
�	�s�A?�?Bc���	|jdd�\}}|jr|jj||�ytjd��#t$rtjd��wxYw)zG
        Add a user and password to the last specified domain.
        r7�z6Argument to --user must be of the form 'user=password'z(Specify a domain before specifying usersN)r8r9rr3r�addUser)r�	user_pass�user�passwords    r�opt_userzOptions.opt_user�su��	�&�_�_�S�!�4�N�D�(�
������$�$�T�8�4��"�"�#M�N�N���	��"�"�H��
�	�s�A�A4c�&�d|j_y)z@
        Send undeliverable messages to the postmaster.
        rBN)r�
postmasterr4s r�opt_bounce_to_postmasterz Options.opt_bounce_to_postmaster�s��'(����#r c�*�|j��tjj|j�r�t	j
|jj|�}|jj|�|jjj|t|jj|j��ytj|jjj�d���tjd��)zR
        Specify an aliases(5) file to use for the last specified domain.
        Nz does not support alias filesz*Specify a domain before specifying aliases)rr�IAliasableDomain�
providedByr�
loadAliasFiler�domains�
setAliasGroup�monitor�monitorFile�AliasUpdaterrr3�	__class__�__name__)r�filename�aliasess   r�opt_aliaseszOptions.opt_aliases�s������'��$�$�/�/��0@�0@�A��-�-�d�l�l�.B�.B�H�M��� � �.�.�w�7����$�$�0�0��l�4�<�<�+?�+?��AQ�AQ�R���&�&��'�'�1�1�:�:�=���
�"�"�#O�P�Pr c�r�||r||S|d|zrgStj||j|�gS)a�
        Return a list of endpoints for the specified service, constructing
        defaults if necessary.

        If no endpoints were configured for the service and the protocol
        was not explicitly disabled with a I{--no-*} option, a default
        endpoint for the service is created.

        @type reactor: L{IReactorTCP <twisted.internet.interfaces.IReactorTCP>}
            provider
        @param reactor: If any endpoints are created, the reactor with
            which they are created.

        @type service: L{bytes}
        @param service: The type of service for which to retrieve endpoints,
            either C{b'pop3'} or C{b'smtp'}.

        @rtype: L{list} of L{IStreamServerEndpoint
            <twisted.internet.interfaces.IStreamServerEndpoint>} provider
        @return: The endpoints for the specified service as configured by the
            command line parameters.
        zno-)r�TCP4ServerEndpointr)rr#rs   r�
_getEndpointszOptions._getEndpoints�sK��.��=���=� �
�%�'�/�
"��I��0�0��$�:M�:M�g�:V�W�X�Xr c��ddlm}|dr|d�tjd��d|vr/|dD]'}|jj
j
|��)|ds7|jj
j
tj��d	}|jD]}|j||�||<||s�d
}�!|stjd��y)z�
        Check the validity of the specified set of options and
        configure authentication.

        @raise UsageError: When the set of options is invalid.
        rr"rrNz--esmtp requires --hostname�credCheckersrFTz You cannot disable all protocols)r$r#rr3r�
smtpPortal�registerCheckerr�AllowAnonymousAccessrr[)rr#�ch�anythingrs     r�postOptionszOptions.postOptions
s���	-���=�T�*�-�5��"�"�#@�A�A��T�!��>�*�
<�����'�'�7�7��;�
<��'�(��L�L�#�#�3�3�H�4Q�4Q�4S�T����*�*�	 �G� �.�.�w��@�D��M��G�}���	 �
��"�"�#E�F�F�r N)rU�
__module__�__qualname__�__doc__�synopsis�
optParameters�optFlagsrr�Completions�CompleteHostnames�compData�longdescrr(r,�opt_pr/�opt_sr5�opt_Dr@�opt_drG�opt_urJ�opt_brX�opt_Ar[rc�r rrrs��� �D�H�	
�	R�	�M�	<�R�=�=�	�H����N�
!�u� � �Z�9P��9P�9P�9R�,S�T�H��H�4�
O�.�
�E�.�
�E�Y�
�E�7�*
!�E�
O�
�E�(�
%�E�Q�&
�E� Y�DGr rc��eZdZdZd�Zd�Zy)rSz�
    A callable object which updates the aliases for a domain from an aliases(5)
    file.

    @ivar domains: See L{__init__}.
    @ivar domain: See L{__init__}.
    c� �||_||_y)z�
        @type domains: L{dict} mapping L{bytes} to L{IDomain} provider
        @param domains: A mapping of domain name to domain object

        @type domain: L{IAliasableDomain} provider
        @param domain: The domain to update.
        N)rOr>)rrOr>s   rrzAliasUpdater.__init__2s�������r c�v�|jjtj|j|��y)z�
        Update the aliases for a domain from an aliases(5) file.

        @type new: L{bytes}
        @param new: The name of an aliases(5) file.
        N)r>rPrrNrO)r�news  r�__call__zAliasUpdater.__call__=s'��	
���!�!�%�"5�"5�d�l�l�C�"H�Ir N)rUrdrerfrrzrur rrSrS)s���	�Jr rSc���|dr'tj}|jj}n&tj}|jj
}|d�r+|d}tjj|�st
j|�|jjtj|��tj|j�}||jj�}|dr|xjdz
c_|xj|dfz
c_tj |d�}|j#|j�|jj$j'|�|drU|jj)�}|dD]3}t+j,||�}	|	j#|j��5|dr||�}|dr|d|_|j.f|_|drd|jz|_|dD]3}t+j,||�}	|	j#|j��5|jS)a�
    Configure a service for operating a mail server.

    The returned service may include POP3 servers, SMTP servers, or both,
    depending on the configuration passed in.  If there are multiple servers,
    they will share all of their non-network state (i.e. the same user accounts
    are available on all of them).

    @type config: L{Options <usage.Options>}
    @param config: Configuration options specifying which servers to include in
        the returned service and where they should keep mail data.

    @rtype: L{IService <twisted.application.service.IService>} provider
    @return: A service which contains the requested mail servers.
    rr
)NNrrBrr)r�SmartHostESMTPRelayingManagerr�getESMTPFactory�SmartHostSMTPRelayingManager�getSMTPFactoryr;r<�isdir�mkdir�setQueue�Queuer
�DomainQueuer�queue�fArgs�RelayStateHelper�setServiceParentrO�setDefaultDomain�getPOP3Factoryr�StreamServerEndpointServicer>)
�config�rmType�smtpFactory�dir�default�manager�helper�f�endpoint�svcs
          r�makeServicer�Gs��� �g���;�;���n�n�4�4���:�:���n�n�3�3��
�g���W�o���w�w�}�}�S�!��H�H�S�M������� 2� 2�3� 7�8��$�$�V�^�^�4������-�-�.���'�?��M�M�\�)�M��
�
�&��,�.�.�
��.�.�w��:��������/������/�/��8�
�f�~��N�N�)�)�+���v��	1�H��6�6�x��C�C�� � ����0�	1��f�~��M���*���j�)�A�H��x�x�k�A�G��'�?�"�Q�W�W�,�A�G��v��	1�H��6�6�x��C�C�� � ����0�	1��>�>�r )rfr;�twisted.applicationr�twisted.credrrr$r�twisted.mailrrr	r
r�twisted.pythonrr�AuthOptionMixinrSr�rur r�<module>r�sO���
�(�*�&�B�B� �SG�e�m�m�W�4�4�SG�lJ�J�<9r 

Zerion Mini Shell 1.0