##// END OF EJS Templates
split open_tunnel part of tunnel_connection into separate method...
MinRK -
Show More
@@ -110,6 +110,22 b' def tunnel_connection(socket, addr, server, keyfile=None, password=None, paramik'
110 110 selected local port of the tunnel.
111 111
112 112 """
113 new_url, tunnel = open_tunnel(addr, server, keyfile=keyfile, password=password, paramiko=paramiko)
114 socket.connect(new_url)
115 return tunnel
116
117
118 def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None):
119 """Open a tunneled connection from a 0MQ url.
120
121 For use inside tunnel_connection.
122
123 Returns
124 -------
125
126 (url, tunnel): The 0MQ url that has been forwarded, and the tunnel object
127 """
128
113 129 lport = select_random_ports(1)[0]
114 130 transport, addr = addr.split('://')
115 131 ip,rport = addr.split(':')
@@ -121,8 +137,7 b' def tunnel_connection(socket, addr, server, keyfile=None, password=None, paramik'
121 137 else:
122 138 tunnelf = openssh_tunnel
123 139 tunnel = tunnelf(lport, rport, server, remoteip=ip, keyfile=keyfile, password=password)
124 socket.connect('tcp://127.0.0.1:%i'%lport)
125 return tunnel
140 return 'tcp://127.0.0.1:%i'%lport, tunnel
126 141
127 142 def openssh_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, password=None, timeout=15):
128 143 """Create an ssh tunnel using command-line ssh that connects port lport
General Comments 0
You need to be logged in to leave comments. Login now