fluent-plugin-syslog-gobi-tls 2.1.27 → 2.1.29

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
2
  SHA256:
3
- metadata.gz: 05dba789739e7d17d93ec0b6834f44f483c81110c0b7a3049b05d4363f4887c6
4
- data.tar.gz: bebec7c5ce38b10f59703fb198a36cbcfe9f288f56185ad1731c917ddcc02be6
3
+ metadata.gz: 3cd2b97fbf5538d79f925edfa2231254929ad80295ef137ddd1f6f18dc38ebd7
4
+ data.tar.gz: 708b7e494707863e469776e94c942f81d556c2b6ccdb84c7d5d24ee244ce8eb6
5
5
  SHA512:
6
- metadata.gz: 0271e8be2d6a57ae2ebea8f4141a7c621e07840e06c884317f6fb0d5a04d53d8f9f80aa61672c254d14861f2967e5e27a4fb2c6d68da589f895e3950c8cf27a8
7
- data.tar.gz: e3d831b0a3cdeffce687482a6bc8b22ed6882c69404b7b808d785439b214ce459f0b87712f192276c5838fa938973ea894e26cec0b8c54fdac622c180288f973
6
+ metadata.gz: a2b97e8aad0a0414ea98e9c31d2e59fa767333f3b15133fcbf702304e80bef1982745ddea8f7a191ab7f32fc29c437f8da679c1188f1285c95b533e4b12cfbd7
7
+ data.tar.gz: fb54c28711b00c1bdf00ef0e38f7c4609e4f7091ae87d8243e11bdf326b59de4d3aca0c6acab5384539e15c7fa4a17ae6cbdab78863d7c2d0143a6dedbf42ca3
data/.gitignore CHANGED
@@ -37,3 +37,4 @@ build/
37
37
 
38
38
  ## System
39
39
  .DS_Store
40
+ .vscode
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-syslog-tls (2.1.0.rc1)
4
+ fluent-plugin-syslog-tls (2.1.0)
5
5
  fluentd (>= 0.14.0, < 2)
6
6
 
7
7
  GEM
@@ -9,35 +9,41 @@ GEM
9
9
  specs:
10
10
  addressable (2.8.1)
11
11
  public_suffix (>= 2.0.2, < 6.0)
12
- concurrent-ruby (1.1.10)
13
- cool.io (1.7.1)
12
+ base64 (0.2.0)
13
+ concurrent-ruby (1.2.3)
14
+ cool.io (1.8.0)
14
15
  crack (0.4.5)
15
16
  rexml
17
+ csv (3.3.0)
16
18
  docile (1.4.0)
17
- fluentd (1.15.3)
19
+ drb (2.2.1)
20
+ fluentd (1.17.0)
21
+ base64 (~> 0.2)
18
22
  bundler
19
23
  cool.io (>= 1.4.5, < 2.0.0)
24
+ csv (~> 3.2)
25
+ drb (~> 2.2)
20
26
  http_parser.rb (>= 0.5.1, < 0.9.0)
21
27
  msgpack (>= 1.3.1, < 2.0.0)
22
- serverengine (>= 2.3.0, < 3.0.0)
23
- sigdump (~> 0.2.2)
28
+ serverengine (>= 2.3.2, < 3.0.0)
29
+ sigdump (~> 0.2.5)
24
30
  strptime (>= 0.2.4, < 1.0.0)
25
31
  tzinfo (>= 1.0, < 3.0)
26
32
  tzinfo-data (~> 1.0)
27
- webrick (>= 1.4.2, < 1.8.0)
33
+ webrick (~> 1.4)
28
34
  yajl-ruby (~> 1.0)
29
35
  hashdiff (1.0.1)
30
36
  http_parser.rb (0.8.0)
31
37
  minitest (5.17.0)
32
38
  minitest-stub_any_instance (1.0.3)
33
- msgpack (1.6.0)
39
+ msgpack (1.7.2)
34
40
  power_assert (2.0.3)
35
41
  public_suffix (5.0.1)
36
42
  rake (13.0.6)
37
43
  rexml (3.2.5)
38
- serverengine (2.3.1)
44
+ serverengine (2.3.2)
39
45
  sigdump (~> 0.2.2)
40
- sigdump (0.2.4)
46
+ sigdump (0.2.5)
41
47
  simplecov (0.22.0)
42
48
  docile (~> 1.1)
43
49
  simplecov-html (~> 0.11)
@@ -47,15 +53,15 @@ GEM
47
53
  strptime (0.2.5)
48
54
  test-unit (3.5.7)
49
55
  power_assert
50
- tzinfo (2.0.5)
56
+ tzinfo (2.0.6)
51
57
  concurrent-ruby (~> 1.0)
52
- tzinfo-data (1.2022.7)
58
+ tzinfo-data (1.2024.1)
53
59
  tzinfo (>= 1.0.0)
54
60
  webmock (3.18.1)
55
61
  addressable (>= 2.8.0)
56
62
  crack (>= 0.3.2)
57
63
  hashdiff (>= 0.4.0, < 2.0.0)
58
- webrick (1.7.0)
64
+ webrick (1.8.1)
59
65
  yajl-ruby (1.4.3)
60
66
 
61
67
  PLATFORMS
@@ -19,10 +19,10 @@ require 'syslog_tls/version'
19
19
 
20
20
  Gem::Specification.new do |s|
21
21
  s.name = 'fluent-plugin-syslog-gobi-tls'
22
- s.version = '2.1.27'
23
- s.summary = %q{Fluent Syslog TLS output plugin}
22
+ s.version = '2.1.29'
24
23
  s.authors = ['thomas morgan']
25
24
  s.email = ['tm@iprog.com']
25
+ s.summary = %q{Fluent Syslog TLS output plugin}
26
26
  s.description = %q{Syslog TLS output plugin with formatting support, for Fluentd}
27
27
  s.homepage = 'https://github.com/zarqman/fluent-plugin-syslog-tls'
28
28
  s.license = 'Apache v2'
@@ -16,6 +16,48 @@
16
16
  require 'socket'
17
17
  require 'syslog_tls/logger'
18
18
  require 'fluent/plugin/output'
19
+ require 'syslog_tls/host_backoff_specs'
20
+ require 'pp'
21
+
22
+ $host_backoff_specs_list = []
23
+
24
+ def add_host_backoff_spec(retries_to_do, host_ip_port)
25
+ # Check if an element with the same hostIPport already exists
26
+ return if $host_backoff_specs_list.any? { |spec| spec.hostIPport == host_ip_port }
27
+
28
+ # If not, add a new HostBackoffSpecs instance to the global array
29
+ $host_backoff_specs_list << ::SyslogTls::HostBackoffSpecs.new(retries_to_do, host_ip_port)
30
+ end
31
+
32
+ def can_write(host_ip_port)
33
+ begin
34
+ $host_backoff_specs_list.each do |backoff_specs|
35
+ if backoff_specs.hostIPport == host_ip_port
36
+ return backoff_specs.canwrite
37
+ end
38
+ end
39
+ rescue => e
40
+ pp "Error in can_write: #{e.message}"
41
+ return 0
42
+ end
43
+ return 1
44
+ end
45
+
46
+ def increase_retry(host_ip_port)
47
+ $host_backoff_specs_list.each do |backoff_specs|
48
+ if backoff_specs.hostIPport == host_ip_port
49
+ backoff_specs.failtowrite
50
+ end
51
+ end
52
+ end
53
+
54
+ def reset_tries(host_ip_port)
55
+ $host_backoff_specs_list.each do |backoff_specs|
56
+ if backoff_specs.hostIPport == host_ip_port
57
+ backoff_specs.resetRetries
58
+ end
59
+ end
60
+ end
19
61
 
20
62
  module Fluent::Plugin
21
63
  class SyslogTlsOutput < Output
@@ -82,6 +124,8 @@ module Fluent::Plugin
82
124
  @mappings[key_name] = conf[conf_key] if conf.key?(conf_key)
83
125
  end
84
126
 
127
+ add_host_backoff_spec(0, conf['host']+":"+conf['port'])
128
+
85
129
  @formatter = formatter_create(conf: conf.elements('format').first, default_type: DEFAULT_FORMAT_TYPE)
86
130
  end
87
131
 
@@ -15,6 +15,7 @@
15
15
 
16
16
  require 'socket'
17
17
  require 'openssl'
18
+ require 'pp'
18
19
 
19
20
  module SyslogTls
20
21
  # Supports SSL connection to remote host
@@ -39,27 +40,17 @@ module SyslogTls
39
40
  @verify_cert_name = verify_cert_name
40
41
  @ssl_version = ssl_version
41
42
  @retries = max_retries
42
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
43
- puts "[#{timestamp}] in initialize: #{idle_timeout}"
44
43
  connect
45
44
  end
46
45
 
47
46
  def connect
48
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
49
- puts "[#{timestamp}] in connect"
50
47
  @socket = get_ssl_connection
51
48
  begin
52
49
  begin
53
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
54
- puts "[#{timestamp}] in connect doing connect_nonblock"
55
50
  @socket.connect_nonblock
56
- rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable => e
57
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
58
- puts "[#{timestamp}] in connect EAGAIN rescue: #{e.class} exception #{e.message} "
51
+ rescue Errno::EAGAIN, Errno::EWOULDBLOCK, IO::WaitReadable
59
52
  select_with_timeout(@socket, :connect_read) && retry
60
- rescue IO::WaitWritable => e
61
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
62
- puts "[#{timestamp}] in connect WaitWritable rescue: #{e.class} exception #{e.message} "
53
+ rescue IO::WaitWritable
63
54
  select_with_timeout(@socket, :connect_write) && retry
64
55
  end
65
56
  rescue Errno::ETIMEDOUT
@@ -69,54 +60,30 @@ module SyslogTls
69
60
  end
70
61
 
71
62
  def get_tcp_connection
72
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
73
- puts "[#{timestamp}] in get_tcp_connection"
74
63
  tcp = nil
75
64
 
76
65
  family = Socket::Constants::AF_UNSPEC
77
66
  sock_type = Socket::Constants::SOCK_STREAM
78
67
  addr_info = Socket.getaddrinfo(host, port, family, sock_type, nil, nil, false).first
79
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
80
- puts "[#{timestamp}] in get_tcp_connection addr_info: #{addr_info}"
81
68
  _, port, _, address, family, sock_type = addr_info
82
69
 
83
70
  begin
84
71
  sock_addr = Socket.sockaddr_in(port, address)
85
72
  tcp = Socket.new(family, sock_type, 0)
86
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
87
- puts "[#{timestamp}] in get_tcp_connection tcp: #{tcp}"
88
73
  tcp.setsockopt(Socket::SOL_SOCKET, Socket::Constants::SO_REUSEADDR, true)
89
74
  tcp.setsockopt(Socket::SOL_SOCKET, Socket::Constants::SO_REUSEPORT, true)
90
75
  tcp.connect_nonblock(sock_addr)
91
- rescue Errno::ECONNREFUSED => e
92
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
93
- puts "[#{timestamp}] in get_tcp_connection ECONNREFUSED exception during TCP connection:"
94
- tcp.close rescue nil
95
- raise
96
- rescue Errno::EINPROGRESS => e
97
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
98
- puts "[#{timestamp}] in get_tcp_connection EINPROGRESS exception during TCP connection:"
99
- puts "[#{timestamp}] Message: #{e.message}"
76
+ rescue Errno::EINPROGRESS
100
77
  select_with_timeout(tcp, :connect_write)
101
78
  begin
102
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
103
- puts "[#{timestamp}] in get_tcp_connection after select_with_timeout"
104
79
  tcp.connect_nonblock(sock_addr)
105
80
  rescue Errno::EISCONN
106
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
107
- puts "[#{timestamp}] in get_tcp_connection in EISCONN"
108
81
  # all good
109
- rescue SystemCallError => e
110
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
111
- puts "[#{timestamp}] in get_tcp_connection SystemCallError exception during TCP connection:"
112
- puts "[#{timestamp}] Message: #{e.message}"
82
+ rescue SystemCallError
113
83
  tcp.close rescue nil
114
84
  raise
115
85
  end
116
- rescue SystemCallError => e
117
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
118
- puts "[#{timestamp}] in get_tcp_connection SystemCallError outer exception during TCP connection:"
119
- puts "[#{timestamp}] Message: #{e.message}"
86
+ rescue SystemCallError
120
87
  tcp.close rescue nil
121
88
  raise
122
89
  end
@@ -126,8 +93,6 @@ module SyslogTls
126
93
  end
127
94
 
128
95
  def get_ssl_connection
129
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
130
- puts "[#{timestamp}] in get_ssl_connection"
131
96
  tcp = get_tcp_connection
132
97
 
133
98
  ctx = OpenSSL::SSL::SSLContext.new
@@ -202,6 +167,8 @@ module SyslogTls
202
167
  end
203
168
 
204
169
  def select_with_timeout(tcp, type)
170
+ host_ip_port = host + ":" + port.to_s
171
+
205
172
  case type
206
173
  when :connect_read
207
174
  args = [[tcp], nil, nil, CONNECT_TIMEOUT]
@@ -214,14 +181,15 @@ module SyslogTls
214
181
  else
215
182
  raise "Unknown select type #{type}"
216
183
  end
217
- # IO.select(*args) || raise("Socket timeout during #{type}")
218
- begin
219
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
220
- select1 = IO.select(*args)
221
- puts "[#{timestamp}] in select_with_timeout: #{select1}"
222
- rescue IOError => e
223
- timestamp = Time.now.strftime("%Y-%m-%d %H:%M:%S")
224
- puts "[#{timestamp}] Error in select_with_timeout: #{e.message}"
184
+ if can_write(host_ip_port) == 1
185
+ if IO.select(*args)
186
+ reset_tries(host_ip_port)
187
+ else
188
+ increase_retry(host_ip_port)
189
+ raise("Socket timeout during #{type}")
190
+ end
191
+ else
192
+ raise("Failed to write #{type}")
225
193
  end
226
194
  end
227
195
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-syslog-gobi-tls
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.27
4
+ version: 2.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-11 00:00:00.000000000 Z
11
+ date: 2024-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
- rubygems_version: 3.2.3
168
+ rubygems_version: 3.1.2
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: Fluent Syslog TLS output plugin