From 44104f1e594959ab4278d865cf31bf4a4f3d9357 Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Mon, 13 Apr 2015 06:16:04 -0400 Subject: [PATCH 1/2] Rolled UDP port support back to v4 only. --- TimberWinR/Inputs/UdpInputListener.cs | 43 +++++++++++---------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/TimberWinR/Inputs/UdpInputListener.cs b/TimberWinR/Inputs/UdpInputListener.cs index d7f0cd7..728e387 100644 --- a/TimberWinR/Inputs/UdpInputListener.cs +++ b/TimberWinR/Inputs/UdpInputListener.cs @@ -13,8 +13,8 @@ namespace TimberWinR.Inputs { public class UdpInputListener : InputListener { - private UdpClient _udpListenerV6; - private readonly Thread _listenThreadV6; + private UdpClient _udpListenerV4; + private readonly Thread _listenThreadV4; private readonly int _port; private long _receivedMessages; @@ -36,13 +36,11 @@ namespace TimberWinR.Inputs public UdpInputListener(CancellationToken cancelToken, int port = 5140) : base(cancelToken, "Win32-Udp") { - _port = port; - - + _port = port; _receivedMessages = 0; - _listenThreadV6 = new Thread(StartListener); - _listenThreadV6.Start(); + _listenThreadV4 = new Thread(StartListener); + _listenThreadV4.Start(); } @@ -51,31 +49,21 @@ namespace TimberWinR.Inputs LogManager.GetCurrentClassLogger().Info("Shutting Down {0}", InputType); // close UDP listeners, which will end the listener threads - _udpListenerV6.Close(); + _udpListenerV4.Close(); // wait for completion of the threads - _listenThreadV6.Join(); + _listenThreadV4.Join(); base.Shutdown(); } private void StartListener() { - var groupV6 = new IPEndPoint(IPAddress.IPv6Any, _port); - // Create the socket as IPv6 - var dualModeSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp); - - // - // Now, disable the IPV6only flag to make it compatable with both ipv4 and ipv6 - // See: http://blogs.msdn.com/b/malarch/archive/2005/11/18/494769.aspx - // - dualModeSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0); - dualModeSocket.Bind(groupV6); + var groupV4 = new IPEndPoint(IPAddress.Any, _port); - _udpListenerV6 = new UdpClient(); - _udpListenerV6.Client = dualModeSocket; - - LogManager.GetCurrentClassLogger().Info("Udp Input on Port {0} Ready", groupV6); + _udpListenerV4 = new UdpClient(_port); + + LogManager.GetCurrentClassLogger().Info("Udp Input on Port {0} Ready", groupV4); string lastMessage = ""; try @@ -84,13 +72,18 @@ namespace TimberWinR.Inputs { try { - byte[] bytes = _udpListenerV6.Receive(ref groupV6); + byte[] bytes = _udpListenerV4.Receive(ref groupV4); var data = Encoding.UTF8.GetString(bytes, 0, bytes.Length); lastMessage = data; var json = JObject.Parse(data); ProcessJson(json); Interlocked.Increment(ref _receivedMessages); } + catch(ArgumentException aex) + { + LogManager.GetCurrentClassLogger().Error(aex); + break; + } catch(SocketException) { break; @@ -107,7 +100,7 @@ namespace TimberWinR.Inputs Interlocked.Increment(ref _parsedErrors); } } - _udpListenerV6.Close(); + _udpListenerV4.Close(); } catch (Exception ex) { From 1468a6d0e65b0eb16ae8da89998b67da1abcd362 Mon Sep 17 00:00:00 2001 From: Eric Fontana Date: Mon, 13 Apr 2015 06:19:47 -0400 Subject: [PATCH 2/2] Updated to new version --- TimberWinR.ServiceHost/Properties/AssemblyInfo.cs | 4 ++-- TimberWinR/ReleaseNotes.md | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs b/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs index 86c588b..bccff3a 100644 --- a/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs +++ b/TimberWinR.ServiceHost/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.3.20.0")] -[assembly: AssemblyFileVersion("1.3.20.0")] +[assembly: AssemblyVersion("1.3.21.0")] +[assembly: AssemblyFileVersion("1.3.21.0")] diff --git a/TimberWinR/ReleaseNotes.md b/TimberWinR/ReleaseNotes.md index 38c5fab..3d6c787 100644 --- a/TimberWinR/ReleaseNotes.md +++ b/TimberWinR/ReleaseNotes.md @@ -3,6 +3,9 @@ A Native Windows to Redis/Elasticsearch Logstash Agent which runs as a service. Version / Date +### 1.3.21.0 - 04/13/2015 +1. Rolled Udp listener support to V4 only, too many issues with dual mode sockets + and hosts file. If we want to add this back, I will add a Udpv6 input. ### 1.3.20.0 - 04/03/2015 1. A re-factoring of Logs and TailLogs to be more efficient and detect log rolling correctly,