Skip to content

Commit

Permalink
Support IPv6 UDP sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
UXabre committed Oct 7, 2019
1 parent 299f935 commit 31d46cc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/logstash/inputs/syslog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class LogStash::Inputs::Syslog < LogStash::Inputs::Base
default :codec, "plain"

# The address to listen on.
config :host, :validate => :string, :default => "0.0.0.0"
config :host, :validate => :string, :default => "::"

# The port to listen on. Remember that ports less than 1024 (privileged
# ports) may require root to use.
Expand Down Expand Up @@ -145,7 +145,12 @@ def udp_listener(output_queue)
@logger.info("Starting syslog udp listener", :address => "#{@host}:#{@port}")

@udp.close if @udp
@udp = UDPSocket.new(Socket::AF_INET)
if IPAddr.new(@host).ipv6?
@udp = UDPSocket.new(Socket::AF_INET6)
elsif IPAddr.new(@host).ipv4?
@udp = UDPSocket.new(Socket::AF_INET)
end

@udp.bind(@host, @port)

while !stop?
Expand Down

0 comments on commit 31d46cc

Please sign in to comment.