fluent-plugin-secure-forward 0.2.0 → 0.2.1

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
  SHA1:
3
- metadata.gz: ca2356a052a35ccb1ce9a6e1e06aefdaaf58fd37
4
- data.tar.gz: 3733590e3818bbbdbc7f92a11a609639e0d19fca
3
+ metadata.gz: 6b0eb8491c4513104e1db78902eac9cfa5a4c28e
4
+ data.tar.gz: 903b7d2ca23e3ed23a6843475a2f0de546e59656
5
5
  SHA512:
6
- metadata.gz: b2f8f19e8550dec4e7b9eff6ec47b030ae5d77e04fc0cbeabc39ff42ba865382839359bb3bf648120c388cfce0357b767b9b767887a336491042e1233095f355
7
- data.tar.gz: e41959d32c7370796154763a0d8314270255f02d738ed3a1f8253f6f7555dc5b6b17040fd4c5aaf99ae82f3fc6b833491f0962c188bb7752355093289d59004e
6
+ metadata.gz: 27b2fb512c94a613c12300befce152fb4511ffcea9970ef8d32c33327b34923fbed585d43b3e2fad5322f2262a4af1833180815daeece2e0507c75fd6e828a99
7
+ data.tar.gz: 58dab1197ea8bf022d1f0dcce7858a0574d55781bac15ec8186c7f95e88950733160cd679c4ec928898104b32e2ab78c118df224f111857e618aeb5623e65706
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-secure-forward"
4
- gem.version = "0.2.0"
4
+ gem.version = "0.2.1"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.summary = %q{Fluentd input/output plugin to forward over SSL with authentications}
@@ -129,17 +129,19 @@ module Fluent
129
129
  node.start
130
130
  end
131
131
  @nodewatcher = Thread.new(&method(:node_watcher))
132
+ @nodewatcher.abort_on_exception = true
132
133
  end
133
134
 
134
135
  def node_watcher
135
136
  reconnectings = Array.new(@nodes.size)
137
+ nodes_size = @nodes.size
136
138
 
137
139
  loop do
138
140
  sleep @reconnect_interval
139
141
 
140
142
  log.trace "in node health watcher"
141
143
 
142
- (0...(@nodes.size)).each do |i|
144
+ (0...nodes_size).each do |i|
143
145
  log.trace "node health watcher for #{@nodes[i].host}"
144
146
 
145
147
  next if @nodes[i].established? && ! @nodes[i].expired?
@@ -152,26 +154,24 @@ module Fluent
152
154
  log.debug "reconnecting to node", :host => node.host, :port => node.port, :expire => node.expire, :expired => node.expired?
153
155
 
154
156
  renewed = node.dup
155
- begin
156
- renewed.start
157
- Thread.pass # to connection thread
158
- reconnectings[i] = { :conn => renewed, :at => Time.now }
159
- rescue => e
160
- log.debug "Some error occured on start of renewed connection", :error_class => e2.class, :error => e2, :host => renewed.host, :port => renewed.port
161
- end
157
+ renewed.start
158
+
159
+ Thread.pass # to connection thread
160
+ reconnectings[i] = { :conn => renewed, :at => Time.now }
162
161
  end
163
162
 
164
- (0...(reconnectings.size)).each do |i|
163
+ (0...nodes_size).each do |i|
165
164
  next unless reconnectings[i]
166
165
 
166
+ log.trace "checking reconnecting node #{reconnectings[i][:conn].host}"
167
+
167
168
  if reconnectings[i][:conn].established?
169
+ log.debug "connection established for reconnecting node"
168
170
  oldconn = @nodes[i]
169
171
  @nodes[i] = reconnectings[i][:conn]
170
- begin
171
- oldconn.shutdown
172
- rescue => e
173
- log.debug "Some error occured on shutdown of expired connection", :error_class => e.class, :error => e, :host => renewed.host, :port => renewed.port
174
- end
172
+ log.trace "old connection shutting down"
173
+ oldconn.shutdown if oldconn # connection object doesn't raise any exceptions
174
+ log.trace "old connection shutted down"
175
175
 
176
176
  reconnectings[i] = nil
177
177
  next
@@ -179,17 +179,13 @@ module Fluent
179
179
 
180
180
  # not connected yet
181
181
 
182
- next if reconnectings[i][:at] < Time.now + @established_timeout
182
+ next if reconnectings[i][:at] + @established_timeout > Time.now
183
183
 
184
184
  # not connected yet, and timeout
185
- begin
186
- timeout_conn = reconnectings[i][:conn]
187
- log.debug "SSL connection is not established until timemout", :host => timeout_conn.host, :port => timeout_conn.port, :timeout => @established_timeout
188
- reconnectings[i] = nil
189
- timeout_conn.shutdown
190
- rescue => e
191
- log.debug "Some error occured on shutdown of timeout re-connection", :error_class => e.class, :error => e
192
- end
185
+ timeout_conn = reconnectings[i][:conn]
186
+ log.debug "SSL connection is not established until timemout", :host => timeout_conn.host, :port => timeout_conn.port, :timeout => @established_timeout
187
+ reconnectings[i] = nil
188
+ timeout_conn.shutdown if timeout_conn # connection object doesn't raise any exceptions
193
189
  end
194
190
  end
195
191
  end
@@ -59,6 +59,8 @@ class Fluent::SecureForwardOutput::Node
59
59
 
60
60
  def start
61
61
  @thread = Thread.new(&method(:connect))
62
+ ## If you want to check code bug, turn this line enable
63
+ # @thread.abort_on_exception = true
62
64
  end
63
65
 
64
66
  def shutdown
@@ -189,7 +191,13 @@ class Fluent::SecureForwardOutput::Node
189
191
 
190
192
  addr = @sender.hostname_resolver.getaddress(@host)
191
193
  log.debug "create tcp socket to node", :host => @host, :address => addr, :port => @port
192
- sock = TCPSocket.new(addr, @port)
194
+ begin
195
+ sock = TCPSocket.new(addr, @port)
196
+ rescue => e
197
+ log.warn "failed to connect for secure-forward", :error_class => e.class, :error => e, :host => @host, :address => addr, :port => @port
198
+ @state = :failed
199
+ return
200
+ end
193
201
 
194
202
  log.trace "changing socket options"
195
203
  opt = [1, @sender.send_timeout.to_i].pack('I!I!') # { int l_onoff; int l_linger; }
@@ -204,10 +212,18 @@ class Fluent::SecureForwardOutput::Node
204
212
  # TODO: context.ca_file = (ca_file_path)
205
213
  # TODO: context.ciphers = (SSL Shared key chiper protocols)
206
214
 
207
- log.debug "trying to connect ssl session", :host => @host, :ipaddr => addr, :port => @port
208
- sslsession = OpenSSL::SSL::SSLSocket.new(sock, context)
209
- # TODO: check connection failure
210
- sslsession.connect
215
+ log.debug "trying to connect ssl session", :host => @host, :address => addr, :port => @port
216
+ begin
217
+ sslsession = OpenSSL::SSL::SSLSocket.new(sock, context)
218
+ rescue => e
219
+ log.warn "failed to establish SSL connection", :host => @host, :address => addr, :port => @port
220
+ end
221
+
222
+ unless sslsession.connect
223
+ log.debug "failed to connect", :host => @host, :address => addr, :port => @port
224
+ @state = :failed
225
+ return
226
+ end
211
227
  log.debug "ssl session connected", :host => @host, :port => @port
212
228
 
213
229
  begin
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-secure-forward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-29 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -126,4 +126,3 @@ test_files:
126
126
  - test/plugin/test_in_secure_forward.rb
127
127
  - test/plugin/test_input_session.rb
128
128
  - test/plugin/test_out_secure_forward.rb
129
- has_rdoc: