+
    Dfj@1                       R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
HtHt ^ RIHt ^ RIHtHt ^ RIHtHtHt ^ R	IHt ]'       d   ^ R
IHt ]! ]P4                  4       ! R R4      4       t ! R R]4      t ! R R]4      t ! R R]P<                  4      t ! R R]4      t ! R R]P@                  4      t! ! R R]PD                  4      t#R# )z
Mail protocol support.
)annotations)TYPE_CHECKINGCallable)implementer)longversion)CramMD5CredentialsUsernamePassword)UnauthorizedLogin)deferprotocol)pop3relaysmtp)log)MailServicec                  `    ] tR t^t$ RtRtRtR]R&   ]P                  3R lt
R tR tR	 tR
tR# )DomainDeliveryBasea.  
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.
Ns   not-implemented-protocolbytesprotocolNamec                *    Wn         W n        W0n        R# )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)selfr   r   r   s   &&&&8/usr/lib/python3/dist-packages/twisted/mail/protocols.py__init__DomainDeliveryBase.__init__*   s     		    c                   R;rEV P                   '       d#   RV P                   P                  R4      ,           pV^ ,          '       d   RV^ ,          ,           pRV^ ,          ,           R,           V^,          ,           R,           V,           V,           pRV P                  ,           R	,           V P                  ,           R
,           \        P                  ! R4      ,           R,           pRRP                  \        \        V4      4      ,           R,           \        P                  ! 4       ,           pRV,           R,           V,           R,           V,           # )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.
r   s    auth=xtexts    helo=s   from s    ([   ]s   by s    with s    (ascii   )s   for <    s   > s
   Received: s   
	)
r   encoder   r   r   joinmapr   r   
rfc822date)	r   heloorigin
recipientsauthStrheloStrfromUserbyforUsers	   &&&&     r   receivedHeader!DomainDeliveryBase.receivedHeader9   s   "  999$))"2"27";;G77$q')Gd1g%.a84?'IGSii   	
   )*  	 tyyUJ!7885@4??CTT 	 x''1B6@7JJr   c                   V P                   '       d}   V P                  P                  '       da   V P                  P                  P	                  VP
                  P                  R4      pVf"   \        P                  ! V P                  R4      pM1V P                  P                  VP
                  P                  ,          p\        P                  ! VP                  V4      # )a  
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)r   r   queuedomainsgetdestdomainr   DomainQueuerr
   maybeDeferredexists)r   r   ds   && r   
validateToDomainDeliveryBase.validateTo^   s    " 999+++$$(()9)94@Ay&&t||T:$$TYY%5%56A""188T22r   c                    V'       g   \         P                  ! VRR4      hVP                  R8w  d*   VP                  R8X  d   \         P                  ! VRR4      hV# )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  zWho are you?  Say HELO first.r   i  z#Sender address must contain domain.)r   SMTPBadSenderlocalr7   )r   r(   r)   s   &&&r   validateFromDomainDeliveryBase.validateFromw   sO    " $$VS2QRR<<36==C#7$$VS2WXXr   )r   r   r   )__name__
__module____qualname____firstlineno____doc__r   r   __annotations__r   DNSNAMEr   r0   r<   rA   __static_attributes__ r   r   r   r      s5    
 G5L%5+/<< #KJ32r   r   c                      ] tR t^tRtRtRtR# )SMTPDomainDeliveryz9
A domain delivery base class for use in an SMTP server.
s   smtprK   NrC   rD   rE   rF   rG   r   rJ   rK   r   r   rM   rM      s     Lr   rM   c                      ] tR t^tRtRtRtR# )ESMTPDomainDeliveryz:
A domain delivery base class for use in an ESMTP server.
s   esmtprK   NrN   rK   r   r   rP   rP      s     Lr   rP   c                  F    ] tR t^tRt]P                  tRtRR lt	R t
RtR# )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}.
Nc                \    \         P                  P                  V 4       Wn        W n        R# )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)r   rR   r   r   portal)r   r   rT   s   &&&r   r   SMTPFactory.__init__   s"     	!!$'r   c                    \         P                  ! RV 24       \        P                  P	                  W4      pV P
                  Vn        V P                  Vn        V# )z
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.
zConnection from )r   msgr   rR   buildProtocolr   rT   r   addrps   && r   rX   SMTPFactory.buildProtocol   sI     	"4&)***46LL	;;r   )rT   r   )N)rC   rD   rE   rF   rG   r   SMTPr   rT   r   rX   rJ   rK   r   r   rR   rR      s!    
 yyHFr   rR   c                  B    ] tR t^tRt]P                  tRtR t	R t
RtR# )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.
Nc                P    \         P                  ! V .VO5!   R\        /V n        R# )zS
@param args: Arguments for L{SMTPFactory.__init__}

@see: L{SMTPFactory.__init__}
s   CRAM-MD5N)rR   r   r   challengers)r   argss   &*r   r   ESMTPFactory.__init__   s%     	T)D)');<r   c                t    \         P                  W4      pV P                  Vn        V P                  Vn        V# )z
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.
)rR   rX   ra   contextctxrY   s   && r   rX   ESMTPFactory.buildProtocol   s1     %%d1((r   )ra   )rC   rD   rE   rF   rG   r   ESMTPr   re   r   rX   rJ   rK   r   r   r_   r_      s!    ( zzHG=r   r_   c                  V    ] tR t^t$ RtRtR]R&   RtR]R&   R tR	 R
 lt	R R lt
RtR# )VirtualPOP3z
A virtual hosting POP3 server.

@ivar service: The email service that created this server.  This must be
    set by the service.

@ivar domainSpecifier: The character to use to split an email address into
    local-part and domain. The default is '@'.
NzMailService | Noner      @r   domainSpecifierc                >   V P                  V4      w  r V P                  P                  V4      pVP                  \        P
                  ! V P                  W4      R\        P                  4      #   \         d"    \        P                  ! \        4       4      u # i ; i)a  
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loginr   APOPCredentialsmagicIMailboxKeyErrorr
   failr	   )r   r   digestr7   rT   s   &&&  r   authenticateUserAPOP VirtualPOP3.authenticateUserAPOP  s    * ((.	\\..v6F <<$$TZZ>dmm   	3::/122	3s   A0 0)BBc               $    V ^8  d   QhRRRRRR/# )   r   r   passwordreturnzMdefer.Deferred[tuple[type[pop3.IMailbox], pop3.IMailbox, Callable[[], None]]]rK   )formats   "r   __annotate__VirtualPOP3.__annotate__.  s$      %*	Vr   c                @   V P                  V4      w  rV P                  f   Q R4       h V P                  P                  V4      pVP                  \	        W4      R\
        P                  4      pV#   \         d"    \        P                  ! \        4       4      u # i ; i)a  
Perform authentication for a username/password login.

Override the default lookup scheme to allow virtual domains.

@param user: The name of the user attempting to log in.

@param password: The password to authenticate with.

@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.
Nz.must have a service to be able to authenticate)rn   r   ro   rp   r   r   rs   rt   r
   ru   r	   )r   r   r{   r7   rT   results   &&&   r   authenticateUserPASS VirtualPOP3.authenticateUserPASS.  s    $ ((.LL$	<;	<$	\\..v6F -d=tT]]S  M  	3::/122	3s   A1 1)BBc                    V ^8  d   QhRRRR/# )rz   r   r   r|   ztuple[bytes, bytes]rK   )r}   s   "r   r~   r   N  s       +> r   c                2    VP                  V P                  ^4      w  rV P                  f   Q R4       hW P                  P                  9  d5   \
        P                  ! RP                  VP                  R4      4      4      hW3#   \         d    Rp Lui ; i)aC  
Check whether a domain part of the given email address is among the
virtual domains supported by the mail service.

@param user: An email address.

@return: a 2-tuple of (local part, domain part) of the email address if
    the domain is supported.

@raise POP3Error: When the domain is not supported by the mail service.
r   z(cannot look up domain if service not setzno such domain {}zutf-8)	splitrl   
ValueErrorr   r4   r   	POP3Errorr}   decode)r   r   r7   s   && r   rn   VirtualPOP3.lookupDomainN  s    	::d&:&:A>LD ||'S)SS'---..!4!;!;FMM'<R!STT|  	F	s   B BBrK   )rC   rD   rE   rF   rG   r   rH   rl   rw   r   rn   rJ   rK   r   r   rj   rj      s3     #'G&!OU!>@ r   rj   c                  .    ] tR tRtRt]tRtR tR t	Rt
R# )POP3Factoryid  a  
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}.
Nc                    Wn         R# )zA
@type service: L{MailService}
@param service: An email service.
Nr   )r   r   s   &&r   r   POP3Factory.__init__s  s	    
 r   c                f    \         P                  P                  W4      pV P                  Vn        V# )z
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   ServerFactoryrX   r   rY   s   && r   rX   POP3Factory.buildProtocolz  s*     ""00<LL	r   r   )rC   rD   rE   rF   rG   rj   r   r   r   rX   rJ   rK   r   r   r   r   d  s    	 HGr   r   N)$rG   
__future__r   typingr   r   zope.interfacer   twisted.copyrightr   twisted.cred.credentialsr   r   twisted.cred.errorr	   twisted.internetr
   r   twisted.mailr   r   r   twisted.pythonr   twisted.mail.mailr   IMessageDeliveryr   rM   rP   rR   r_   POP3rj   r   r   rK   r   r   <module>r      s   
 # * & ) I 0 , * * - T""#r r $rj+ , +$"" +\.; .bc$)) cL"((( "r   