sshkit 1.21.0 → 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: 3eaedfcc391ee8b3f86807ce9985f135544a0f31743f86da16848d5fc3076c3f
4
- data.tar.gz: 20350f20d3645c905a13f1a0c0042d795ced406bea32d4c556730924c4c32dc4
3
+ metadata.gz: 5c845c4da471347d8486fa647e8c138ed1b4ea5b086adca5a2e06477ef711157
4
+ data.tar.gz: ef7598d8818ff1e262e41520e73f3c411f1217c005bf56d60d183eeef32b3805
5
5
  SHA512:
6
- metadata.gz: 38b892a953d3884a6d8077b40d153d25c795eff70c4ae406c26ea0cd542066e7f3553b34a684df7066e53549415fd10e3ca418e533dd2880e26d3a1c930f63ae
7
- data.tar.gz: c5c07a4bf6f856f61d1b63d8024fd9d686b13dfcdb1b6dae71d89ccf9d80daf53b10ee716cd6159fc4e67d829b6c50fe523411aba504c89f93e519b2e85da259
6
+ metadata.gz: 8505e49f7025060f422837ed548517e8ced559d4f2462f23a541badd3d2d5c0436d04e8553f5d22771fd04f330c5bdcfe5d1a81b87a2144b2088b24062ae59ed
7
+ data.tar.gz: bc9f07123a4127fd82c0a26af34c4bb8d5a4b3d81532673a60ceb3529024c378412b84780f1042c3ce616d7b5eb0bb616a57c64e56f4aef57087feee6bcb0a13
data/.travis.yml CHANGED
@@ -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
data/EXAMPLES.md CHANGED
@@ -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'
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, _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.0".freeze
2
+ VERSION = "1.21.2".freeze
3
3
  end
@@ -180,7 +180,7 @@ module SSHKit
180
180
  size = 25
181
181
  fills = SecureRandom.random_bytes(1024*1024)
182
182
  file_name = "/tmp/file-#{size}.txt"
183
- File.open(file_name, 'w') do |f|
183
+ File.open(file_name, 'wb') do |f|
184
184
  (size).times {f.write(fills) }
185
185
  end
186
186
  file_contents = ""
@@ -188,7 +188,7 @@ module SSHKit
188
188
  upload!(file_name, file_name)
189
189
  file_contents = download!(file_name)
190
190
  end.run
191
- assert_equal File.open(file_name).read, file_contents
191
+ assert_equal File.open(file_name, 'rb').read, file_contents
192
192
  end
193
193
 
194
194
  def test_upload_via_pathname
@@ -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,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sshkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.0
4
+ version: 1.21.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Hambley
8
8
  - Tom Clements
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-05 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
@@ -275,7 +275,7 @@ licenses:
275
275
  - MIT
276
276
  metadata:
277
277
  changelog_uri: https://github.com/capistrano/sshkit/releases
278
- post_install_message:
278
+ post_install_message:
279
279
  rdoc_options: []
280
280
  require_paths:
281
281
  - lib
@@ -290,8 +290,8 @@ 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.2
294
- signing_key:
293
+ rubygems_version: 3.2.5
294
+ signing_key:
295
295
  specification_version: 4
296
296
  summary: SSHKit makes it easy to write structured, testable SSH commands in Ruby
297
297
  test_files: