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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 302bdf2103654ae9a2cf858bf4c9cc585a57fac04a340f70c494a59cc0a8633f
4
- data.tar.gz: 9dc1fe14a5ccfc3e3ae756c04790a37c6c84564f62c5a506df078fa9e8e07d83
3
+ metadata.gz: 5c845c4da471347d8486fa647e8c138ed1b4ea5b086adca5a2e06477ef711157
4
+ data.tar.gz: ef7598d8818ff1e262e41520e73f3c411f1217c005bf56d60d183eeef32b3805
5
5
  SHA512:
6
- metadata.gz: 62dab7dd19368a572930d0eb704eed44f989e57cd68e7470998040f835b568f199ee230caf52ba519d58d596890b12e45fc010775a112fbcfe3ec7d9b94e3e4e
7
- data.tar.gz: d9185a014c779dfa43dfa7586223bb56cfae83b4e25f7d74a69badafce37e680ee2f3c04bbbf2cffda82366b982e09cde13b9321a10f73a2b065a10d0cd45c9c
6
+ metadata.gz: 8505e49f7025060f422837ed548517e8ced559d4f2462f23a541badd3d2d5c0436d04e8553f5d22771fd04f330c5bdcfe5d1a81b87a2144b2088b24062ae59ed
7
+ data.tar.gz: bc9f07123a4127fd82c0a26af34c4bb8d5a4b3d81532673a60ceb3529024c378412b84780f1042c3ce616d7b5eb0bb616a57c64e56f4aef57087feee6bcb0a13
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 3.0
4
+ - 2.7
5
+ - 2.6
3
6
  - 2.5
4
7
  - 2.4
5
8
  - 2.3
@@ -8,7 +11,7 @@ rvm:
8
11
  - 2.0
9
12
  branches:
10
13
  only:
11
- - master
14
+ - master
12
15
  matrix:
13
16
  include:
14
17
  # Run Danger only once, on 2.5
@@ -171,6 +171,7 @@ individual hosts:
171
171
  SSHKit::Backend::Netssh.configure do |ssh|
172
172
  ssh.connection_timeout = 30
173
173
  ssh.ssh_options = {
174
+ user: 'adifferentuser',
174
175
  keys: %w(/home/user/.ssh/id_rsa),
175
176
  forward_agent: false,
176
177
  auth_methods: %w(publickey password)
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'
@@ -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, _connection = connections.first
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
@@ -1,3 +1,3 @@
1
1
  module SSHKit
2
- VERSION = "1.21.1".freeze
2
+ VERSION = "1.21.2".freeze
3
3
  end
@@ -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.1
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: 2020-11-26 00:00:00.000000000 Z
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.1.4
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