예제 #1
0
파일: process.py 프로젝트: sporsh/carnifex
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
예제 #2
0
파일: ssh.py 프로젝트: jkoelker/prospector
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
예제 #3
0
파일: ssh.py 프로젝트: Fusl/prospector
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
예제 #4
0
 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)
예제 #5
0
파일: process.py 프로젝트: sporsh/carnifex
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
예제 #6
0
    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)