Current File : //proc/self/root/usr/lib/python3/dist-packages/twisted/conch/__pycache__/endpoints.cpython-312.pyc
�

Ϫ�f	u��^�dZgd�ZddlZddlmZddlmZddlmZm	Z	ddl
mZddlm
Z
dd	lmZmZdd
lmZddlmZmZddlmZdd
lmZddlmZddlmZddlmZm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-ddl.m/Z/m0Z0ddl1m2Z2ddl3m4Z4Gd�de5�Z6Gd�de�Z7Gd�d�Z8Gd�d e�Z9Gd!�d"e�Z:Gd#�d$e�Z;Gd%�d&e�Z<e	e)�Gd'�d(��Z=Gd)�d*�Z>e	e7�Gd+�d,��Z?e	e7�Gd-�d.��Z@y)/z7
Endpoint implementations of various SSH interactions.
)�AuthenticationFailed�SSHCommandAddress�SSHCommandClientEndpoint�N)�
expanduser)�unpack)�	Interface�implementer)�SSHAgentClient)�_KNOWN_HOSTS)�	ConsoleUI�KnownHostsFile)�
SSHChannel)�NS�getNS)�
SSHConnection)�Key)�SSHClientTransport)�SSHUserAuthClient)�CancelledError�Deferred�succeed)�TCP4ClientEndpoint�connectProtocol)�ConnectionDone�ProcessTerminated)�IStreamClientEndpoint)�Factory)�Logger)�nativeString�
networkString)�Failure)�FilePathc��eZdZdZy)rz`
    An SSH session could not be established because authentication was not
    successful.
    N)�__name__�
__module__�__qualname__�__doc__���9/usr/lib/python3/dist-packages/twisted/conch/endpoints.pyrr%s��r)rc��eZdZdZd�Zd�Zy)�_ISSHConnectionCreatorzS
    An L{_ISSHConnectionCreator} knows how to create SSH connections somehow.
    c��y)z�
        Return a new, connected, secured, but not yet authenticated instance of
        L{twisted.conch.ssh.transport.SSHServerTransport} or
        L{twisted.conch.ssh.transport.SSHClientTransport}.
        Nr(r(r)r*�secureConnectionz'_ISSHConnectionCreator.secureConnection2��r)c��y)a�
        Perform cleanup necessary for a connection object previously returned
        from this creator's C{secureConnection} method.

        @param connection: An L{twisted.conch.ssh.transport.SSHServerTransport}
            or L{twisted.conch.ssh.transport.SSHClientTransport} returned by a
            previous call to C{secureConnection}.  It is no longer needed by
            the caller of that method and may be closed or otherwise cleaned up
            as necessary.

        @param immediate: If C{True} don't wait for any network communication,
            just close the connection immediately and as aggressively as
            necessary.
        Nr()�
connection�	immediates  r*�cleanupConnectionz(_ISSHConnectionCreator.cleanupConnection9r/r)N)r$r%r&r'r.r3r(r)r*r,r,-s����r)r,c��eZdZdZd�Zy)ra$
    An L{SSHCommandAddress} instance represents the address of an SSH server, a
    username which was used to authenticate with that server, and a command
    which was run there.

    @ivar server: See L{__init__}
    @ivar username: See L{__init__}
    @ivar command: See L{__init__}
    c�.�||_||_||_y)a�
        @param server: The address of the SSH server on which the command is
            running.
        @type server: L{IAddress} provider

        @param username: An authentication username which was used to
            authenticate against the server at the given address.
        @type username: L{bytes}

        @param command: A command which was run in a session channel on the
            server at the given address.
        @type command: L{bytes}
        N)�server�username�command)�selfr6r7r8s    r*�__init__zSSHCommandAddress.__init__Us����� ��
���r)N)r$r%r&r'r:r(r)r*rrJs���r)rc�X�eZdZdZdZe�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zy)
�_CommandChannela�
    A L{_CommandChannel} executes a command in a session channel and connects
    its input and output to an L{IProtocol} provider.

    @ivar _creator: See L{__init__}
    @ivar _command: See L{__init__}
    @ivar _protocolFactory:  See L{__init__}
    @ivar _commandConnected:  See L{__init__}
    @ivar _protocol: An L{IProtocol} provider created using C{_protocolFactory}
        which is hooked up to the running command's input and output streams.
    ssessionc�t�tj|�||_||_||_||_d|_y)a�
        @param creator: The L{_ISSHConnectionCreator} provider which was used
            to get the connection which this channel exists on.
        @type creator: L{_ISSHConnectionCreator} provider

        @param command: The command to be executed.
        @type command: L{bytes}

        @param protocolFactory: A client factory to use to build a L{IProtocol}
            provider to use to associate with the running command.

        @param commandConnected: A L{Deferred} to use to signal that execution
            of the command has failed or that it has succeeded and the command
            is now running.
        @type commandConnected: L{Deferred}
        N)rr:�_creator�_command�_protocolFactory�_commandConnected�_reason)r9�creatorr8�protocolFactory�commandConnecteds     r*r:z_CommandChannel.__init__xs7��"	���D�!���
���
� /���!1�����r)c�:�|jj|�y)z�
        When the request to open a new channel to run this command in fails,
        fire the C{commandConnected} deferred with a failure indicating that.
        N�rA�errback�r9�reasons  r*�
openFailedz_CommandChannel.openFailed�s��
	
���&�&�v�.r)c��|jj|dt|j�d��}|j	|j
|j�y)z�
        When the request to open a new channel to run this command in succeeds,
        issue an C{"exec"} request to run the command.
        sexecT)�	wantReplyN)�conn�sendRequestrr?�addCallbacks�_execSuccess�_execFailure)r9�ignoredr8s   r*�channelOpenz_CommandChannel.channelOpen�sM��
�)�)�'�'��'�2�d�m�m�,��(�
��	���T�.�.��0A�0A�Br)c�:�|jj|�y)a
        When the request to execute the command in this channel fails, fire the
        C{commandConnected} deferred with a failure indicating this.

        @param reason: The cause of the command execution failure.
        @type reason: L{Failure}
        NrGrIs  r*rRz_CommandChannel._execFailure�s��	
���&�&�v�.r)c���|jjt|jjjj�|jjjj|jjjj��|_	|jj|�|jj|j�y)a�
        When the request to execute the command in this channel succeeds, use
        C{protocolFactory} to build a protocol to handle the command's input
        and output and connect the protocol to a transport representing those
        streams.

        Also fire C{commandConnected} with the created protocol after it is
        connected to its transport.

        @param ignored: The (ignored) result of the execute request
        N)
r@�
buildProtocolrrN�	transport�getPeerrCr7r8�	_protocol�makeConnectionrA�callback)r9rSs  r*rQz_CommandChannel._execSuccess�s����.�.�<�<���	�	�#�#�-�-�5�5�7��	�	�#�#�+�+�4�4��	�	�#�#�+�+�3�3�
�
���	
���%�%�d�+����'�'����7r)c�:�|jj|�y)z�
        When the command's stdout data arrives over the channel, deliver it to
        the protocol instance.

        @param data: The bytes from the command's stdout.
        @type data: L{bytes}
        N)rZ�dataReceived�r9�datas  r*r^z_CommandChannel.dataReceived�s��	
���#�#�D�)r)c�P�td|�\}|dk7rt|dd�|_yy)a
        When the server sends the command's exit status, record it for later
        delivery to the protocol.

        @param data: The network-order four byte representation of the exit
            status of the command.
        @type data: L{bytes}
        z>LrN)rrrB)r9r`�statuss   r*�request_exit_statusz#_CommandChannel.request_exit_status�s.���4��&�	���Q�;�,�V�T�4�@�D�L�r)c�P�t|�\}}tt|dd��|dd}}t|�\}}t|�\}}dt|���}t	t
|d�}|jjd|||jd�|��td|d�|_
y)	a
        When the server sends the command's exit status, record it for later
        delivery to the protocol.

        @param data: The network-order four byte representation of the exit
            signal of the command.
        @type data: L{bytes}
        r�N�SIG���z�Process exited with signal {shortSignalName!r}; core dumped: {coreDumped}; error message: {errorMessage}; language: {languageTag!r}zutf-8)�shortSignalName�
coreDumped�errorMessage�languageTag)r�bool�ordr�getattr�signal�_log�info�decoderrB)r9r`rhrirjrk�
signalName�signalIDs        r*�request_exit_signalz#_CommandChannel.request_exit_signal�s���!&�d�������D��1�I��/��a�b��D�
�"�4�[���d�!�$�K���T��<��8�9�:�
��6�:�r�2���	�	���
)�,�!�%�,�,�W�5�#�	�		
�)��x��>��r)c���|jj|jd�|j�t	d�}n|j}|j
j
t|��y)zf
        When the channel closes, deliver disconnection notification to the
        protocol.
        FNzssh channel closed)r>r3rNrBrrZ�connectionLostr!rIs  r*�closedz_CommandChannel.closed�sP��
	
�
�
�'�'��	�	�5�9��<�<��#�$8�9�F��\�\�F����%�%�g�f�o�6r)N)r$r%r&r'�namerrpr:rKrTrRrQr^rcrurxr(r)r*r<r<hsD��
��D��8�D��0/�C�/�8�,*�A�?�6
7r)r<c��eZdZdZd�Zd�Zy)�_ConnectionReadyz�
    L{_ConnectionReady} is an L{SSHConnection} (an SSH service) which only
    propagates the I{serviceStarted} event to a L{Deferred} to be handled
    elsewhere.
    c�<�tj|�||_y)zo
        @param ready: A L{Deferred} which should be fired when
            I{serviceStarted} happens.
        N)rr:�_ready)r9�readys  r*r:z_ConnectionReady.__init__s��
	���t�$���r)c�>�|jj|�|`y)z�
        When the SSH I{connection} I{service} this object represents is ready
        to be used, fire the C{connectionReady} L{Deferred} to publish that
        event to some other interested party.

        N)r}r\�r9s r*�serviceStartedz_ConnectionReady.serviceStarteds��	
�����T�"��Kr)N)r$r%r&r'r:r�r(r)r*r{r{s����r)r{c�F�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
y)
�	_UserAuthaG
    L{_UserAuth} implements the client part of SSH user authentication in the
    convenient way a user might expect if they are familiar with the
    interactive I{ssh} command line client.

    L{_UserAuth} supports key-based authentication, password-based
    authentication, and delegating authentication to an agent.
    Nc���|j�|jj�S|jr!|jjd�|_nd|_|jj�S)a~
        Retrieve the next public key object to offer to the server, possibly
        delegating to an authentication agent if there is one.

        @return: The public part of a key pair that could be used to
            authenticate with the server, or L{None} if there are no more
            public keys to try.
        @rtype: L{twisted.conch.ssh.keys.Key} or L{None}
        Nr)�agent�getPublicKey�keys�pop�key�publicr�s r*r�z_UserAuth.getPublicKey(sT���:�:�!��:�:�*�*�,�,��9�9��y�y�}�}�Q�'�D�H��D�H��x�x��� � r)c��|j�*|jj|j�|�Stj|||�S)z�
        Extend the base signing behavior by using an SSH agent to sign the
        data, if one is available.

        @type publicKey: L{Key}
        @type signData: L{str}
        )r��signData�blobr)r9�	publicKeyr�s   r*r�z_UserAuth.signData;sA���:�:�!��:�:�&�&�y�~�~�'7��B�B�$�-�-�d�I�x�H�Hr)c�,�t|j�S)a
        Get the private part of a key pair to use for authentication.  The key
        corresponds to the public part most recently returned from
        C{getPublicKey}.

        @return: A L{Deferred} which fires with the private key.
        @rtype: L{Deferred}
        )rr�r�s r*�
getPrivateKeyz_UserAuth.getPrivateKeyHs���t�x�x� � r)c�F�|j�yt|j�S)z�
        Get the password to use for authentication.

        @return: A L{Deferred} which fires with the password, or L{None} if the
            password was not specified.
        N)�passwordrr�s r*�getPasswordz_UserAuth.getPasswordSs ���=�=� ���t�}�}�%�%r)c�P�d|j_tj||�S)z�
        Handle user authentication success in the normal way, but also make a
        note of the state change on the L{_CommandTransport}.
        sCHANNELLING)rX�_stater�ssh_USERAUTH_SUCCESS)r9�packets  r*r�z_UserAuth.ssh_USERAUTH_SUCCESS^s#��
!/����� �5�5�d�F�C�Cr)c���t�}t|_|j|�}�fd�}|j	|�|S)as
        Set up a connection to the authentication agent and trigger its
        initialization.

        @param endpoint: An endpoint which can be used to connect to the
            authentication agent.
        @type endpoint: L{IStreamClientEndpoint} provider

        @return: A L{Deferred} which fires when the agent connection is ready
            for use.
        c�2��|�_|j�S�N)r��
getPublicKeys)r�r9s �r*�	connectedz+_UserAuth.connectToAgent.<locals>.connectedvs����D�J��&�&�(�(r))rr
�protocol�connect�addCallback)r9�endpoint�factory�dr�s`    r*�connectToAgentz_UserAuth.connectToAgentfs<����)��)������W�%��	)�	
�
�
�i� ��r)c�f�|j�y|jjj�y)z'
        Disconnect the agent.
        N)r�rX�loseConnectionr�s r*�loseAgentConnectionz_UserAuth.loseAgentConnection}s'���:�:����
�
���+�+�-r))r$r%r&r'r�r�r�r�r�r�r�r�r�r�r(r)r*r�r�s=����H��D��E�!�&I�	!�	&�D��..r)r�c�:�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d�Zy)	�_CommandTransporta
    L{_CommandTransport} is an SSH client I{transport} which includes a host
    key verification step before it will proceed to secure the connection.

    L{_CommandTransport} also knows how to set up a connection to an
    authentication agent if it is told where it can connect to one.

    @ivar _userauth: The L{_UserAuth} instance which is in charge of the
        overall authentication process or L{None} if the SSH connection has not
        reach yet the C{user-auth} service.
    @type _userauth: L{_UserAuth}
    sSTARTINGNc�z��t�fd���_�fd�}�jj|�|�_y)z�
        @param creator: The L{_NewConnectionHelper} that created this
            connection.

        @type creator: L{_NewConnectionHelper}.
        c�8���jj�Sr�)rX�abortConnection)r�r9s �r*�<lambda>z,_CommandTransport.__init__.<locals>.<lambda>�s���$�.�.�2P�2P�2R�r)c���d�_|Sr�)�connectionReady)�resultr9s �r*�
readyFiredz._CommandTransport.__init__.<locals>.readyFired�s���#'�D� ��Mr)N)rr��addBothrC)r9rCr�s`  r*r:z_CommandTransport.__init__�s5��� (�(R�S���	�	
���$�$�Z�0���r)c�n�|jj}t|jj	�j
�}d|_|jjj|jj||tj|��}|j|j�|S)a	
        Ask the L{KnownHostsFile} provider available on the factory which
        created this protocol this protocol to verify the given host key.

        @return: A L{Deferred} which fires with the result of
            L{KnownHostsFile.verifyHostKey}.
        �SECURING)rC�hostnamer rXrY�hostr��
knownHosts�
verifyHostKey�uir�
fromString�
addErrback�_saveHostKeyFailure)r9�hostKey�fingerprintr��ipr�s      r*r�z_CommandTransport.verifyHostKey�s����<�<�(�(��
�4�>�>�1�1�3�8�8�
9��!����L�L�#�#�1�1��L�L�O�O�X�r�3�>�>�'�+B�
��	
���T�-�-�.��r)c��||_|S)a+
        When host key verification fails, record the reason for the failure in
        order to fire a L{Deferred} with it later.

        @param reason: The cause of the host key verification failure.
        @type reason: L{Failure}

        @return: C{reason}
        @rtype: L{Failure}
        )�_hostKeyFailurerIs  r*r�z%_CommandTransport._saveHostKeyFailure�s�� &����
r)c�(��d�_t�j�}t�jj
|��_�jj�j_�jjr.t�jj��j_�jj�0�jj�jj�}ntd�}�fd�}|j|�y)zR
        When the connection is secure, start the authentication process.
        �AUTHENTICATINGNc�<���j�j�yr�)�requestService�	_userauth)rSr9s �r*�
maybeGotAgentz9_CommandTransport.connectionSecure.<locals>.maybeGotAgent�s���������/r))r�r{r�r�rCr7r�r�r��list�
agentEndpointr�rr�)r9r8r�r�s`   r*�connectionSecurez"_CommandTransport.connectionSecure�s����(���"�4�#7�#7�8��"�4�<�<�#8�#8�'�B���"&�,�,�"7�"7������<�<���"&�t�|�|�'8�'8�"9�D�N�N���<�<�%�%�1����-�-�d�l�l�.H�.H�I�A���
�A�	0�	
�	�	�-� r)c�T�|jr|jj�|jdk(s|j�y|jdk(r|j�
|j}n#|jdk(rtt
d��}|jj|�y)z�
        When the underlying connection to the SSH server is lost, if there were
        any connection setup errors, propagate them. Also, clean up the
        connection to the ssh agent if one was created.
        sRUNNINGNr�r�z$Connection lost while authenticating)r�r�r�r�r�r!rrHrIs  r*rwz _CommandTransport.connectionLost�s����>�>��N�N�.�.�0��;�;�*�$��(<�(<�(D���;�;�+�%�$�*>�*>�*J��)�)�F�
�[�[�-�
-��$�%K�L��F�	
���$�$�V�,r))r$r%r&r'r�r�r�r:r�r�r�rwr(r)r*r�r��s1����F��O��I��(�$�!�.-r)r�c�P�eZdZdZd�Ze						dd��Zed��Zd�Zd�Z	y)	ra�
    L{SSHCommandClientEndpoint} exposes the command-executing functionality of
    SSH servers.

    L{SSHCommandClientEndpoint} can set up a new SSH connection, authenticate
    it in any one of a number of different ways (keys, passwords, agents),
    launch a command over that connection and then associate its input and
    output with a protocol.

    It can also re-use an existing, already-authenticated SSH connection
    (perhaps one which already has some SSH channels being used for other
    purposes).  In this case it creates a new SSH channel to use to execute the
    command.  Notably this means it supports multiplexing several different
    command invocations over a single SSH connection.
    c� �||_||_y)at
        @param creator: An L{_ISSHConnectionCreator} provider which will be
            used to set up the SSH connection which will be used to run a
            command.
        @type creator: L{_ISSHConnectionCreator} provider

        @param command: The command line to execute on the SSH server.  This
            byte string is interpreted by a shell on the SSH server, so it may
            have a value like C{"ls /"}.  Take care when trying to run a
            command like C{"/Volumes/My Stuff/a-program"} - spaces (and other
            special bytes) may require escaping.
        @type command: L{bytes}

        N)r>r?)r9rCr8s   r*r:z!SSHCommandClientEndpoint.__init__s�� ��
���
r)Nc�<�t|||||||||	|
�
}|||�S)a�
        Create and return a new endpoint which will try to create a new
        connection to an SSH server and run a command over it.  It will also
        close the connection if there are problems leading up to the command
        being executed, after the command finishes, or if the connection
        L{Deferred} is cancelled.

        @param reactor: The reactor to use to establish the connection.
        @type reactor: L{IReactorTCP} provider

        @param command: See L{__init__}'s C{command} argument.

        @param username: The username with which to authenticate to the SSH
            server.
        @type username: L{bytes}

        @param hostname: The hostname of the SSH server.
        @type hostname: L{bytes}

        @param port: The port number of the SSH server.  By default, the
            standard SSH port number is used.
        @type port: L{int}

        @param keys: Private keys with which to authenticate to the SSH server,
            if key authentication is to be attempted (otherwise L{None}).
        @type keys: L{list} of L{Key}

        @param password: The password with which to authenticate to the SSH
            server, if password authentication is to be attempted (otherwise
            L{None}).
        @type password: L{bytes} or L{None}

        @param agentEndpoint: An L{IStreamClientEndpoint} provider which may be
            used to connect to an SSH agent, if one is to be used to help with
            authentication.
        @type agentEndpoint: L{IStreamClientEndpoint} provider

        @param knownHosts: The currently known host keys, used to check the
            host key presented by the server we actually connect to.
        @type knownHosts: L{KnownHostsFile}

        @param ui: An object for interacting with users to make decisions about
            whether to accept the server host keys.  If L{None}, a L{ConsoleUI}
            connected to /dev/tty will be used; if /dev/tty is unavailable, an
            object which answers C{b"no"} to all prompts will be used.
        @type ui: L{None} or L{ConsoleUI}

        @return: A new instance of C{cls} (probably
            L{SSHCommandClientEndpoint}).
        )�_NewConnectionHelper)�cls�reactorr8r7r��portr�r�r�r�r��helpers            r*�
newConnectionz&SSHCommandClientEndpoint.newConnections<��@&�����������
���6�7�#�#r)c�*�t|�}|||�S)ar
        Create and return a new endpoint which will try to open a new channel
        on an existing SSH connection and run a command over it.  It will
        B{not} close the connection if there is a problem executing the command
        or after the command finishes.

        @param connection: An existing connection to an SSH server.
        @type connection: L{SSHConnection}

        @param command: See L{SSHCommandClientEndpoint.newConnection}'s
            C{command} parameter.
        @type command: L{bytes}

        @return: A new instance of C{cls} (probably
            L{SSHCommandClientEndpoint}).
        )�_ExistingConnectionHelper)r�r1r8r�s    r*�existingConnectionz+SSHCommandClientEndpoint.existingConnectionls��$+�:�6���6�7�#�#r)c�r�|jj�}|j|j|�|S)a�
        Set up an SSH connection, use a channel from that connection to launch
        a command, and hook the stdin and stdout of that command up as a
        transport for a protocol created by the given factory.

        @param protocolFactory: A L{Factory} to use to create the protocol
            which will be connected to the stdin and stdout of the command on
            the SSH server.

        @return: A L{Deferred} which will fire with an error if the connection
            cannot be set up for any reason or with the protocol instance
            created by C{protocolFactory} once it has been connected to the
            command.
        )r>r.r��_executeCommand)r9rDr�s   r*r�z SSHCommandClientEndpoint.connect�s/��
�M�M�*�*�,��	�
�
�d�*�*�O�<��r)c����t�}��fd�}|j|�t�j�j||�}�j|�|S)a�
        Given a secured SSH connection, try to execute a command in a new
        channel created on it and associate the result with a protocol from the
        given factory.

        @param connection: See L{SSHCommandClientEndpoint.existingConnection}'s
            C{connection} parameter.

        @param protocolFactory: See L{SSHCommandClientEndpoint.connect}'s
            C{protocolFactory} parameter.

        @return: See L{SSHCommandClientEndpoint.connect}'s return value.
        c�j��|jt�}�jj�|�|Sr�)�checkrr>r3)�passthroughr2r1r9s  ��r*�disconnectOnFailurezESSHCommandClientEndpoint._executeCommand.<locals>.disconnectOnFailure�s/���$�)�)�.�9�I��M�M�+�+�J�	�B��r))rr�r<r>r?�openChannel)r9r1rDrEr��channels``    r*r�z(SSHCommandClientEndpoint._executeCommand�sU���$�:��	�	�#�#�$7�8�!��M�M�4�=�=�/�;K�
��	���w�'��r))NNNNNN)
r$r%r&r'r:�classmethodr�r�r�r�r(r)r*rr�sU���  �$��
�����K$��K$�Z�$��$�(�& r)rc�*�eZdZdZd�Zd�Zdd�Zd�Zy)�	_ReadFilez�
    A weakly file-like object which can be used with L{KnownHostsFile} to
    respond in the negative to all prompts for decisions.
    c��||_y)zk
        @param contents: L{bytes} which will be returned from every C{readline}
            call.
        N��	_contents)r9�contentss  r*r:z_ReadFile.__init__�s��
"��r)c��y)z6
        No-op.

        @param data: ignored
        Nr(r_s  r*�writez_ReadFile.write�r/r)c��|jS)z�
        Always give back the byte string that this L{_ReadFile} was initialized
        with.

        @param count: ignored

        @return: A fixed byte-string.
        @rtype: L{bytes}
        r�)r9�counts  r*�readlinez_ReadFile.readline�s���~�~�r)c��y)z
        No-op.
        Nr(r�s r*�closez_ReadFile.close�r/r)N)rg)r$r%r&r'r:r�r�r�r(r)r*r�r��s���
"��
�r)r�c�P�eZdZdZeZdZed�fd�Zd�Ze	d��Z
d�Zd�Zy	)
r�z�
    L{_NewConnectionHelper} implements L{_ISSHConnectionCreator} by
    establishing a brand new SSH connection, securing it, and authenticating.
    �s/dev/ttyc���||_||_|�||_||_||_||_||_||_|	�|j�}	|	|_	|
�t|j�}
|
|_||_
y)z�
        @param tty: The path of the tty device to use in case C{ui} is L{None}.
        @type tty: L{FilePath}

        @see: L{SSHCommandClientEndpoint.newConnection}
        N)r�r�r�r8r7r�r�r��_knownHostsr�r�_openerr��tty)r9r�r�r�r8r7r�r�r�r�r�r�s            r*r:z_NewConnectionHelper.__init__�s��(��� ��
����D�I���� ��
���	� ��
�*������)�)�+�J�$���
�:��4�<�<�(�B������r)c�n�	|jjd�S#t$rtd�cYSwxYw)z�
        Open the tty if possible, otherwise give back a file-like object from
        which C{b"no"} can be read.

        For use as the opener argument to L{ConsoleUI}.
        zrb+sno)r��open�
BaseExceptionr�r�s r*r�z_NewConnectionHelper._opener
s6��	$��8�8�=�=��'�'���	$��U�#�#�	$�s��4�4c�d�tjtt|j���S)z�

        @return: A L{KnownHostsFile} instance pointed at the user's personal
            I{known hosts} file.
        @rtype: L{KnownHostsFile}
        )r
�fromPathr"rr)r�s r*r�z _NewConnectionHelper._knownHostss%���&�&�x�
�3�;K�;K�0L�'M�N�Nr)c����t|�}|j�t|jt	|j
�|j�}t||�}|j�fd��|S)aR
        Create and return a new SSH connection which has been secured and on
        which authentication has already happened.

        @return: A L{Deferred} which fires with the ready-to-use connection or
            with a failure if something prevents the connection from being
            setup, secured, or authenticated.
        c����Sr�r()rSr~s �r*r�z7_NewConnectionHelper.secureConnection.<locals>.<lambda>3s���e�r))	r�r�rr�rr�r�rr�)r9r��	sshClientr�r~s    @r*r.z%_NewConnectionHelper.secureConnection"s\���%�T�*���(�(��&��L�L�,�t�}�}�5�t�y�y�
�	�
�I�x�0��	�
�
�+�,��r)c��|r%|jjj�y|jj�y)ab
        Clean up the connection by closing it.  The command running on the
        endpoint has ended so the connection is no longer needed.

        @param connection: The L{SSHConnection} to close.
        @type connection: L{SSHConnection}

        @param immediate: Whether to close connection immediately.
        @type immediate: L{bool}.
        N)rXr�r��r9r1r2s   r*r3z&_NewConnectionHelper.cleanupConnection6s3���
� � �*�*�:�:�<�� � �/�/�1r)N)
r$r%r&r'rr�r"r:r�r�r�r.r3r(r)r*r�r��sH���
 �L�
�D�
�[�!�$�L$��O��O��(2r)r�c�"�eZdZdZd�Zd�Zd�Zy)r�z�
    L{_ExistingConnectionHelper} implements L{_ISSHConnectionCreator} by
    handing out an existing SSH connection which is supplied to its
    initializer.
    c��||_y)z~
        @param connection: See L{SSHCommandClientEndpoint.existingConnection}'s
            C{connection} parameter.
        N)r1)r9r1s  r*r:z"_ExistingConnectionHelper.__init__Qs��
%��r)c�,�t|j�S)z~

        @return: A L{Deferred} that fires synchronously with the
            already-established connection object.
        )rr1r�s r*r.z*_ExistingConnectionHelper.secureConnectionXs���t���'�'r)c��y)a|
        Do not do any cleanup on the connection.  Leave that responsibility to
        whatever code created it in the first place.

        @param connection: The L{SSHConnection} which will not be modified in
            any way.
        @type connection: L{SSHConnection}

        @param immediate: An argument which will be ignored.
        @type immediate: L{bool}.
        Nr(r�s   r*r3z+_ExistingConnectionHelper.cleanupConnection`r/r)N)r$r%r&r'r:r.r3r(r)r*r�r�Is���%�(�r)r�)Ar'�__all__ro�os.pathr�structr�zope.interfacerr	�twisted.conch.client.agentr
�twisted.conch.client.defaultr�twisted.conch.client.knownhostsrr
�twisted.conch.ssh.channelr�twisted.conch.ssh.commonrr�twisted.conch.ssh.connectionr�twisted.conch.ssh.keysr�twisted.conch.ssh.transportr�twisted.conch.ssh.userauthr�twisted.internet.deferrrr�twisted.internet.endpointsrr�twisted.internet.errorrr�twisted.internet.interfacesr�twisted.internet.protocolr�twisted.loggerr�twisted.python.compatrr �twisted.python.failurer!�twisted.python.filepathr"�	Exceptionrr,rr<r{r�r�rr�r�r�r(r)r*�<module>rs$��
�T��
���1�5�5�E�0�.�6�&�:�8�D�D�J�D�=�-�!�=�*�,��9���Y��:��<U7�j�U7�p�}��4i.�!�i.�Xq-�*�q-�h
�
"�#�v �v �$�v �r#�#�L
�
#�$�k2�k2�%�k2�\
�
#�$�!�!�%�!r)
¿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!