Exemple #1
0
 def __init__(self, ready):
     """
     @param ready: A L{Deferred} which should be fired when
         I{serviceStarted} happens.
     """
     SSHConnection.__init__(self)
     self._ready = ready
Exemple #2
0
 def __init__(self, ready):
     """
     @param ready: A L{Deferred} which should be fired when
         I{serviceStarted} happens.
     """
     SSHConnection.__init__(self)
     self._ready = ready
Exemple #3
0
 def __init__(self):
     """
     Adds a deferred here so client can add a callback when the SFTP client is ready.
     """
     SSHConnection.__init__(self)
     self._sftpClient = Deferred()
     self.sftpSession = SFTPSession()
Exemple #4
0
    def serviceStopped(self):
        for d, channel in self._pendingChannelsDeferreds:
            d.cancel()
        else:
            del self._pendingChannelsDeferreds[:]
        self._ready = False

        SSHConnection.serviceStopped(self)
Exemple #5
0
    def serviceStopped(self):
        for d, channel in self._pendingChannelsDeferreds:
            d.cancel()
        else:
            del self._pendingChannelsDeferreds[:]
        self._ready = False

        SSHConnection.serviceStopped(self)
Exemple #6
0
 def __init__(self, factory):
     """
     @param factory: The factory used to create the connection this service
         is running over to grant access to the C{connectionReady} attribute
         which is a L{Deferred} which will get fired when I{serviceStarted}
         happens.
     """
     SSHConnection.__init__(self)
     self._factory = factory
Exemple #7
0
    def serviceStarted(self):
        SSHConnection.serviceStarted(self)
        self._ready = True
        for d, channel in self._pendingChannelsDeferreds:
            self.openChannel(channel)
            d.callback(True)
        else:
            del self._pendingChannelsDeferreds[:]

        self.factory.server.connection = self
        self.factory.serverConnected.callback(self)
Exemple #8
0
    def serviceStarted(self):
        SSHConnection.serviceStarted(self)
        self._ready = True
        for d, channel in self._pendingChannelsDeferreds:
            self.openChannel(channel)
            d.callback(True)
        else:
            del self._pendingChannelsDeferreds[:]

        self.factory.server.connection = self
        self.factory.serverConnected.callback(self)
 def test_cleanupConnectionNotImmediately(self):
     """
     L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
     if called with C{immediate} set to C{False}.
     """
     helper = _NewConnectionHelper(
         None, None, None, None, None, None, None, None, None, None)
     connection = SSHConnection()
     connection.transport = StringTransport()
     helper.cleanupConnection(connection, False)
     self.assertTrue(connection.transport.disconnecting)
 def test_cleanupConnectionNotImmediately(self):
     """
     L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
     if called with C{immediate} set to C{False}.
     """
     helper = _NewConnectionHelper(None, None, None, None, None, None, None,
                                   None, None, None)
     connection = SSHConnection()
     connection.transport = StringTransport()
     helper.cleanupConnection(connection, False)
     self.assertTrue(connection.transport.disconnecting)
    def test_cleanupConnectionImmediately(self):
        """
        L{_NewConnectionHelper.cleanupConnection} closes the transport with
        C{abortConnection} if called with C{immediate} set to C{True}.
        """
        class Abortable:
            aborted = False
            def abortConnection(self):
                """
                Abort the connection.
                """
                self.aborted = True

        helper = _NewConnectionHelper(
            None, None, None, None, None, None, None, None, None, None)
        connection = SSHConnection()
        connection.transport = SSHClientTransport()
        connection.transport.transport = Abortable()
        helper.cleanupConnection(connection, True)
        self.assertTrue(connection.transport.transport.aborted)
Exemple #12
0
    def startConnection(self, user):
        serviceStartedDeferred = defer.Deferred()
        connectionService = SSHConnection()
        def serviceStarted():
            self._connections[user] = connectionService
            serviceStartedDeferred.callback(connectionService)
        connectionService.serviceStarted = serviceStarted

        connectionLostDeferred = defer.Deferred()
        userAuthObject = self._getUserAuthObject(user, connectionService)
        sshClientFactory = SSHClientFactory(connectionLostDeferred,
                                            self._verifyHostKey, userAuthObject)

        def connectionEnded(reason):
            self._connections[user] = None
            serviceStartedDeferred.called or serviceStartedDeferred.errback(reason)
        connectionLostDeferred.addBoth(connectionEnded)
        connectionMadeDeferred = self.endpoint.connect(sshClientFactory)
        connectionMadeDeferred.addErrback(connectionEnded)

        return serviceStartedDeferred
    def test_cleanupConnectionImmediately(self):
        """
        L{_NewConnectionHelper.cleanupConnection} closes the transport with
        C{abortConnection} if called with C{immediate} set to C{True}.
        """
        class Abortable:
            aborted = False

            def abortConnection(self):
                """
                Abort the connection.
                """
                self.aborted = True

        helper = _NewConnectionHelper(None, None, None, None, None, None, None,
                                      None, None, None)
        connection = SSHConnection()
        connection.transport = SSHClientTransport()
        connection.transport.transport = Abortable()
        helper.cleanupConnection(connection, True)
        self.assertTrue(connection.transport.transport.aborted)
Exemple #14
0
    def startConnection(self, user):
        serviceStartedDeferred = defer.Deferred()
        connectionService = SSHConnection()
        def serviceStarted():
            self._connections[user] = connectionService
            serviceStartedDeferred.callback(connectionService)
        connectionService.serviceStarted = serviceStarted

        connectionLostDeferred = defer.Deferred()
        userAuthObject = self._getUserAuthObject(user, connectionService)
        sshClientFactory = SSHClientFactory(connectionLostDeferred,
                                            self._verifyHostKey, userAuthObject)

        def connectionEnded(reason):
            self._connections[user] = None
            serviceStartedDeferred.called or serviceStartedDeferred.errback(reason)
        connectionLostDeferred.addBoth(connectionEnded)
        connectionMadeDeferred = self.endpoint.connect(sshClientFactory)
        connectionMadeDeferred.addErrback(connectionEnded)

        return serviceStartedDeferred
Exemple #15
0
 def __init__(self, factory):
     SSHConnection.__init__(self)
     self.factory = factory
     self._pendingChannelsDeferreds = []
Exemple #16
0
 def __init__(self, command, env={}):
     SSHConnection.__init__(self)
     self.command_str = command
     self.env = env
     self.reason = None
Exemple #17
0
 def __init__(self, client):
     SSHConnection.__init__(self)
     self.client = client
Exemple #18
0
 def channelClosed(self, channel):
     SSHConnection.channelClosed(self, channel)
     self.reason = channel.reason
     self.transport.loseConnection()
Exemple #19
0
 def __init__(self, command):
     SSHConnection.__init__(self)
     self.command_str = command
     self.reason = None
Exemple #20
0
 def __init__(self, command):
     SSHConnection.__init__(self)
     self.command_str = command
     self.reason = None
 def __init__(self, filename, stop_defer):
     SSHConnection.__init__(self)
     self.filename = filename
     self.stop_defer = stop_defer
 def __init__(self, command, protocolFactory, commandConnected):
     SSHConnection.__init__(self)
     self._command = command
     self._protocolFactory = protocolFactory
     self._commandConnected = commandConnected
Exemple #23
0
 def __init__(self, command, protocolFactory, commandConnected):
     SSHConnection.__init__(self)
     self._command = command
     self._protocolFactory = protocolFactory
     self._commandConnected = commandConnected
Exemple #24
0
 def channelClosed(self, channel):
     SSHConnection.channelClosed(self, channel)
     self.reason = channel.reason
     self.transport.loseConnection()
Exemple #25
0
 def __init__(self, factory):
     SSHConnection.__init__(self)
     self.factory = factory
     self._pendingChannelsDeferreds = []
Exemple #26
0
 def __init__(self, client):
     SSHConnection.__init__(self)
     self.client = client