deploy-agent 1.2.0 → 1.3.3

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
- SHA1:
3
- metadata.gz: 5e1c889d6e8699972cf1452a86c42d9be633cc65
4
- data.tar.gz: dd2f460d6e6d8fbaeac3da023719f7a5c04b62fe
2
+ SHA256:
3
+ metadata.gz: 55068c8f22a5ef2219f05df92bea4a61f61b7fe50d6913bde0370e0ee57636de
4
+ data.tar.gz: 69c43ca34010ef2087ebb64159b6bdd65088ed73adfa5b36927e5ff10a8d9750
5
5
  SHA512:
6
- metadata.gz: 6eb91a06b4226c38fbd7e5ca0f8f28897a36e3c19e4079e52a2f6b1702e3d67883fa2561840977d024ecf3f28815e5f29b39793b8f39a30fb8d1a7f175c00259
7
- data.tar.gz: 9e3bca578a01b6b578c48a353f447db801f70d661b1b395a120467613f0990b3e3df516c99f315f550115f5b76964184c12b154eb3e312bf185c339def5af10d
6
+ metadata.gz: b461ee04ef850bdf398ce0cf37ac1f888778d997d36f111fe78c0b886b1b44b7a7f26902f4bc8cecbacd2879d1fcacbed84464e2e4e9de0c9e2f89dbfd9126ba
7
+ data.tar.gz: c26dab5b3ccd5b9a4f65849321c4c2873c81071b38dd6bf5ac41e51e235e986cdacf925e80628c61b51900c8d1b6e68521324d8e41e6d0bc466222b7165873c1
data/bin/deploy-agent CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- $:.unshift(File.expand_path('../../lib', __FILE__))
2
+ # frozen_string_literal: true
3
+
4
+ $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
3
5
  require 'deploy_agent'
4
6
 
5
7
  DeployAgent::CLI.new.dispatch(ARGV)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'deploy-agent'
5
+ s.version = '1.3.3'
6
+ s.required_ruby_version = '>= 2.7'
7
+ s.summary = 'The DeployHQ Agent'
8
+ s.description = 'This gem allows you to configure a secure proxy through which DeployHQ can forward connections'
9
+ s.authors = ['Charlie Smurthwaite']
10
+ s.email = ['support@deployhq.com']
11
+ s.files = Dir.glob('{lib,bin}/**/*')
12
+ s.files << 'ca.crt'
13
+ s.files << 'deploy-agent.gemspec'
14
+ s.homepage = 'https://www.deployhq.com/'
15
+ s.bindir = 'bin'
16
+ s.executables << 'deploy-agent'
17
+
18
+ s.add_dependency 'nio4r', '2.1.0'
19
+ s.add_dependency 'rb-readline', '0.5.5'
20
+ s.add_dependency 'timers', '4.1.2'
21
+ end
@@ -6,6 +6,10 @@ require 'logger'
6
6
 
7
7
  module DeployAgent
8
8
  class Agent
9
+ def initialize(options = {})
10
+ @retries = 0
11
+ @options = options
12
+ end
9
13
 
10
14
  def run
11
15
  nio_selector = NIO::Selector.new
@@ -21,22 +25,40 @@ module DeployAgent
21
25
  monitor.value.tx_data if monitor.writeable?
22
26
  end
23
27
  timers.fire
28
+
29
+ @retries = 0
30
+ end
31
+ rescue OpenSSL::SSL::SSLError => e
32
+ @retries += 1
33
+
34
+ if @retries == 4
35
+ raise e
36
+ else
37
+ retry
24
38
  end
25
39
  rescue ServerConnection::ServerDisconnected
26
40
  retry
41
+ rescue Interrupt, SignalException => e
42
+ logger.info("Stopping")
43
+ rescue Exception => e
44
+ logger.debug("#{e.class}: #{e.message}")
45
+ raise e
27
46
  end
28
47
 
29
48
  def logger
30
49
  @logger ||= begin
31
50
  if $background
32
51
  logger = Logger.new(LOG_PATH, 5, 10240)
33
- logger.level = Logger::INFO
34
- logger
35
52
  else
36
- Logger.new(STDOUT)
53
+ logger = Logger.new(STDOUT)
37
54
  end
55
+ logger.level = @options[:verbose] ? Logger::DEBUG : Logger::INFO
56
+ logger
38
57
  end
39
58
  end
40
59
 
60
+ private
61
+
62
+ attr_reader :options
41
63
  end
42
64
  end
@@ -1,10 +1,20 @@
1
1
  require 'ipaddr'
2
+ require 'optparse'
2
3
 
3
4
  module DeployAgent
4
5
  class CLI
5
6
 
6
7
  def dispatch(arguments)
7
8
  methods = self.public_methods(false).delete_if { |n| n == :dispatch }.sort
9
+
10
+ @options = {}
11
+
12
+ OptionParser.new do |opts|
13
+ opts.on('-v', '--verbose', 'Log extra debug information') do
14
+ @options[:verbose] = true
15
+ end
16
+ end.parse!
17
+
8
18
  if arguments[0] && methods.include?(arguments[0].to_sym)
9
19
  public_send(arguments[0])
10
20
  else
@@ -62,7 +72,7 @@ module DeployAgent
62
72
 
63
73
  def run
64
74
  ensure_configured
65
- Agent.new.run
75
+ Agent.new(@options).run
66
76
  end
67
77
 
68
78
  def accesslist
@@ -79,6 +89,10 @@ module DeployAgent
79
89
  puts "To edit the list of allowed servers, please modify " + ACCESS_PATH
80
90
  end
81
91
 
92
+ def version
93
+ puts DeployAgent::VERSION
94
+ end
95
+
82
96
  private
83
97
 
84
98
  def ensure_configured
@@ -109,7 +123,7 @@ module DeployAgent
109
123
 
110
124
  def write_pid
111
125
  File.open(PID_PATH, 'w') { |f| f.write Process.pid.to_s }
112
- at_exit { File.delete(PID_PATH) if File.exists?(PID_PATH) }
126
+ at_exit { File.delete(PID_PATH) if File.exist?(PID_PATH) }
113
127
  end
114
128
 
115
129
  end
@@ -8,6 +8,7 @@ module DeployAgent
8
8
  attr_accessor :claim_code
9
9
 
10
10
  def configure
11
+ FileUtils.mkdir_p(CONFIG_PATH)
11
12
  if File.file?(CERTIFICATE_PATH) || File.file?(ACCESS_PATH)
12
13
  puts "***************************** WARNING *****************************"
13
14
  puts "The Deploy agent has already been configured. Are you sure you wish"
@@ -79,7 +79,7 @@ module DeployAgent
79
79
  # Nothing more to send, wait for inbound data only
80
80
  @nio_monitor.interests = :r
81
81
  end
82
- rescue Errno::ECONNRESET
82
+ rescue Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETRESET
83
83
  # The backend has closed the connection. Inform the Deploy server.
84
84
  @server_connection.send_connection_close(@id)
85
85
  # Ensure everything is tidied up
@@ -91,7 +91,7 @@ module DeployAgent
91
91
  data = @tcp_socket.readpartial(10240)
92
92
  @agent.logger.debug "[#{@id}] #{data.bytesize} bytes received from destination"
93
93
  @server_connection.send_data(@id, data)
94
- rescue EOFError, Errno::ECONNRESET
94
+ rescue EOFError, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETRESET
95
95
  @agent.logger.info "[#{@id}] Destination closed connection"
96
96
  # The backend has closed the connection. Inform the Deploy server.
97
97
  @server_connection.send_connection_close(@id)
@@ -54,10 +54,17 @@ module DeployAgent
54
54
  # Receive and process packets from the control server
55
55
  def rx_data
56
56
  # Ensure all received data is read
57
- @rx_buffer << @socket.readpartial(10240)
58
- while(@socket.pending > 0)
59
- @rx_buffer << @socket.readpartial(10240)
57
+ loop do
58
+ begin
59
+ data = @socket.read_nonblock(10240)
60
+ raise EOFError if data.nil?
61
+
62
+ @rx_buffer << data
63
+ rescue IO::WaitReadable, IO::WaitWritable
64
+ break # nothing more to read
65
+ end
60
66
  end
67
+
61
68
  # Wait until we have a complete packet of data
62
69
  while @rx_buffer.bytesize >=2 && @rx_buffer.bytesize >= @rx_buffer[0,2].unpack('n')[0]
63
70
  length = @rx_buffer.slice!(0,2).unpack('n')[0]
@@ -106,7 +113,7 @@ module DeployAgent
106
113
  close
107
114
  end
108
115
  end
109
- rescue EOFError, Errno::ECONNRESET
116
+ rescue EOFError, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETRESET
110
117
  close
111
118
  end
112
119
 
@@ -144,7 +151,9 @@ module DeployAgent
144
151
 
145
152
  # Called by event loop to send all waiting packets to the Deploy server
146
153
  def tx_data
154
+ @agent.logger.debug('Writing to socket')
147
155
  bytes_sent = @socket.write_nonblock(@tx_buffer[0,1024])
156
+ @agent.logger.debug('Writing to socket completed')
148
157
  # Send as much data as possible
149
158
  if bytes_sent >= @tx_buffer.bytesize
150
159
  @tx_buffer = String.new.force_encoding('BINARY')
@@ -154,7 +163,7 @@ module DeployAgent
154
163
  # the remaining data in the send buffer
155
164
  @tx_buffer.slice!(0, bytes_sent)
156
165
  end
157
- rescue EOFError, Errno::ECONNRESET
166
+ rescue EOFError, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::ENETRESET
158
167
  close
159
168
  end
160
169
 
@@ -0,0 +1,17 @@
1
+ require "rubygems"
2
+
3
+ module DeployAgent
4
+ VERSION_FILE_PATH = File.expand_path('../../../VERSION', __FILE__)
5
+ SPEC_FILE_PATH = File.expand_path('../../../deploy-agent.gemspec', __FILE__)
6
+
7
+ if File.file?(VERSION_FILE_PATH)
8
+ VERSION = File.read(VERSION_FILE_PATH).strip.sub(/\Av/, '')
9
+ elsif File.file?(SPEC_FILE_PATH)
10
+ VERSION = Gem::Specification::load(SPEC_FILE_PATH).version.to_s
11
+ else
12
+ puts __FILE__
13
+
14
+ VERSION = '0.0.0.dev'
15
+ end
16
+
17
+ end
data/lib/deploy_agent.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'deploy_agent/version'
1
2
  require 'deploy_agent/configuration_generator'
2
3
  require 'deploy_agent/server_connection'
3
4
  require 'deploy_agent/destination_connection'
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deploy-agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
- - aTech Media
8
- autorequire:
7
+ - Charlie Smurthwaite
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2018-10-30 00:00:00.000000000 Z
10
+ date: 2025-01-08 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: nio4r
@@ -25,48 +24,34 @@ dependencies:
25
24
  - !ruby/object:Gem::Version
26
25
  version: 2.1.0
27
26
  - !ruby/object:Gem::Dependency
28
- name: timers
27
+ name: rb-readline
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - '='
32
31
  - !ruby/object:Gem::Version
33
- version: 4.1.2
32
+ version: 0.5.5
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - '='
39
38
  - !ruby/object:Gem::Version
40
- version: 4.1.2
39
+ version: 0.5.5
41
40
  - !ruby/object:Gem::Dependency
42
- name: rb-readline
41
+ name: timers
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - '='
46
45
  - !ruby/object:Gem::Version
47
- version: 0.5.4
46
+ version: 4.1.2
48
47
  type: :runtime
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - '='
53
52
  - !ruby/object:Gem::Version
54
- version: 0.5.4
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.16'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.16'
69
- description: This gem allows you to configure a secure proxy through which Deploy
53
+ version: 4.1.2
54
+ description: This gem allows you to configure a secure proxy through which DeployHQ
70
55
  can forward connections
71
56
  email:
72
57
  - support@deployhq.com
@@ -77,16 +62,17 @@ extra_rdoc_files: []
77
62
  files:
78
63
  - bin/deploy-agent
79
64
  - ca.crt
65
+ - deploy-agent.gemspec
80
66
  - lib/deploy_agent.rb
81
67
  - lib/deploy_agent/agent.rb
82
68
  - lib/deploy_agent/cli.rb
83
69
  - lib/deploy_agent/configuration_generator.rb
84
70
  - lib/deploy_agent/destination_connection.rb
85
71
  - lib/deploy_agent/server_connection.rb
72
+ - lib/deploy_agent/version.rb
86
73
  homepage: https://www.deployhq.com/
87
74
  licenses: []
88
75
  metadata: {}
89
- post_install_message:
90
76
  rdoc_options: []
91
77
  require_paths:
92
78
  - lib
@@ -94,16 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
80
  requirements:
95
81
  - - ">="
96
82
  - !ruby/object:Gem::Version
97
- version: '0'
83
+ version: '2.7'
98
84
  required_rubygems_version: !ruby/object:Gem::Requirement
99
85
  requirements:
100
86
  - - ">="
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0'
103
89
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.6.14
106
- signing_key:
90
+ rubygems_version: 3.6.2
107
91
  specification_version: 4
108
- summary: The Deploy agent
92
+ summary: The DeployHQ Agent
109
93
  test_files: []