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 +4 -4
- data/.rubocop.yml +4 -0
- data/Gemfile.lock +1 -1
- data/lib/ssh_tunnels/tunnel.rb +29 -7
- data/lib/ssh_tunnels/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 428ecc2c8e81f6b9d705f634a974fdb9c6a48d36285430154afb54ba842f5f0b
|
|
4
|
+
data.tar.gz: aa630aa9387d0e2ad8a2e61a2c4c5d5a137d0b4ec131432105fc357b9ef7fd02
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 609d1bdff13df6d9557b80bccf0cac59d103357fc3da9f652985da003a4fdafac26be3617bdde91d76b29652afcef1f3fba479b7e36cc29df57eeb85d91a9653
|
|
7
|
+
data.tar.gz: 3e9fa47276e2743552c9e191a33c1c5dd4c7334db574e44f45ffc2d00baa643ca685de9777996bbf8e36712d510838cdc2536d3564f8c141dc5bdc439767ec44
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/ssh_tunnels/tunnel.rb
CHANGED
|
@@ -32,12 +32,15 @@ module SshTunnels
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def open
|
|
35
|
-
@
|
|
36
|
-
|
|
35
|
+
@error = nil
|
|
36
|
+
connect
|
|
37
37
|
@active = true
|
|
38
|
-
@thread = Thread.new {
|
|
39
|
-
rescue StandardError
|
|
40
|
-
|
|
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
|
data/lib/ssh_tunnels/version.rb
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2026-06-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bcrypt_pbkdf
|