##// END OF EJS Templates
increase default ssh tunnel timeout to 60 seconds...
MinRK -
Show More
@@ -122,7 +122,7 b' def _try_passwordless_paramiko(server, keyfile):'
122 return True
122 return True
123
123
124
124
125 def tunnel_connection(socket, addr, server, keyfile=None, password=None, paramiko=None):
125 def tunnel_connection(socket, addr, server, keyfile=None, password=None, paramiko=None, timeout=60):
126 """Connect a socket to an address via an ssh tunnel.
126 """Connect a socket to an address via an ssh tunnel.
127
127
128 This is a wrapper for socket.connect(addr), when addr is not accessible
128 This is a wrapper for socket.connect(addr), when addr is not accessible
@@ -131,12 +131,12 b' def tunnel_connection(socket, addr, server, keyfile=None, password=None, paramik'
131 selected local port of the tunnel.
131 selected local port of the tunnel.
132
132
133 """
133 """
134 new_url, tunnel = open_tunnel(addr, server, keyfile=keyfile, password=password, paramiko=paramiko)
134 new_url, tunnel = open_tunnel(addr, server, keyfile=keyfile, password=password, paramiko=paramiko, timeout=timeout)
135 socket.connect(new_url)
135 socket.connect(new_url)
136 return tunnel
136 return tunnel
137
137
138
138
139 def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None):
139 def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None, timeout=60):
140 """Open a tunneled connection from a 0MQ url.
140 """Open a tunneled connection from a 0MQ url.
141
141
142 For use inside tunnel_connection.
142 For use inside tunnel_connection.
@@ -157,10 +157,11 b' def open_tunnel(addr, server, keyfile=None, password=None, paramiko=None):'
157 tunnelf = paramiko_tunnel
157 tunnelf = paramiko_tunnel
158 else:
158 else:
159 tunnelf = openssh_tunnel
159 tunnelf = openssh_tunnel
160 tunnel = tunnelf(lport, rport, server, remoteip=ip, keyfile=keyfile, password=password)
160
161 tunnel = tunnelf(lport, rport, server, remoteip=ip, keyfile=keyfile, password=password, timeout=timeout)
161 return 'tcp://127.0.0.1:%i'%lport, tunnel
162 return 'tcp://127.0.0.1:%i'%lport, tunnel
162
163
163 def openssh_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, password=None, timeout=15):
164 def openssh_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, password=None, timeout=60):
164 """Create an ssh tunnel using command-line ssh that connects port lport
165 """Create an ssh tunnel using command-line ssh that connects port lport
165 on this machine to localhost:rport on server. The tunnel
166 on this machine to localhost:rport on server. The tunnel
166 will automatically close when not in use, remaining open
167 will automatically close when not in use, remaining open
@@ -192,7 +193,9 b" def openssh_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, pas"
192 password : str;
193 password : str;
193 Your ssh password to the ssh server. Note that if this is left None,
194 Your ssh password to the ssh server. Note that if this is left None,
194 you will be prompted for it if passwordless key based login is unavailable.
195 you will be prompted for it if passwordless key based login is unavailable.
195
196 timeout : int [default: 60]
197 The time (in seconds) after which no activity will result in the tunnel
198 closing. This prevents orphaned tunnels from running forever.
196 """
199 """
197 if pexpect is None:
200 if pexpect is None:
198 raise ImportError("pexpect unavailable, use paramiko_tunnel")
201 raise ImportError("pexpect unavailable, use paramiko_tunnel")
@@ -236,7 +239,7 b' def _split_server(server):'
236 port = 22
239 port = 22
237 return username, server, port
240 return username, server, port
238
241
239 def paramiko_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, password=None, timeout=15):
242 def paramiko_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, password=None, timeout=60):
240 """launch a tunner with paramiko in a subprocess. This should only be used
243 """launch a tunner with paramiko in a subprocess. This should only be used
241 when shell ssh is unavailable (e.g. Windows).
244 when shell ssh is unavailable (e.g. Windows).
242
245
@@ -271,6 +274,9 b" def paramiko_tunnel(lport, rport, server, remoteip='127.0.0.1', keyfile=None, pa"
271 password : str;
274 password : str;
272 Your ssh password to the ssh server. Note that if this is left None,
275 Your ssh password to the ssh server. Note that if this is left None,
273 you will be prompted for it if passwordless key based login is unavailable.
276 you will be prompted for it if passwordless key based login is unavailable.
277 timeout : int [default: 60]
278 The time (in seconds) after which no activity will result in the tunnel
279 closing. This prevents orphaned tunnels from running forever.
274
280
275 """
281 """
276 if paramiko is None:
282 if paramiko is None:
General Comments 0
You need to be logged in to leave comments. Login now