Loading cloudcontrol/node/host/__init__.py +18 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import subprocess import logging import os.path import struct import socket import termios from fcntl import ioctl from itertools import chain, imap Loading Loading @@ -172,6 +173,7 @@ class Handler(BasePlugin): rshell=self.rshell, rshell_resize=self.rshell_resize, rshell_wait=self.rshell_wait, forward=self.forward, )) # running shells self.shells = dict() Loading Loading @@ -235,3 +237,19 @@ class Handler(BasePlugin): def rshell_wait(self, label): """Wait for a tunnel termination.""" return self.shells[label].wait_n_close() @pass_connection def forward(self, conn, label, port, destination='127.0.0.1'): # create socket try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: logger.exception('Cannot create socket in forward handler') raise try: sock.connect((destination, port)) except socket.error: logger.exception('Error while connecting to destination (forward)') raise # create tunnel conn.create_tunnel(label=label, endpoint=sock) Loading
cloudcontrol/node/host/__init__.py +18 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ import subprocess import logging import os.path import struct import socket import termios from fcntl import ioctl from itertools import chain, imap Loading Loading @@ -172,6 +173,7 @@ class Handler(BasePlugin): rshell=self.rshell, rshell_resize=self.rshell_resize, rshell_wait=self.rshell_wait, forward=self.forward, )) # running shells self.shells = dict() Loading Loading @@ -235,3 +237,19 @@ class Handler(BasePlugin): def rshell_wait(self, label): """Wait for a tunnel termination.""" return self.shells[label].wait_n_close() @pass_connection def forward(self, conn, label, port, destination='127.0.0.1'): # create socket try: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: logger.exception('Cannot create socket in forward handler') raise try: sock.connect((destination, port)) except socket.error: logger.exception('Error while connecting to destination (forward)') raise # create tunnel conn.create_tunnel(label=label, endpoint=sock)