Exemple #1
0
def connectProcess(connection,
                   processProtocol,
                   commandLine='',
                   env={},
                   usePTY=None,
                   childFDs=None,
                   *args,
                   **kwargs):
    """Opens a SSHSession channel and connects a ProcessProtocol to it

    @param connection: the SSH Connection to open the session channel on
    @param processProtocol: the ProcessProtocol instance to connect to the process
    @param commandLine: the command line to execute the process
    @param env: optional environment variables to set for the process
    @param usePTY: if set, request a PTY for the process
    @param childFDs: custom child file descriptors for the process
    """
    processOpenDeferred = defer.Deferred()
    process = SSHProcess(processProtocol, commandLine, env, usePTY, childFDs,
                         *args, **kwargs)
    process.processOpen = processOpenDeferred.callback
    process.openFailed = processOpenDeferred.errback

    connection.openChannel(process)
    return processOpenDeferred
Exemple #2
0
def sendCommand(connection, command, result=None):
    def done(result, executed):
        executed.callback(connection)
        return result

    executed = defer.Deferred()
    result.addCallback(done, executed)
    channel = CommandChannel(command, result, conn=connection)
    connection.openChannel(channel)
    return executed
Exemple #3
0
def sendCommand(connection, command, result=None):
    def done(result, executed):
        executed.callback(connection)
        return result

    executed = defer.Deferred()
    result.addCallback(done, executed)
    channel = CommandChannel(command, result, conn=connection)
    connection.openChannel(channel)
    return executed
 def connect(self, remoteAddress, remotePort, inputProtocol):
     twunnel.logger.log(3, "trace: SSHOutputProtocolConnection.connect")
     
     if len(self.connections) == 0:
         return
     
     self.i = self.i + 1
     if self.i >= len(self.connections):
         self.i = 0
     
     connection = self.connections[self.i]
     
     inputProtocol.outputProtocol = SSHChannel(conn = connection)
     inputProtocol.outputProtocol.inputProtocol = inputProtocol
     data = forwarding.packOpen_direct_tcpip((remoteAddress, remotePort), (self.configuration["LOCAL_PROXY_SERVER"]["ADDRESS"], self.configuration["LOCAL_PROXY_SERVER"]["PORT"]))
     connection.openChannel(inputProtocol.outputProtocol, data)
Exemple #5
0
def connectProcess(connection, processProtocol, commandLine='', env={},
                   usePTY=None, childFDs=None, *args, **kwargs):
    """Opens a SSHSession channel and connects a ProcessProtocol to it

    @param connection: the SSH Connection to open the session channel on
    @param processProtocol: the ProcessProtocol instance to connect to the process
    @param commandLine: the command line to execute the process
    @param env: optional environment variables to set for the process
    @param usePTY: if set, request a PTY for the process
    @param childFDs: custom child file descriptors for the process
    """
    processOpenDeferred = defer.Deferred()
    process = SSHProcess(processProtocol, commandLine, env, usePTY, childFDs,
                         *args, **kwargs)
    process.processOpen = processOpenDeferred.callback
    process.openFailed = processOpenDeferred.errback

    connection.openChannel(process)
    return processOpenDeferred
    def connect(self, remoteAddress, remotePort, inputProtocol):
        twunnel.logger.log(3, "trace: SSHOutputProtocolConnection.connect")

        if len(self.connections) == 0:
            return

        self.i = self.i + 1
        if self.i >= len(self.connections):
            self.i = 0

        connection = self.connections[self.i]

        inputProtocol.outputProtocol = SSHChannel(conn=connection)
        inputProtocol.outputProtocol.inputProtocol = inputProtocol
        data = forwarding.packOpen_direct_tcpip(
            (remoteAddress, remotePort),
            (self.configuration["LOCAL_PROXY_SERVER"]["ADDRESS"],
             self.configuration["LOCAL_PROXY_SERVER"]["PORT"]))
        connection.openChannel(inputProtocol.outputProtocol, data)