sshkit 1.21.1 → 1.21.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/EXAMPLES.md +1 -0
- data/Gemfile +0 -5
- data/Vagrantfile +5 -0
- data/lib/sshkit/backends/connection_pool/cache.rb +12 -5
- data/lib/sshkit/version.rb +1 -1
- data/test/functional/backends/test_netssh.rb +14 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c845c4da471347d8486fa647e8c138ed1b4ea5b086adca5a2e06477ef711157
|
4
|
+
data.tar.gz: ef7598d8818ff1e262e41520e73f3c411f1217c005bf56d60d183eeef32b3805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8505e49f7025060f422837ed548517e8ced559d4f2462f23a541badd3d2d5c0436d04e8553f5d22771fd04f330c5bdcfe5d1a81b87a2144b2088b24062ae59ed
|
7
|
+
data.tar.gz: bc9f07123a4127fd82c0a26af34c4bb8d5a4b3d81532673a60ceb3529024c378412b84780f1042c3ce616d7b5eb0bb616a57c64e56f4aef57087feee6bcb0a13
|
data/.travis.yml
CHANGED
data/EXAMPLES.md
CHANGED
data/Gemfile
CHANGED
@@ -2,11 +2,6 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
platforms :rbx do
|
6
|
-
gem 'rubysl', '~> 2.0'
|
7
|
-
gem 'json'
|
8
|
-
end
|
9
|
-
|
10
5
|
# public_suffix 3+ requires ruby 2.1+
|
11
6
|
if Gem::Requirement.new('< 2.1').satisfied_by?(Gem::Version.new(RUBY_VERSION))
|
12
7
|
gem 'public_suffix', '< 3'
|
data/Vagrantfile
CHANGED
@@ -2,6 +2,11 @@ VAGRANTFILE_API_VERSION = "2"
|
|
2
2
|
|
3
3
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
4
4
|
config.vm.box = 'hashicorp/precise64'
|
5
|
+
config.vm.provision "shell", inline: <<-SHELL
|
6
|
+
echo 'ClientAliveInterval 1' >> /etc/ssh/sshd_config
|
7
|
+
echo 'ClientAliveCountMax 1' >> /etc/ssh/sshd_config
|
8
|
+
service ssh restart
|
9
|
+
SHELL
|
5
10
|
|
6
11
|
json_config_path = File.join("test", "boxes.json")
|
7
12
|
list = File.open(json_config_path).read
|
@@ -36,12 +36,12 @@ class SSHKit::Backend::ConnectionPool::Cache
|
|
36
36
|
def evict
|
37
37
|
# Peek at the first connection to see if it is still fresh. If so, we can
|
38
38
|
# return right away without needing to use `synchronize`.
|
39
|
-
first_expires_at,
|
40
|
-
return if first_expires_at.nil? || fresh?(first_expires_at)
|
39
|
+
first_expires_at, first_conn = connections.first
|
40
|
+
return if (first_expires_at.nil? || fresh?(first_expires_at)) && !closed?(first_conn)
|
41
41
|
|
42
42
|
connections.synchronize do
|
43
|
-
fresh, stale = connections.partition do |expires_at,
|
44
|
-
fresh?(expires_at)
|
43
|
+
fresh, stale = connections.partition do |expires_at, conn|
|
44
|
+
fresh?(expires_at) && !closed?(conn)
|
45
45
|
end
|
46
46
|
connections.replace(fresh)
|
47
47
|
stale.each { |_, conn| closer.call(conn) }
|
@@ -71,6 +71,13 @@ class SSHKit::Backend::ConnectionPool::Cache
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def closed?(conn)
|
74
|
-
conn.respond_to?(:closed?) && conn.closed?
|
74
|
+
return true if conn.respond_to?(:closed?) && conn.closed?
|
75
|
+
# test if connection is alive
|
76
|
+
conn.process(0) if conn.respond_to?(:process)
|
77
|
+
return false
|
78
|
+
rescue IOError => e
|
79
|
+
# connection is closed by server
|
80
|
+
return true if e.message == 'closed stream'
|
81
|
+
raise
|
75
82
|
end
|
76
83
|
end
|
data/lib/sshkit/version.rb
CHANGED
@@ -212,6 +212,20 @@ module SSHKit
|
|
212
212
|
end.run
|
213
213
|
assert_equal("Enter Data\nCaptured SOME DATA", captured_command_result)
|
214
214
|
end
|
215
|
+
|
216
|
+
def test_connection_pool_keepalive
|
217
|
+
# ensure we enable connection pool
|
218
|
+
SSHKit::Backend::Netssh.pool.idle_timeout = 10
|
219
|
+
Netssh.new(a_host) do |_host|
|
220
|
+
test :false
|
221
|
+
end.run
|
222
|
+
sleep 2.5
|
223
|
+
captured_command_result = nil
|
224
|
+
Netssh.new(a_host) do |_host|
|
225
|
+
captured_command_result = capture(:echo, 'some_value')
|
226
|
+
end.run
|
227
|
+
assert_equal "some_value", captured_command_result
|
228
|
+
end
|
215
229
|
end
|
216
230
|
|
217
231
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sshkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.21.
|
4
|
+
version: 1.21.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Hambley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: net-ssh
|
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: '0'
|
292
292
|
requirements: []
|
293
|
-
rubygems_version: 3.
|
293
|
+
rubygems_version: 3.2.5
|
294
294
|
signing_key:
|
295
295
|
specification_version: 4
|
296
296
|
summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
|