Skip to content

Commit

Permalink
Updated the file to be compatible with 6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmucr committed Sep 4, 2020
1 parent 831f2b9 commit 1dc9a3d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/logstash/outputs/tcp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ class LogStash::Outputs::Tcp < LogStash::Outputs::Base
# SSL key passphrase
config :ssl_key_passphrase, :validate => :password, :default => nil

config :message_format, :validate => :string, :obsolete => "This setting is obsolete. The event will be formatted according to the codec used"

class Client
public
def initialize(socket, logger)
Expand Down Expand Up @@ -85,8 +83,12 @@ def setup_ssl
require "openssl"

@ssl_context = OpenSSL::SSL::SSLContext.new
@ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
@ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase)
if @ssl_cert
@ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(@ssl_cert))
if @ssl_key
@ssl_context.key = OpenSSL::PKey::RSA.new(File.read(@ssl_key),@ssl_key_passphrase)
end
end
if @ssl_verify
@cert_store = OpenSSL::X509::Store.new
# Load the system default certificate path to the store
Expand Down Expand Up @@ -150,8 +152,8 @@ def register
begin
client_socket = connect unless client_socket
r,w,e = IO.select([client_socket], [client_socket], [client_socket], nil)
loop do
break if !r.any?
# Read everything first
while r.any? do
# don't expect any reads, but a readable socket might
# mean the remote end closed, so read it and throw it away.
# we'll get an EOFError if it happens.
Expand All @@ -162,7 +164,7 @@ def register
# Now send the payload
client_socket.syswrite(payload) if w.any?
rescue => e
@logger.warn("tcp output exception", :host => @host, :port => @port,
@logger.warn("tcp output exception, will retry", :host => @host, :port => @port,
:exception => e, :backtrace => e.backtrace)
client_socket.close rescue nil
client_socket = nil
Expand Down Expand Up @@ -204,4 +206,4 @@ def server?
def receive(event)
@codec.encode(event)
end # def receive
end # class LogStash::Outputs::Tcp
end # class LogStash::Outputs::Tcp

0 comments on commit 1dc9a3d

Please sign in to comment.