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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02d7a7b16448e5680c078a84f37ad8a7919a16c3d373124b6cb9b01697296b1f
4
- data.tar.gz: c800950968aff424a071c0b8e34e056468190c2353f2de2be4cf8bfa44bdf19d
3
+ metadata.gz: d630446f0fdb8aef67ee33836b032d03308e2928900b69654c4346b8c711f5be
4
+ data.tar.gz: 9bd5674dde7c914f166137d4c133af0bf0fff4bd6ec5e1e5b54a18911e953b89
5
5
  SHA512:
6
- metadata.gz: 2bfed31e7bd9647dcb6e3c400433f426af7862d6d0c60bc0cfbddcd067893c8f160a2f10a2afe56113eb8c88441f81b31eade53e4b885766f12a7792b4b6002c
7
- data.tar.gz: e7f7f90b6c266185eb55bc18a65e6552f2e860058ef9c4b7cc39d96a13f7c69f3d193c3c985f7c416dab38fd3c953f15066f353660738ad1060c74b290c0d6ee
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)](http://www.rubydoc.info/gems/net-ssh-proxy-gateway)
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
@@ -2,7 +2,7 @@ module Net
2
2
  module SSH
3
3
  module Proxy
4
4
  class Gateway
5
- VERSION = '0.1.0'.freeze
5
+ VERSION = '0.2.0'.freeze
6
6
  end
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-ssh-proxy-gateway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc