logstash-input-tcp 5.0.2-java → 5.0.3-java
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 +5 -5
- data/CHANGELOG.md +6 -0
- data/lib/logstash/inputs/tcp.rb +9 -6
- data/lib/logstash/inputs/tcp/decoder_impl.rb +5 -1
- data/logstash-input-tcp.gemspec +2 -1
- data/spec/inputs/tcp_spec.rb +40 -2
- data/vendor/jar-dependencies/org/logstash/inputs/logstash-input-tcp/{5.0.2/logstash-input-tcp-5.0.2.jar → 5.0.3/logstash-input-tcp-5.0.3.jar} +0 -0
- data/version +1 -1
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e583a67a7f5b0fe1ea4b0e800a43102f82431cfd1b57f54213d7306a6d35366e
|
4
|
+
data.tar.gz: b9818207449346d5f863b0edf5fdc5cd29ab1660bec6c0ba056a7b70a803901a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0c0e58436f8d2c1049abb53a8f31cbb1cb3db84587c3a6c93b0f5929f3912dffd54420472b8ded67997ba9a81a72dd5db3cd3c61f970e266e79afd2258fb19
|
7
|
+
data.tar.gz: 2e0433042a7af1d19c1c87e07686b32b733f13622034c20ae10470d994b3b5dd1a4c4ed81575813e3c5acbb58854a1a12142a4c419744e29e92e5fe4893bea18
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 5.0.3
|
2
|
+
- Fix bug where codec was not flushed when client disconnected
|
3
|
+
- Restore INFO logging statement on startup
|
4
|
+
- Fixed typo in @metadata tag
|
5
|
+
- Update gemspec summary
|
6
|
+
|
1
7
|
## 5.0.2
|
2
8
|
- Fix bug where this input would crash logstash during some socket reads when acting as an SSL server
|
3
9
|
|
data/lib/logstash/inputs/tcp.rb
CHANGED
@@ -106,7 +106,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
106
106
|
config :ssl_extra_chain_certs, :validate => :array, :default => []
|
107
107
|
|
108
108
|
HOST_FIELD = "host".freeze
|
109
|
-
HOST_IP_FIELD = "[@
|
109
|
+
HOST_IP_FIELD = "[@metadata][ip_address]".freeze
|
110
110
|
PORT_FIELD = "port".freeze
|
111
111
|
PROXY_HOST_FIELD = "proxy_host".freeze
|
112
112
|
PROXY_PORT_FIELD = "proxy_port".freeze
|
@@ -135,6 +135,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
135
135
|
# in the close method even if we also close it in the stop method since we could have
|
136
136
|
# a situation where register is called but not run & stop.
|
137
137
|
|
138
|
+
@logger.info("Starting tcp input listener", :address => "#{@host}:#{@port}", :ssl_enable => "#{@ssl_enable}")
|
138
139
|
if server?
|
139
140
|
if @ssl_enable
|
140
141
|
self.server_socket = new_server_socket
|
@@ -187,6 +188,12 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
191
|
+
def flush_codec(codec, client_ip_address, client_address, client_port)
|
192
|
+
codec.flush do |event|
|
193
|
+
enqueue_decorated(event, client_ip_address, client_address, client_port)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
190
197
|
private
|
191
198
|
|
192
199
|
RUN_LOOP_ERROR_MESSAGE="TCP input server encountered error"
|
@@ -277,10 +284,7 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
277
284
|
ensure
|
278
285
|
# catch all rescue nil on close to discard any close errors or invalid socket
|
279
286
|
socket.close rescue nil
|
280
|
-
|
281
|
-
codec.respond_to?(:flush) && codec.flush do |event|
|
282
|
-
enqueue_decorated(event, client_ip_address, client_address, client_port)
|
283
|
-
end
|
287
|
+
flush_codec(codec, client_ip_address, client_address, client_port)
|
284
288
|
end
|
285
289
|
|
286
290
|
def enqueue_decorated(event, client_ip_address, client_address, client_port)
|
@@ -324,7 +328,6 @@ class LogStash::Inputs::Tcp < LogStash::Inputs::Base
|
|
324
328
|
end
|
325
329
|
|
326
330
|
def new_server_socket
|
327
|
-
@logger.info("Starting tcp input listener", :address => "#{@host}:#{@port}")
|
328
331
|
begin
|
329
332
|
socket = TCPServer.new(@host, @port)
|
330
333
|
rescue Errno::EADDRINUSE
|
@@ -25,10 +25,14 @@ class DecoderImpl
|
|
25
25
|
@proxy_address, @proxy_port, tbuf)
|
26
26
|
end
|
27
27
|
|
28
|
-
def copy
|
28
|
+
def copy
|
29
29
|
DecoderImpl.new(@codec.clone, @tcp)
|
30
30
|
end
|
31
31
|
|
32
|
+
def flush
|
33
|
+
@tcp.flush_codec(@codec, @ip_address, @address, @port)
|
34
|
+
end
|
35
|
+
|
32
36
|
private
|
33
37
|
def init_first_read(channel_addr, received)
|
34
38
|
if @tcp.proxy_protocol
|
data/logstash-input-tcp.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'logstash-input-tcp'
|
3
3
|
s.version = ::File.read('version').split("\n").first
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
|
-
s.summary = "
|
5
|
+
s.summary = "Reads events from a TCP socket"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
7
7
|
s.authors = ["Elastic"]
|
8
8
|
s.email = 'info@elastic.co'
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_runtime_dependency 'logstash-codec-line'
|
30
30
|
s.add_runtime_dependency 'logstash-codec-json'
|
31
31
|
s.add_runtime_dependency 'logstash-codec-json_lines'
|
32
|
+
s.add_runtime_dependency 'logstash-codec-multiline'
|
32
33
|
|
33
34
|
s.add_development_dependency 'logstash-devutils'
|
34
35
|
s.add_development_dependency 'flores', '~> 0.0.6'
|
data/spec/inputs/tcp_spec.rb
CHANGED
@@ -72,11 +72,12 @@ describe LogStash::Inputs::Tcp do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
insist { events.length } == event_count
|
75
|
+
events = events.sort_by {|e| e.get("message")} # the ordering of events in the queue is highly timing-dependent
|
75
76
|
event_count.times do |i|
|
76
77
|
event = events[i]
|
77
78
|
insist { event.get("message") } == "#{i} ☹"
|
78
|
-
insist { event.get("host") }
|
79
|
-
insist { event.get("[@
|
79
|
+
insist { ["localhost","ip6-localhost"].includes? event.get("host") }
|
80
|
+
insist { event.get("[@metadata][ip_address]") } == '127.0.0.1'
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -106,6 +107,7 @@ describe LogStash::Inputs::Tcp do
|
|
106
107
|
end
|
107
108
|
|
108
109
|
insist { events.length } == event_count
|
110
|
+
events = events.sort_by {|e| e.get("message")} # the ordering of events in the queue is highly timing-dependent
|
109
111
|
event_count.times do |i|
|
110
112
|
insist { events[i].get("message") } == "#{i} ☹"
|
111
113
|
insist { events[i].get("host") } == "1.2.3.4"
|
@@ -231,6 +233,7 @@ describe LogStash::Inputs::Tcp do
|
|
231
233
|
(1..event_count).map{queue.pop}
|
232
234
|
end
|
233
235
|
|
236
|
+
events = events.sort_by {|e| e.get("idx")} # the ordering of events in the queue is highly timing-dependent
|
234
237
|
events.each_with_index do |event, idx|
|
235
238
|
insist { event.get("hello") } == data["hello"]
|
236
239
|
insist { event.get("foo").to_a } == data["foo"] # to_a to cast Java ArrayList produced by JrJackson
|
@@ -266,6 +269,41 @@ describe LogStash::Inputs::Tcp do
|
|
266
269
|
end
|
267
270
|
end
|
268
271
|
|
272
|
+
it "should flush codec after client disconnects" do
|
273
|
+
# verifies fix for https://github.com/logstash-plugins/logstash-input-tcp/issues/90
|
274
|
+
conf = <<-CONFIG
|
275
|
+
input {
|
276
|
+
tcp {
|
277
|
+
port => #{port}
|
278
|
+
codec => multiline {
|
279
|
+
pattern => "^\s"
|
280
|
+
what => "previous"
|
281
|
+
}
|
282
|
+
}
|
283
|
+
}
|
284
|
+
CONFIG
|
285
|
+
|
286
|
+
data = "a\n 1\n 2\nb\n 1"
|
287
|
+
event_count = 2
|
288
|
+
|
289
|
+
events = input(conf) do |pipeline, queue|
|
290
|
+
socket = Stud::try(5.times) { TCPSocket.new("127.0.0.1", port) }
|
291
|
+
socket.puts(data)
|
292
|
+
socket.close
|
293
|
+
|
294
|
+
# If the codec is not properly flushed, there will be only one event and the second call to queue.pop
|
295
|
+
# will block indefinitely. Wrapping this with a timeout ensures that failure mode does not hang the
|
296
|
+
# test.
|
297
|
+
Timeout.timeout(5) do
|
298
|
+
event_count.times.collect do
|
299
|
+
queue.pop
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
expect(events.length).to equal(event_count)
|
305
|
+
end
|
306
|
+
|
269
307
|
# below are new specs added in the context of the shutdown semantic refactor.
|
270
308
|
# TODO:
|
271
309
|
# - refactor all specs using this new model
|
Binary file
|
data/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.0.
|
1
|
+
5.0.3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-tcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,20 @@ dependencies:
|
|
86
86
|
- - ">="
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
name: logstash-codec-multiline
|
96
|
+
prerelease: false
|
97
|
+
type: :runtime
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
104
|
requirement: !ruby/object:Gem::Requirement
|
91
105
|
requirements:
|
@@ -128,7 +142,9 @@ dependencies:
|
|
128
142
|
- - "~>"
|
129
143
|
- !ruby/object:Gem::Version
|
130
144
|
version: 0.0.22
|
131
|
-
description: This gem is a Logstash plugin required to be installed on top of the
|
145
|
+
description: This gem is a Logstash plugin required to be installed on top of the
|
146
|
+
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
147
|
+
gem is not a stand-alone program
|
132
148
|
email: info@elastic.co
|
133
149
|
executables: []
|
134
150
|
extensions: []
|
@@ -147,7 +163,7 @@ files:
|
|
147
163
|
- logstash-input-tcp.gemspec
|
148
164
|
- spec/inputs/tcp_spec.rb
|
149
165
|
- spec/spec_helper.rb
|
150
|
-
- vendor/jar-dependencies/org/logstash/inputs/logstash-input-tcp/5.0.
|
166
|
+
- vendor/jar-dependencies/org/logstash/inputs/logstash-input-tcp/5.0.3/logstash-input-tcp-5.0.3.jar
|
151
167
|
- version
|
152
168
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
153
169
|
licenses:
|
@@ -172,10 +188,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
188
|
version: '0'
|
173
189
|
requirements: []
|
174
190
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.6.13
|
176
192
|
signing_key:
|
177
193
|
specification_version: 4
|
178
|
-
summary:
|
194
|
+
summary: Reads events from a TCP socket
|
179
195
|
test_files:
|
180
196
|
- spec/inputs/tcp_spec.rb
|
181
197
|
- spec/spec_helper.rb
|