ssh_tunnels 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9bcdb9b758ed9d27d0e81ba9bafbf8e50273fa38c2c954b332b916fccb7cc699
4
- data.tar.gz: 42d49d0040704dbe2ca4c51040ccfffc797eb2f5cf4dbdc7c322aa51a9f26c27
3
+ metadata.gz: 428ecc2c8e81f6b9d705f634a974fdb9c6a48d36285430154afb54ba842f5f0b
4
+ data.tar.gz: aa630aa9387d0e2ad8a2e61a2c4c5d5a137d0b4ec131432105fc357b9ef7fd02
5
5
  SHA512:
6
- metadata.gz: 109da60813a282a22c54b91075112e9a2bf5408e2490abe7c625aae87ef7c45ef3633ab698cdfd5f82fa24cf2a0fae04e32a6c86ba9a66b275b2eba97621e4c3
7
- data.tar.gz: 117a4e60567f1763cf7c55ca024e4a1a9fc00e4b187209aff3e57edb288b209dd18ab217e958d505a4837b5daab1a8bd9502e098d1640080c091633b60b6f282
6
+ metadata.gz: 609d1bdff13df6d9557b80bccf0cac59d103357fc3da9f652985da003a4fdafac26be3617bdde91d76b29652afcef1f3fba479b7e36cc29df57eeb85d91a9653
7
+ data.tar.gz: 3e9fa47276e2743552c9e191a33c1c5dd4c7334db574e44f45ffc2d00baa643ca685de9777996bbf8e36712d510838cdc2536d3564f8c141dc5bdc439767ec44
data/.rubocop.yml CHANGED
@@ -2,3 +2,7 @@ AllCops:
2
2
  NewCops: enable
3
3
  TargetRubyVersion: 3.3
4
4
  SuggestExtensions: false
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ssh_tunnels (0.3.0)
4
+ ssh_tunnels (0.3.1)
5
5
  bcrypt_pbkdf (~> 1.1)
6
6
  curses (~> 1.4)
7
7
  ed25519 (~> 1.3)
@@ -32,12 +32,15 @@ module SshTunnels
32
32
  end
33
33
 
34
34
  def open
35
- @session = Net::SSH.start(@gateway.fetch('host'), @gateway.fetch('user', @user), options)
36
- forward_local
35
+ @error = nil
36
+ connect
37
37
  @active = true
38
- @thread = Thread.new { @session.loop(0.001) { @active } }
39
- rescue StandardError
40
- shutdown
38
+ @thread = Thread.new { run_loop }
39
+ rescue StandardError => e
40
+ @error = e
41
+ @active = false
42
+ @session&.close
43
+ @session = nil
41
44
  raise
42
45
  end
43
46
 
@@ -48,13 +51,32 @@ module SshTunnels
48
51
  def shutdown
49
52
  @active = false
50
53
  @thread&.join
51
- @session&.close
52
- @session = nil
53
54
  @thread = nil
55
+ @session = nil
54
56
  end
55
57
 
56
58
  private
57
59
 
60
+ def connect
61
+ @session = Net::SSH.start(@gateway.fetch('host'), @gateway.fetch('user', @user), options)
62
+ forward_local
63
+ end
64
+
65
+ # Runs in the background thread. When the loop ends — whether because the
66
+ # user disconnected (@active set to false) or the connection dropped (the
67
+ # loop raises) — we must close the session here so the local forwarded port
68
+ # is released. Otherwise the orphaned listener keeps the port bound, causing
69
+ # connecting apps to hang and reconnects to fail with "address in use".
70
+ def run_loop
71
+ @session.loop(0.001) { @active }
72
+ rescue StandardError => e
73
+ @error = e
74
+ ensure
75
+ @active = false
76
+ @session&.close
77
+ @session = nil
78
+ end
79
+
58
80
  def forward_local
59
81
  args = [local_port, remote_host, remote_port]
60
82
  args.unshift(local_host) if local_host
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SshTunnels
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssh_tunnels
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Farrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-29 00:00:00.000000000 Z
11
+ date: 2026-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf