net-ssh-proxy-gateway 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/net/ssh/proxy/gateway.rb +18 -1
- data/lib/net/ssh/proxy/gateway/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d630446f0fdb8aef67ee33836b032d03308e2928900b69654c4346b8c711f5be
|
4
|
+
data.tar.gz: 9bd5674dde7c914f166137d4c133af0bf0fff4bd6ec5e1e5b54a18911e953b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f6fa056fc2d5f86b4fe95a2ea187d6ea678a6f35d9b7d5246466d223ee7cf22a3b9347997708be64bbacfd0615b2e3e2d18217c3c8878b7325aa0b55d4942d9
|
7
|
+
data.tar.gz: 5278e32e762df8b0aa56aa21c3f772944ad34eb5bb5fdaf0a7e0ecaf056256aab7a92520697ec562873fe24a062a03ba36b3edc3f7928bb79414fcf6bf7c09af
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/kontena/net-ssh-proxy-gateway.svg?branch=master)](https://travis-ci.org/kontena/net-ssh-proxy-gateway)
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/net-ssh-proxy-gateway)](https://badge.fury.io/rb/net-ssh-proxy-gateway)
|
3
|
-
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/net-ssh-proxy-gateway.svg)](https://badge.fury.io/rb/net-ssh-proxy-gateway)
|
3
|
+
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/kontena/net-ssh-proxy-gateway)
|
4
4
|
|
5
5
|
# Net::SSH::Proxy::Gateway
|
6
6
|
|
@@ -30,10 +30,12 @@ module Net
|
|
30
30
|
# @param connection_options [Hash]
|
31
31
|
# @return [Socket]
|
32
32
|
def open(host, port, connection_options = nil)
|
33
|
+
ensure_connected!
|
34
|
+
|
33
35
|
local_port = gateway.open(host, connection_options&.dig(:port) || 22)
|
34
36
|
io = Socket.tcp('localhost'.freeze, local_port, nil, nil, connect_timeout: connection_options&.dig(:timeout))
|
35
37
|
|
36
|
-
Thread.new(io, local_port) do |io, local_port|
|
38
|
+
Thread.new(io, local_port, self) do |io, local_port, gateway|
|
37
39
|
Thread.current.report_on_exception = false
|
38
40
|
Thread.pass until io.closed?
|
39
41
|
gateway.close(local_port)
|
@@ -45,6 +47,21 @@ module Net
|
|
45
47
|
@gateway&.close(local_port) if local_port
|
46
48
|
raise
|
47
49
|
end
|
50
|
+
|
51
|
+
# Shuts down the Net::SSH::Gateway instance
|
52
|
+
def shutdown!
|
53
|
+
@gateway&.shutdown!
|
54
|
+
sleep 0.5 until !@gateway&.active?
|
55
|
+
@gateway = nil
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def ensure_connected!
|
61
|
+
unless @gateway&.active?
|
62
|
+
@gateway = nil
|
63
|
+
end
|
64
|
+
end
|
48
65
|
end
|
49
66
|
end
|
50
67
|
end
|