sauce 0.4.0 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/gateway_ext.rb +38 -0
- metadata +2 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.3
|
data/lib/gateway_ext.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# http://groups.google.com/group/capistrano/browse_thread/thread/455c0c8a6faa9cc8?pli=1
|
2
|
+
class Net::SSH::Gateway
|
3
|
+
# Opens a SSH tunnel from a port on a remote host to a given host and port
|
4
|
+
# on the local side
|
5
|
+
# (equivalent to openssh -R parameter)
|
6
|
+
def open_remote(port, host, remote_port, remote_host = "127.0.0.1")
|
7
|
+
ensure_open!
|
8
|
+
|
9
|
+
begin
|
10
|
+
@session_mutex.synchronize do
|
11
|
+
result = @session.forward.remote(port, host, remote_port, remote_host)
|
12
|
+
end
|
13
|
+
|
14
|
+
if block_given?
|
15
|
+
begin
|
16
|
+
yield [remote_port, remote_host]
|
17
|
+
ensure
|
18
|
+
close_remote(remote_port, remote_host)
|
19
|
+
end
|
20
|
+
else
|
21
|
+
return [remote_port, remote_host]
|
22
|
+
end
|
23
|
+
rescue Errno::EADDRINUSE
|
24
|
+
retry
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Cancels port-forwarding over an open port that was previously opened via
|
29
|
+
# #open_remote.
|
30
|
+
def close_remote(port, host = "127.0.0.1")
|
31
|
+
puts "Close the remote port #{host}:#{port}!"
|
32
|
+
ensure_open!
|
33
|
+
|
34
|
+
@session_mutex.synchronize do
|
35
|
+
@session.forward.cancel_remote(port, host)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sauce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Grove
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- README.markdown
|
49
49
|
- Rakefile
|
50
50
|
- VERSION
|
51
|
+
- lib/gateway_ext.rb
|
51
52
|
- lib/job.rb
|
52
53
|
- lib/rest.rb
|
53
54
|
- lib/sauce.rb
|