Current File : //proc/self/root/lib/python3/dist-packages/twisted/mail/__pycache__/relaymanager.cpython-312.pyc
�

Ϫ�ff�����dZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZddlmZdd	lmZmZmZdd
lmZddlmZGd�d
�ZGd�deej8�ZGd�deej<�ZGd�dej@�Z!Gd�de!�Z"Gd�d�Z#Gd�d�Z$Gd�d�Z%Gd�de%�Z&d�Z'd�Z(Gd �d!e)�Z*Gd"�d#e)�Z+Gd$�d%�Z,y)&aI
Infrastructure for relaying mail through a smart host.

Traditional peer-to-peer email has been increasingly replaced by smart host
configurations.  Instead of sending mail directly to the recipient, a sender
sends mail to a smart host.  The smart host finds the mail exchange server for
the recipient and sends on the message.
�N)�Type)�internet)�protocol)�Deferred�DeferredList)�DNSLookupError)�connectionDone)�bounce�relay�smtp)�log)�Failurec�d�eZdZdZd�Zed��Zejd��Zd�Ze	fde
ddfd	�Zy)
�ManagedRelayerMixinz�
    SMTP Relayer which notifies a manager

    Notify the manager about successful mail, failed mail
    and broken connections
    c��||_y�N��manager)�selfrs  �;/usr/lib/python3/dist-packages/twisted/mail/relaymanager.py�__init__zManagedRelayerMixin.__init__&s	�����c��|jSr��_factory�rs r�factoryzManagedRelayerMixin.factory)s���}�}�rc��||_yrr)r�values  rrzManagedRelayerMixin.factory-s	����
rc��|jd}|tjvr'|jj	|j
|�n&|jj
|j
|�|jd=|jd=y)z`
        called when e-mail has been sent

        we will always get 0 or 1 addresses.
        rN)�namesr�SUCCESSr�
notifySuccessr�
notifyFailure�messages)r�code�resp�numOk�	addressesr
�messages       r�sentMailzManagedRelayerMixin.sentMail1sd���*�*�Q�-���4�<�<���L�L�&�&�t�|�|�W�=��L�L�&�&�t�|�|�W�=��M�M�!���J�J�q�Mr�reason�returnNc�N�|jj|j�y)zm
        called when connection is broken

        notify manager we will try to send no more e-mail
        N)r�
notifyDoner)rr,s  r�connectionLostz"ManagedRelayerMixin.connectionLost?s��	
��������-r)�__name__�
__module__�__qualname__�__doc__r�propertyr�setterr+r	rr0�rrrrsU��������
�^�^�����0>�.�W�.�$�.rrc��eZdZdZd�Zy)�SMTPManagedRelayeraV
    An SMTP managed relayer.

    This managed relayer is an SMTP client which is responsible for sending a
    set of messages and keeping an attempt manager informed about its progress.

    @type factory: L{SMTPManagedRelayerFactory}
    @ivar factory: The factory that created this relayer.  This must be set by
        the factory.
    c�x�tj||�tjj||g|��i|��y)a�
        @type messages: L{list} of L{bytes}
        @param messages: The base filenames of messages to be relayed.

        @type manager: L{_AttemptManager}
        @param manager: An attempt manager.

        @type args: 1-L{tuple} of (0) L{bytes} or 2-L{tuple} of
            (0) L{bytes}, (1) L{int}
        @param args: Positional arguments for L{SMTPClient.__init__}

        @type kw: L{dict}
        @param kw: Keyword arguments for L{SMTPClient.__init__}
        N)rrr�SMTPRelayer�rr%r�args�kws     rrzSMTPManagedRelayer.__init__Ts4��	�$�$�T�7�3�
���"�"�4��?�D�?�B�?rN�r1r2r3r4rr7rrr9r9Hs
��	�@rr9c��eZdZdZd�Zy)�ESMTPManagedRelayerz�
    An ESMTP managed relayer.

    This managed relayer is an ESMTP client which is responsible for sending a
    set of messages and keeping an attempt manager informed about its progress.
    c�x�tj||�tjj||g|��i|��y)a�
        @type messages: L{list} of L{bytes}
        @param messages: The base filenames of messages to be relayed.

        @type manager: L{_AttemptManager}
        @param manager: An attempt manager.

        @type args: 3-L{tuple} of (0) L{bytes}, (1) L{None} or
            L{ClientContextFactory
            <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes} or
            4-L{tuple} of (0) L{bytes}, (1) L{None} or
            L{ClientContextFactory
            <twisted.internet.ssl.ClientContextFactory>}, (2) L{bytes},
            (3) L{int}
        @param args: Positional arguments for L{ESMTPClient.__init__}

        @type kw: L{dict}
        @param kw: Keyword arguments for L{ESMTPClient.__init__}
        N)rrr�ESMTPRelayerr<s     rrzESMTPManagedRelayer.__init__os4��(	�$�$�T�7�3�
���#�#�D�(�@�T�@�R�@rNr?r7rrrArAgs
���ArrAc�2�eZdZUdZeZded<d�Zd�Zd�Z	y)�SMTPManagedRelayerFactorya�
    A factory to create an L{SMTPManagedRelayer}.

    This factory creates a managed relayer which relays a set of messages over
    SMTP and informs an attempt manager of its progress.

    @ivar messages: See L{__init__}
    @ivar manager: See L{__init__}

    @type protocol: callable which returns L{SMTPManagedRelayer}
    @ivar protocol: A callable which returns a managed relayer for SMTP.  See
        L{SMTPManagedRelayer.__init__} for parameters to the callable.

    @type pArgs: 1-L{tuple} of (0) L{bytes} or 2-L{tuple} of
        (0) L{bytes}, (1), L{int}
    @ivar pArgs: Positional arguments for L{SMTPClient.__init__}

    @type pKwArgs: L{dict}
    @ivar pKwArgs: Keyword arguments for L{SMTPClient.__init__}
    zType[protocol.Protocol]rc�<�||_||_||_||_y)a�
        @type messages: L{list} of L{bytes}
        @param messages: The base filenames of messages to be relayed.

        @type manager: L{_AttemptManager}
        @param manager: An attempt manager.

        @type args: 1-L{tuple} of (0) L{bytes} or 2-L{tuple} of
            (0) L{bytes}, (1), L{int}
        @param args: Positional arguments for L{SMTPClient.__init__}

        @type kw: L{dict}
        @param kw: Keyword arguments for L{SMTPClient.__init__}
        N)r%r�pArgs�pKwArgsr<s     rrz"SMTPManagedRelayerFactory.__init__�s ��!��
������
���rc��|j|j|jg|j��i|j��}||_|S)a
        Create an L{SMTPManagedRelayer}.

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

        @rtype: L{SMTPManagedRelayer}
        @return: A managed relayer for SMTP.
        )rr%rrGrHr)r�addrrs   r�
buildProtocolz'SMTPManagedRelayerFactory.buildProtocol�sH��!�4�=�=��M�M�4�<�<�
�*.�*�*�
�8<���
�� ����rc�p�|jj|�|jj|�y)aH
        Notify the attempt manager that a connection could not be established.

        @type connector: L{IConnector <twisted.internet.interfaces.IConnector>}
            provider
        @param connector: A connector.

        @type reason: L{Failure}
        @param reason: The reason the connection attempt failed.
        N)r�notifyNoConnectionr/)r�	connectorr,s   r�clientConnectionFailedz0SMTPManagedRelayerFactory.clientConnectionFailed�s(��	
���'�'��-�������%rN)
r1r2r3r4r9r�__annotations__rrKrOr7rrrErE�s#���*+=�H�'�<��(� &rrEc� �eZdZdZeZd�Zd�Zy)�ESMTPManagedRelayerFactorya�
    A factory to create an L{ESMTPManagedRelayer}.

    This factory creates a managed relayer which relays a set of messages over
    ESMTP and informs an attempt manager of its progress.

    @type protocol: callable which returns L{ESMTPManagedRelayer}
    @ivar protocol: A callable which returns a managed relayer for ESMTP.  See
        L{ESMTPManagedRelayer.__init__} for parameters to the callable.

    @ivar secret: See L{__init__}
    @ivar contextFactory: See L{__init__}
    c�V�||_||_tj|||g|��i|��y)a�
        @type messages: L{list} of L{bytes}
        @param messages: The base filenames of messages to be relayed.

        @type manager: L{_AttemptManager}
        @param manager: An attempt manager.

        @type secret: L{bytes}
        @param secret: A string for the authentication challenge response.

        @type contextFactory: L{None} or
            L{ClientContextFactory <twisted.internet.ssl.ClientContextFactory>}
        @param contextFactory: An SSL context factory.

        @type args: 1-L{tuple} of (0) L{bytes} or 2-L{tuple} of
            (0) L{bytes}, (1), L{int}
        @param args: Positional arguments for L{SMTPClient.__init__}

        @param kw: Keyword arguments for L{SMTPClient.__init__}
        N)�secret�contextFactoryrEr)rr%rrTrUr=r>s       rrz#ESMTPManagedRelayerFactory.__init__�s/��*���,���!�*�*�4��7�P�T�P�R�Prc���|jxr|j|�}|j|j|j||jg|j
��i|j��}||_|S)a
        Create an L{ESMTPManagedRelayer}.

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

        @rtype: L{ESMTPManagedRelayer}
        @return: A managed relayer for ESMTP.
        )rTrr%rrUrGrHr)rrJ�srs    rrKz(ESMTPManagedRelayerFactory.buildProtocol�sp��
�K�K�-�D�K�K��-�� �4�=�=��M�M��L�L�
����	
�
�Z�Z�
��l�l�

�� ����rN)r1r2r3r4rArrrKr7rrrRrR�s���#�H�Q�2rrRc�t�eZdZdZdZd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zy)�Queuea.
    A queue for messages to be relayed.

    @ivar directory: See L{__init__}

    @type n: L{int}
    @ivar n: A number used to form unique filenames.

    @type waiting: L{dict} of L{bytes}
    @ivar waiting: The base filenames of messages waiting to be relayed.

    @type relayed: L{dict} of L{bytes}
    @ivar relayed: The base filenames of messages in the process of being
        relayed.

    @type noisy: L{bool}
    @ivar noisy: A flag which determines whether informational log messages
        will be generated (C{True}) or not (C{False}).
    Tc�2�||_|j�y)z�
        Initialize non-volatile state.

        @type directory: L{bytes}
        @param directory: The pathname of the directory holding messages in the
            queue.
        N)�	directory�_init)rr[s  rrzQueue.__init__*s��#����
�
�rc�N�d|_i|_i|_|j�y)z,
        Initialize volatile state.
        rN)�n�waiting�relayed�
readDirectoryrs rr\zQueue._init5s%��������������rc��d|jiS)z�
        Create a representation of the non-volatile state of the queue.

        @rtype: L{dict} mapping L{bytes} to L{object}
        @return: The non-volatile state of the queue.
        r[)r[rs r�__getstate__zQueue.__getstate__>s���T�^�^�,�,rc�Z�|jj|�|j�y)z�
        Restore the non-volatile state of the queue and recreate the volatile
        state.

        @type state: L{dict} mapping L{bytes} to L{object}
        @param state: The non-volatile state of the queue.
        N)�__dict__�updater\�r�states  r�__setstate__zQueue.__setstate__Gs��	
�
�
���U�#��
�
�rc��tj|j�D]}|dddk7r�|j|dd��!y)z>
        Scan the message directory for new messages.
        ���N�-D)�os�listdirr[�
addMessage�rr*s  rrazQueue.readDirectoryRsC���z�z�$�.�.�1�	*�G��r�s�|�t�#���O�O�G�C�R�L�)�		*rc�6�|jj�S)z�
        Return the base filenames of messages waiting to be relayed.

        @rtype: L{list} of L{bytes}
        @return: The base filenames of messages waiting to be relayed.
        )r_�keysrs r�
getWaitingzQueue.getWaiting\s���|�|� � �"�"rc�2�t|j�dkDS)z�
        Return an indication of whether the queue has messages waiting to be
        relayed.

        @rtype: L{bool}
        @return: C{True} if messages are waiting to be relayed.  C{False}
            otherwise.
        r)�lenr_rs r�
hasWaitingzQueue.hasWaitinges���4�<�<� �1�$�$rc�6�|jj�S)z�
        Return the base filenames of messages in the process of being relayed.

        @rtype: L{list} of L{bytes}
        @return: The base filenames of messages in the process of being
            relayed.
        )r`rrrs r�
getRelayedzQueue.getRelayedps���|�|� � �"�"rc�<�|j|=d|j|<y)z�
        Mark a message as being relayed.

        @type message: L{bytes}
        @param message: The base filename of a message.
        �N)r_r`rps  r�setRelayingzQueue.setRelayingz���
�L�L��!� !����W�rc�<�|j|=d|j|<y)z�
        Mark a message as waiting to be relayed.

        @type message: L{bytes}
        @param message: The base filename of a message.
        rzN)r`r_rps  r�
setWaitingzQueue.setWaiting�r|rc��||jvr8d|j|<|jrtjd|zdz�yyy)z�
        Mark a message as waiting to be relayed unless it is in the process of
        being relayed.

        @type message: L{bytes}
        @param message: The base filename of a message.
        rzzSet � waitingN)r`r_�noisyr
�msgrps  rrozQueue.addMessage�sE���$�,�,�&�$%�D�L�L��!��z�z������(�:�5�6��'rc��tjj|�}tj|j	|�dz�tj|j	|�dz�|j
|=y)z�
        Remove a message from the queue.

        @type message: L{bytes}
        @param message: The base filename of a message.
        rl�-HN)rm�path�basename�remove�getPathr`rps  r�donez
Queue.done�sX���'�'�"�"�7�+��
�	�	�$�,�,�w�'�$�.�/�
�	�	�$�,�,�w�'�$�.�/��L�L��!rc�V�tjj|j|�S)z�
        Return the full base pathname of a message in the queue.

        @type message: L{bytes}
        @param message: The base filename of a message.

        @rtype: L{bytes}
        @return: The full base pathname of the message.
        )rmr��joinr[rps  rr�z
Queue.getPath�s���w�w�|�|�D�N�N�G�4�4rc�z�|j|�5}tj|�cddd�S#1swYyxYw)a
        Get the envelope for a message.

        @type message: L{bytes}
        @param message: The base filename of a message.

        @rtype: L{list} of two L{bytes}
        @return: A list containing the origination and destination addresses
            for the message.
        N)�getEnvelopeFile�pickle�load)rr*�fs   r�getEnvelopezQueue.getEnvelope�s4���
!�
!�'�
*�	"�a��;�;�q�>�	"�	"�	"�s�1�:c�p�ttjj|j|dz�d�S)z�
        Return the envelope file for a message in the queue.

        @type message: L{bytes}
        @param message: The base filename of a message.

        @rtype: file
        @return: The envelope file for the message.
        r��rb)�openrmr�r�r[rps  rr�zQueue.getEnvelopeFile�s(���B�G�G�L�L�����4��@�$�G�Grc	��tj��dtj��d|j�dt	|���}|jdz|_ttjj|j|dz�d�}tjj|j|dz�}tjj|j|dz�}t|d�}ddl	m
}|||||�fS)	z�
        Create a new message in the queue.

        @rtype: 2-L{tuple} of (0) file, (1) L{FileMessage}
        @return: The envelope file and a message receiver for a new message in
            the queue.
        �_rzr��wbz-Crlr)�FileMessage)rm�getpid�timer^�idr�r�r�r[�twisted.mail.mailr�)r�fname�
headerFile�tempFilename�
finalFilename�messageFiler�s       r�createNewMessagezQueue.createNewMessage�s����9�9�;�-�q�����
�Q�t�v�v�h�a��4��z�B�����!�����"�'�'�,�,�t�~�~�u�t�|�D�d�K�
��w�w�|�|�D�N�N�E�D�L�A�������T�^�^�U�T�\�B�
��<��.��1��;�{�L�-�P�P�PrN)r1r2r3r4r�rr\rcrirarsrvrxr{r~ror�r�r�r�r�r7rrrYrYs`���(
�E�	��-�	�*�#�	%�#�"�"�7�
"�
5�"�
H�QrrYc�<�eZdZdZd
d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
y)�_AttemptManagera*
    A manager for an attempt to relay a set of messages to a mail exchange
    server.

    @ivar manager: See L{__init__}

    @type _completionDeferreds: L{list} of L{Deferred}
    @ivar _completionDeferreds: Deferreds which are to be notified when the
        attempt to relay is finished.
    Nc�L�||_g|_||_|sddlm}||_y)a�
        @type manager: L{SmartHostSMTPRelayingManager}
        @param manager: A smart host.

        @type noisy: L{bool}
        @param noisy: A flag which determines whether informational log
            messages will be generated (L{True}) or not (L{False}).

        @type reactor: L{IReactorTime
            <twisted.internet.interfaces.IReactorTime>} provider
        @param reactor: A reactor which will be used to schedule delayed calls.
        r��reactorN)r�_completionDeferredsr��twisted.internetr�)rrr�r�s    rrz_AttemptManager.__init__�s'�����$&��!���
��0���rc�f�|jjt��|jdS)z�
        Return a deferred which will fire when the attempt to relay is
        finished.

        @rtype: L{Deferred}
        @return: A deferred which will fire when the attempt to relay is
            finished.
        ���)r��appendrrs r�getCompletionDeferredz%_AttemptManager.getCompletionDeferreds+��	
�!�!�(�(���4��(�(��,�,rc���|jj|jtjj|��|jjj|�y)aY
        Remove a message from the relay queue and from the smart host's list of
        messages being relayed.

        @type relay: L{SMTPManagedRelayerFactory}
        @param relay: The factory for the relayer which sent the message.

        @type message: L{bytes}
        @param message: The path of the file holding the message.
        N)r�managedr�rmr�r��queuer��rrr*s   r�_finishz_AttemptManager._finishsH��	
�����U�#�*�*�2�7�7�+;�+;�G�+D�E���������(rc�p�|jrtjd|z�|j||�y)aD
        Remove a message from the relay queue after it has been successfully
        sent.

        @type relay: L{SMTPManagedRelayerFactory}
        @param relay: The factory for the relayer which sent the message.

        @type message: L{bytes}
        @param message: The path of the file holding the message.
        z'success sending %s, removing from queueN)r�r
r�r�r�s   rr#z_AttemptManager.notifySuccesss+���:�:��G�G�=��G�H����U�G�$rc�F�|jrtjd|z�tjj|�}|jjj|�5}tj|�\}}ddd�tjt|jjj|�dz��\}}}|jjj�\}}|5tj ||g|�ddd�|j#�D]}|j%|��|j'�|j)||jjj|��y#1swY��
xYw#1swY��xYw)a7
        Generate a bounce message for a message which cannot be relayed.

        @type relay: L{SMTPManagedRelayerFactory}
        @param relay: The factory for the relayer responsible for the message.

        @type message: L{bytes}
        @param message: The path of the file holding the message.
        zcould not relay Nrl)r�r
r�rmr�r�rr�r�r�r�r
�generateBouncer�r�r��dump�
splitlines�lineReceived�eomReceivedr�)	rrr*�fp�from_�to�
bounceMessage�outgoingMessage�lines	         rr$z_AttemptManager.notifyFailure+sN���:�:��G�G�&��0�1��'�'�"�"�7�+��
�\�\�
�
�
/�
/��
8�	(�B����B��I�E�2�	(�#)�#8�#8�����#�#�+�+�G�4�t�;�<�e�R�$
� ��r�=�#�l�l�0�0�A�A�C���O�
�	)��K�K����R�(�	)�!�,�,�.�	/�D��(�(��.�	/��#�#�%����U�D�L�L�.�.�6�6�w�?�@�	(�	(��	)�	)�s�)F
�=F�
F�F c��|jjj|d�D]N}|jrt	j
d|zdz�|jjj|��P	|jj|=|j}d|_	|D]}|jd��y#t$rY�7wxYw)aF
        When the connection is lost or cannot be established, prepare to
        resend unsent messages and fire all deferred which are waiting for
        the completion of the attempt to relay.

        @type relay: L{SMTPManagedRelayerFactory}
        @param relay: The factory for the relayer for the connection.
        r7zSetting r�N)rr��getr�r
r�r�r~�KeyErrorr��callback)rrr*�
notifications�ds     rr/z_AttemptManager.notifyDoneHs����|�|�+�+�/�/��r�:�	3�G��z�z����
�W�,�z�9�:��L�L���)�)�'�2�	3�	����$�$�U�+��1�1�
�$(��!��	�A�
�J�J�t��	��	�	��	�s�9B<�<	C�Cc�r�	|jj|}|j
r!tjdt
|�z�d�}|jjd||jj|�|jj|=y#t$rtjd�YywxYw)a
        When a connection to the mail exchange server cannot be established,
        prepare to resend messages later.

        @type relay: L{SMTPManagedRelayerFactory}
        @param relay: The factory for the relayer meant to use the connection.
        z(notifyNoConnection passed unknown relay!NzBacking off on delivery of c�0�t|j|�yr��mapr~�r�r%s  rr~z6_AttemptManager.notifyNoConnection.<locals>.setWaitingp����� � �(�+r�)
rr�r�r
r�r��strr��	callLaterr�)rr�msgsr~s    rrMz"_AttemptManager.notifyNoConnection^s���	��<�<�'�'��.�D�
�:�:��G�G�1�C��I�=�>�	,�	
�����r�:�t�|�|�/A�/A�4�H��L�L� � ��'���	��G�G�>�?��	�s�B�B6�5B6)TN)r1r2r3r4rr�r�r#r$r/rMr7rrr�r��s+��	��*
-�)�
%�A�:�,(rr�c�n�eZdZUdZeZeeje	d<dZ
dZdd�Zd�Z
d�Zd�Zd	�Zd
�Zd�Zy)
�SmartHostSMTPRelayingManagera�
    A smart host which uses SMTP managed relayers to send messages from the
    relay queue.

    L{checkState} must be called periodically at which time the state of the
    relay queue is checked and new relayers are created as needed.

    In order to relay a set of messages to a mail exchange server, a smart host
    creates an attempt manager and a managed relayer factory for that set of
    messages.  When a connection is made with the mail exchange server, the
    managed relayer factory creates a managed relayer to send the messages.
    The managed relayer reports on its progress to the attempt manager which,
    in turn, updates the smart host's relay queue and information about its
    managed relayers.

    @ivar queue: See L{__init__}.
    @ivar maxConnections: See L{__init__}.
    @ivar maxMessagesPerConnection: See L{__init__}.

    @type fArgs: 3-L{tuple} of (0) L{list} of L{bytes},
        (1) L{_AttemptManager}, (2) L{bytes} or 4-L{tuple} of (0) L{list}
        of L{bytes}, (1) L{_AttemptManager}, (2) L{bytes}, (3) L{int}
    @ivar fArgs: Positional arguments for
        L{SMTPManagedRelayerFactory.__init__}.

    @type fKwArgs: L{dict}
    @ivar fKwArgs: Keyword arguments for L{SMTPManagedRelayerFactory.__init__}.

    @type factory: callable which returns L{SMTPManagedRelayerFactory}
    @ivar factory: A callable which creates a factory for creating a managed
        relayer. See L{SMTPManagedRelayerFactory.__init__} for parameters to
        the callable.

    @type PORT: L{int}
    @ivar PORT: The port over which to connect to the SMTP server.

    @type mxcalc: L{None} or L{MXCalculator}
    @ivar mxcalc: A resource for mail exchange host lookups.

    @type managed: L{dict} mapping L{SMTPManagedRelayerFactory} to L{list} of
        L{bytes}
    @ivar managed: A mapping of factory for a managed relayer to
        filenames of messages the managed relayer is responsible for.
    r�Nc�X�||_||_i|_||_d|_i|_y)a
        Initialize a smart host.

        The default values specify connection limits appropriate for a
        low-volume smart host.

        @type queue: L{Queue}
        @param queue: A relay queue.

        @type maxConnections: L{int}
        @param maxConnections: The maximum number of concurrent connections to
            SMTP servers.

        @type maxMessagesPerConnection: L{int}
        @param maxMessagesPerConnection: The maximum number of messages for
            which a relayer will be given responsibility.
        r7N)�maxConnections�maxMessagesPerConnectionr�r��fArgs�fKwArgs)rr�r�r�s    rrz%SmartHostSMTPRelayingManager.__init__�s0��$-���(@��%������
���
���rc�@�|jj�}|d=|S)z�
        Create a representation of the non-volatile state of this object.

        @rtype: L{dict} mapping L{bytes} to L{object}
        @return: The non-volatile state of the queue.
        r�)re�copy)r�dcts  rrcz)SmartHostSMTPRelayingManager.__getstate__�s"���m�m� � �"���	�N��
rc�H�|jj|�i|_y)z�
        Restore the non-volatile state of this object and recreate the volatile
        state.

        @type state: L{dict} mapping L{bytes} to L{object}
        @param state: The non-volatile state of the queue.
        N)rerfr�rgs  rriz)SmartHostSMTPRelayingManager.__setstate__�s��	
�
�
���U�#���rc���|jj�t|j�|jk\ry|jj�sy|j
�S)af
        Check the state of the relay queue and, if possible, launch relayers to
        handle waiting messages.

        @rtype: L{None} or L{Deferred}
        @return: No return value if no further messages can be relayed or a
            deferred which fires when all of the SMTP connections initiated by
            this call have disconnected.
        N)r�rarur�r�rv�
_checkStateMXrs r�
checkStatez'SmartHostSMTPRelayingManager.checkState�sP��	
�
�
� � �"��t�|�|��� 3� 3�3���z�z�$�$�&���!�!�#�#rc�<��|jj�}|j�i}|D�]}|jj|�\}}tj
j
|�\}}|jdd�}t|�dk7rtjd|z��}|d}	|jj|�|j|	g�j|jj|��t|�|jt|j �z
k\s��n|j"�t%�|_g}
|j'�D�](\}	}t)||jj*�}|j,||g|j.��i|j0��}
t3t4j6j8|�|j |
<|j;��|j"j=|	�}|j?d��|j?|j@|jB|
�|jE�fd��|jE|jF|
|	�|
j����+tI|
�S)N�@rz�zIllegal message destination: c�,�t|j�Sr)r��name)�mxs r�<lambda>z<SmartHostSMTPRelayingManager._checkStateMX.<locals>.<lambda>	s���B�G�G��rc�0���j|�|fdS)Nrz)�errback)�err�relayAttemptDeferreds �rr�z<SmartHostSMTPRelayingManager._checkStateMX.<locals>.<lambda>s���1�9�9�#�>��D�Q�G�r)%r�rs�reverser��email�utils�	parseaddr�splitrur
r�r{�
setdefaultr�r�r�r��mxcalc�MXCalculator�	iteritemsr�r�rr�r�r�rmr�r�r��getMX�addCallback�_cbExchange�PORT�
addErrback�_ebExchanger)r�nextMessages�	exchangesr�r�r�r�rJ�parts�domain�relaysr�rr�connectSetupDeferredr�s               @rr�z*SmartHostSMTPRelayingManager._checkStateMX�s ����z�z�,�,�.�������	��	�C��
�
�.�.�s�3�I�E�2����.�.�r�2�J�D�$��J�J�s�A�&�E��5�z�Q�����7�"�<�=���1�X�F��J�J�"�"�3�'�� � ���,�3�3�D�J�J�4F�4F�s�4K�L��9�~�$�"5�"5��D�L�L�8I�"I�J��	��;�;��&�.�D�K���%�/�/�1�	0�L�F�D�%�d�D�J�J�,<�,<�=�G�"�d�l�l�4��N�4�:�:�N����N�G�$'����(8�(8�$�$?�D�L�L��!�#*�#@�#@�#B� �#'�;�;�#4�#4�V�#<� � �,�,�-D�E� �,�,�T�-=�-=�t�y�y�'�R� �+�+�G�
�
!�+�+�D�,<�,<�g�v�N��M�M�.�/�	0��F�#�#rc�6�ddlm}|j|||�y)a�
        Initiate a connection with a mail exchange server.

        This callback function runs after mail exchange server for the domain
        has been looked up.

        @type address: L{bytes}
        @param address: The hostname of a mail exchange server.

        @type port: L{int}
        @param port: A port number.

        @type factory: L{SMTPManagedRelayerFactory}
        @param factory: A factory which can create a relayer for the mail
            exchange server.
        rr�N)r�r��
connectTCP)r�address�portrr�s     rr�z(SmartHostSMTPRelayingManager._cbExchanges��"	-����7�D�'�2rc���tjd|z�tj|�d�}ddlm}|j	d||j
|j|�|j|=y)a�
        Prepare to resend messages later.

        This errback function runs when no mail exchange server for the domain
        can be found.

        @type failure: L{Failure}
        @param failure: The reason the mail exchange lookup failed.

        @type factory: L{SMTPManagedRelayerFactory}
        @param factory: A factory which can create a relayer for the mail
            exchange server.

        @type domain: L{bytes}
        @param domain: A domain.
        z+Error setting up managed relay factory for c�0�t|j|�yrr�r�s  rr~z<SmartHostSMTPRelayingManager._ebExchange.<locals>.setWaiting;r�rrr�r�N)r
r�r�r�r�r�r�)r�failurerr�r~r�s      rr�z(SmartHostSMTPRelayingManager._ebExchange'sY��"	���=��F�G������	,�	-����"�j�$�*�*�d�l�l�7�6K�L��L�L��!r)r��
)r1r2r3r4rErrr�
ClientFactoryrPr�r�rrcrir�r�r�r�r7rrr�r�wsN��+�Z-F�G�T�(�(�(�
)�E�
�D�
�F��2	�	�$�$$$�L3�*"rr�c��eZdZdZeZy)�SmartHostESMTPRelayingManagera]
    A smart host which uses ESMTP managed relayers to send messages from the
    relay queue.

    @type factory: callable which returns L{ESMTPManagedRelayerFactory}
    @ivar factory: A callable which creates a factory for creating a managed
        relayer. See L{ESMTPManagedRelayerFactory.__init__} for parameters to
        the callable.
    N)r1r2r3r4rRrr7rrr	r	Ds���)�Grr	c�$�|j�y)z�
    Prompt a relaying manager to check state.

    @type manager: L{SmartHostSMTPRelayingManager}
    @param manager: A relaying manager.
    N)r�rs r�_checkStaterRs�����rc�8�tj|t|�S)a�
    Set up a periodic call to prompt a relaying manager to check state.

    @type manager: L{SmartHostSMTPRelayingManager}
    @param manager: A relaying manager.

    @type delay: L{float}
    @param delay: The number of seconds between calls.

    @rtype: L{TimerService <internet.TimerService>}
    @return: A service which periodically reminds a relaying manager to check
        state.
    )r�TimerServicer)r�delays  r�RelayStateHelperr\s��� � ���W�=�=rc��eZdZdZy)�CanonicalNameLoopz�
    An error indicating that when trying to look up a mail exchange host, a set
    of canonical name records was found which form a cycle and resolution was
    abandoned.
    N�r1r2r3r4r7rrrrm���rrc��eZdZdZy)�CanonicalNameChainTooLongz�
    An error indicating that when trying to look up a mail exchange host, too
    many canonical name records which point to other canonical name records
    were encountered and resolution was abandoned.
    Nrr7rrrrurrrc�F�eZdZdZdZdZdd�Zd�Zd�Zd
d�Z	d	�Z
d
�Zd�Zy)r�a�
    A utility for looking up mail exchange hosts and tracking whether they are
    working or not.

    @type clock: L{IReactorTime <twisted.internet.interfaces.IReactorTime>}
        provider
    @ivar clock: A reactor which will be used to schedule timeouts.

    @type resolver: L{IResolver <twisted.internet.interfaces.IResolver>}
    @ivar resolver: A resolver.

    @type badMXs: L{dict} mapping L{bytes} to L{float}
    @ivar badMXs: A mapping of non-functioning mail exchange hostname to time
        at which another attempt at contacting it may be made.

    @type timeOutBadMX: L{int}
    @ivar timeOutBadMX: Period in seconds between attempts to contact a
        non-functioning mail exchange host.

    @type fallbackToDomain: L{bool}
    @ivar fallbackToDomain: A flag indicating whether to attempt to use the
        hostname directly when no mail exchange can be found (C{True}) or
        not (C{False}).
    iTNc�\�i|_|�
ddlm}|�}||_|�ddlm}||_y)aU
        @type resolver: L{IResolver <twisted.internet.interfaces.IResolver>}
            provider or L{None}
        @param resolver: A resolver.

        @type clock: L{IReactorTime <twisted.internet.interfaces.IReactorTime>}
            provider or L{None}
        @param clock: A reactor which will be used to schedule timeouts.
        Nr)�createResolverr�)�badMXs�twisted.names.clientr�resolverr�r��clock)rrrrs    rrzMXCalculator.__init__�s2�������;�%�'�H� ��
��=�9���
rc�~�|jj�|jz|jt	|�<y)z�
        Record that a mail exchange host is not currently functioning.

        @type mx: L{bytes}
        @param mx: The hostname of a mail exchange host.
        N)r�seconds�timeOutBadMXrr��rr�s  r�markBadzMXCalculator.markBad�s.�� $�z�z�1�1�3�d�6G�6G�G����C��G�rc�>�	|j|=y#t$rYywxYw)z�
        Record that a mail exchange host is functioning.

        @type mx: L{bytes}
        @param mx: The hostname of a mail exchange host.
        N)rr�r s  r�markGoodzMXCalculator.markGood�s$��	����B����	��	�s�
�	�c���|jj|�}|j|j�|j|j||�|j|j|�|S)ad
        Find the name of a host that acts as a mail exchange server
        for a domain.

        @type domain: L{bytes}
        @param domain: A domain name.

        @type maximumCanonicalChainLength: L{int}
        @param maximumCanonicalChainLength: The maximum number of unique
            canonical name records to follow while looking up the mail exchange
            host.

        @rtype: L{Deferred} which successfully fires with L{Record_MX}
        @return: A deferred which succeeds with the MX record for the mail
            exchange server for the domain or fails if none can be found.
        )r�lookupMailExchanger��_filterRecords�_cbMXr��_ebMX)rr��maximumCanonicalChainLength�mailExchangeDeferreds    rr�zMXCalculator.getMX�sc��" $�}�}�?�?��G���(�(��)<�)<�=��(�(��J�J�� ;�	
�	�'�'��
�
�F�;�#�#rc��i}|dD]@}|jt|j�g�j|j��B|S)af
        Organize the records of a DNS response by record name.

        @type records: 3-L{tuple} of (0) L{list} of L{RRHeader
            <twisted.names.dns.RRHeader>}, (1) L{list} of L{RRHeader
            <twisted.names.dns.RRHeader>}, (2) L{list} of L{RRHeader
            <twisted.names.dns.RRHeader>}
        @param records: Answer resource records, authority resource records and
            additional resource records.

        @rtype: L{dict} mapping L{bytes} to L{list} of L{IRecord
            <twisted.names.dns.IRecord>} provider
        @return: A mapping of record name to record payload.
        r)r�r�r�r��payload)r�records�	recordBag�answers    rr&zMXCalculator._filterRecords�sL���	��a�j�	N�F�� � ��V�[�[�!1�2�6�=�=�f�n�n�M�	N��rc�P�ddlm}m}t�}g}|j	|g�}|r�|j�}	|	j|jk(ru|j|�t|	j�}
|
|vr |
|vrtt|	��S||
}g}n+|r|j|
|dz
�Stt|	��S|	j|jk(r|j!|	j"|	f�|r��|r�|j%�|D]l\}}	t|	j�}||j&vr|	cS|j(j+�|j&|z
}
|
dk\s�]|j&|=|	cS|ddSt|j-d|����S)a�
        Try to find the mail exchange host for a domain from the given DNS
        records.

        This will attempt to resolve canonical name record results.  It can
        recognize loops and will give up on non-cyclic chains after a specified
        number of lookups.

        @type answers: L{dict} mapping L{bytes} to L{list} of L{IRecord
            <twisted.names.dns.IRecord>} provider
        @param answers: A mapping of record name to record payload.

        @type domain: L{bytes}
        @param domain: A domain name.

        @type cnamesLeft: L{int}
        @param cnamesLeft: The number of unique canonical name records
            left to follow while looking up the mail exchange host.

        @rtype: L{Record_MX <twisted.names.dns.Record_MX>} or L{Failure}
        @return: An MX record for the mail exchange host or a failure if one
            cannot be found.
        r��dns�errorrzzNo MX records for )�
twisted.namesr2r3�setr��pop�TYPE�CNAME�addr�r�rrr�r�MXr��
preference�sortrrr�DNSNameError)r�answersr��
cnamesLeftr2r3�seenAliasesr��pertinentRecords�record�
canonicalNamer;�host�ts              rr'zMXCalculator._cbMX�s���4	-��e���	�"�;�;�v�r�2���%�)�)�+�F��{�{�c�i�i�'�����'� #�F�K�K� 0�
� �G�+�%��3�&�'8��'@�A�A�'.�}�'=�$� "�I�!�#�z�z�-��a��H�H� '�'@��'H�I�I��{�{�c�f�f�$�� � �&�"3�"3�V�!<�=�9�<��N�N��&/�
"�"�
�F��6�;�;�'���t�{�{�*�!�M��J�J�&�&�(�4�;�;�t�+<�<����6����D�)�!�M�
"��Q�<��?�"��5�-�-�0B�6�*�.M�N�O�Orc�t���ddlm�m�|jrx|j	�j
�t
jdj|��|jj|�}�fd�}�fd�}|j||�|S|j�j
�rtd|����|S)aX
        Attempt to use the name of the domain directly when mail exchange
        lookup fails.

        @type failure: L{Failure}
        @param failure: The reason for the lookup failure.

        @type domain: L{bytes}
        @param domain: The domain name.

        @rtype: L{Record_MX <twisted.names.dns.Record_MX>} or L{Failure}
        @return: An MX record for the domain or a failure if the fallback to
            domain option is not in effect and an error, other than not
            finding an MX record, occurred during lookup.

        @raise IOError: When no MX record could be found and the fallback to
            domain option is not in effect.

        @raise DNSLookupError: When no MX record could be found and the
            fallback to domain option is in effect but no address for the
            domain could be found.
        rr1z:MX lookup failed; attempting to use hostname ({}) directlyc�(���j|��S)N)r�)�	Record_MX)rJr2s �r�
cbResolvedz&MXCalculator._ebMX.<locals>.cbResolvedds����}�}�$�}�/�/rc�N��|j�j�t��r)�trapr=r)r�r3s �r�
ebResolvedz&MXCalculator._ebMX.<locals>.ebResolvedgs�������+�+�,�$�&�&rzNo MX found for )r4r2r3�fallbackToDomainrKr=r
r��formatr�
getHostByName�addCallbacks�check�OSError)rrr�r�rIrLr2r3s      @@rr(zMXCalculator._ebMX@s����.	-�� � ��L�L��+�+�,��G�G�L�S�S���
��
�
�+�+�F�3�A�
0�
'�
�N�N�:�z�2��H�
�]�]�5�-�-�
.��,�V�J�7�8�8��r)NN)�)
r1r2r3r4rrMrr!r#r�r&r'r(r7rrr�r�}s;���2�L����(H�
�$�2�(NP�`/rr�)-r4�email.utilsr�rmr�r��typingr�twisted.applicationrr�r�twisted.internet.deferrr�twisted.internet.errorr�twisted.internet.protocolr	�twisted.mailr
rr�twisted.pythonr
�twisted.python.failurerrr;r9rCrArrErRrYr�r�r	rr�	Exceptionrrr�r7rr�<module>r^s���
��	�
���(�%�9�1�4�,�,��*�'.�'.�T@�,�e�.?�.?�@�>A�-�u�/A�/A�A�@H&�� 6� 6�H&�V>�!:�>�BKQ�KQ�\S(�S(�lJ"�J"�Z)�$@�)��>�"�	���	��r�rr
¿Qué es la limpieza dental de perros? - Clínica veterinaria


Es la eliminación del sarro y la placa adherida a la superficie de los dientes mediante un equipo de ultrasonidos que garantiza la integridad de las piezas dentales a la vez que elimina en profundidad cualquier resto de suciedad.

A continuación se procede al pulido de los dientes mediante una fresa especial que elimina la placa bacteriana y devuelve a los dientes el aspecto sano que deben tener.

Una vez terminado todo el proceso, se mantiene al perro en observación hasta que se despierta de la anestesia, bajo la atenta supervisión de un veterinario.

¿Cada cuánto tiempo tengo que hacerle una limpieza dental a mi perro?

A partir de cierta edad, los perros pueden necesitar una limpieza dental anual o bianual. Depende de cada caso. En líneas generales, puede decirse que los perros de razas pequeñas suelen acumular más sarro y suelen necesitar una atención mayor en cuanto a higiene dental.


Riesgos de una mala higiene


Los riesgos más evidentes de una mala higiene dental en los perros son los siguientes:

  • Cuando la acumulación de sarro no se trata, se puede producir una inflamación y retracción de las encías que puede descalzar el diente y provocar caídas.
  • Mal aliento (halitosis).
  • Sarro perros
  • Puede ir a más
  • Las bacterias de la placa pueden trasladarse a través del torrente circulatorio a órganos vitales como el corazón ocasionando problemas de endocarditis en las válvulas. Las bacterias pueden incluso acantonarse en huesos (La osteomielitis es la infección ósea, tanto cortical como medular) provocando mucho dolor y una artritis séptica).

¿Cómo se forma el sarro?

El sarro es la calcificación de la placa dental. Los restos de alimentos, junto con las bacterias presentes en la boca, van a formar la placa bacteriana o placa dental. Si la placa no se retira, al mezclarse con la saliva y los minerales presentes en ella, reaccionará formando una costra. La placa se calcifica y se forma el sarro.

El sarro, cuando se forma, es de color blanquecino pero a medida que pasa el tiempo se va poniendo amarillo y luego marrón.

Síntomas de una pobre higiene dental
La señal más obvia de una mala salud dental canina es el mal aliento.

Sin embargo, a veces no es tan fácil de detectar
Y hay perros que no se dejan abrir la boca por su dueño. Por ejemplo…

Recientemente nos trajeron a la clínica a un perro que parpadeaba de un ojo y decía su dueño que le picaba un lado de la cara. Tenía molestias y dificultad para comer, lo que había llevado a sus dueños a comprarle comida blanda (que suele ser un poco más cara y llevar más contenido en grasa) durante medio año. Después de una exploración oftalmológica, nos dimos cuenta de que el ojo tenía una úlcera en la córnea probablemente de rascarse . Además, el canto lateral del ojo estaba inflamado. Tenía lo que en humanos llamamos flemón pero como era un perro de pelo largo, no se le notaba a simple vista. Al abrirle la boca nos llamó la atención el ver una muela llena de sarro. Le realizamos una radiografía y encontramos una fístula que llegaba hasta la parte inferior del ojo.

Le tuvimos que extraer la muela. Tras esto, el ojo se curó completamente con unos colirios y una lentilla protectora de úlcera. Afortunadamente, la úlcera no profundizó y no perforó el ojo. Ahora el perro come perfectamente a pesar de haber perdido una muela.

¿Cómo mantener la higiene dental de tu perro?
Hay varias maneras de prevenir problemas derivados de la salud dental de tu perro.

Limpiezas de dientes en casa
Es recomendable limpiar los dientes de tu perro semanal o diariamente si se puede. Existe una gran variedad de productos que se pueden utilizar:

Pastas de dientes.
Cepillos de dientes o dedales para el dedo índice, que hacen más fácil la limpieza.
Colutorios para echar en agua de bebida o directamente sobre el diente en líquido o en spray.

En la Clínica Tus Veterinarios enseñamos a nuestros clientes a tomar el hábito de limpiar los dientes de sus perros desde que son cachorros. Esto responde a nuestro compromiso con la prevención de enfermedades caninas.

Hoy en día tenemos muchos clientes que limpian los dientes todos los días a su mascota, y como resultado, se ahorran el dinero de hacer limpiezas dentales profesionales y consiguen una mejor salud de su perro.


Limpiezas dentales profesionales de perros y gatos

Recomendamos hacer una limpieza dental especializada anualmente. La realizamos con un aparato de ultrasonidos que utiliza agua para quitar el sarro. Después, procedemos a pulir los dientes con un cepillo de alta velocidad y una pasta especial. Hacemos esto para proteger el esmalte.

La frecuencia de limpiezas dentales necesaria varía mucho entre razas. En general, las razas grandes tienen buena calidad de esmalte, por lo que no necesitan hacerlo tan a menudo e incluso pueden pasarse la vida sin requerir una limpieza. Sin embargo, razas pequeñas como el Yorkshire o el Maltés, deben hacérselas todos los años desde cachorros si se quiere conservar sus piezas dentales.

Otro factor fundamental es la calidad del pienso. Algunas marcas han diseñado croquetas que limpian la superficie del diente y de la muela al masticarse.

Ultrasonido para perros

¿Se necesita anestesia para las limpiezas dentales de perros y gatos?

La limpieza dental en perros no es una técnica que pueda practicarse sin anestesia general , aunque hay veces que los propietarios no quieren anestesiar y si tiene poco sarro y el perro es muy bueno se puede intentar…… , pero no se va a poder pulir ni acceder a todas la zona de la boca …. Además los limpiadores dentales van a irrigar agua y hay riesgo de aspiración a vías respiratorias si no se realiza una anestesia correcta con intubación traqueal . En resumen , sin anestesia no se va hacer una correcta limpieza dental.

Tampoco sirve la sedación ya que necesitamos que el animal esté totalmente quieto, y el veterinario tenga un acceso completo a todas sus piezas dentales y encías.

Alimentos para la limpieza dental

Hay que tener cierto cuidado a la hora de comprar determinados alimentos porque no todos son saludables. Algunos tienen demasiado contenido graso, que en exceso puede causar problemas cardiovasculares y obesidad.

Los mejores alimentos para los dientes son aquellos que están elaborados por empresas farmacéuticas y llevan componentes químicos con tratamientos específicos para el diente del perro. Esto implica no solo limpieza a través de la acción mecánica de morder sino también un tratamiento antibacteriano para prevenir el sarro.

Conclusión

Si eres como la mayoría de dueños, por falta de tiempo , es probable que no estés prestando la suficiente atención a la limpieza dental de tu perro. Por eso te animamos a que comiences a limpiar los dientes de tu perro y consideres atender a su higiene bucal con frecuencia.

Estas simples medidas pueden conllevar a que tu perro tenga una vida más larga y mucho más saludable.

Si te resulta imposible introducir un cepillo de dientes a tu perro en la boca, pásate con él por clínica Tus Veterinarios y te explicamos cómo hacerlo.

Necesitas hacer una limpieza dental profesional a tu mascota?
Llámanos al 622575274 o contacta con nosotros

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

¡Hola!