Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/SyslogProxy/Proxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ private async Task EchoAsync(TcpClient client)
Logger.Information("New client connected from IP: [{0}].", ipAddress);
using (client)
{
var decoder = Encoding.UTF8.GetDecoder();
char[] decoded = new char[BufferSize];
var stream = client.GetStream();
var buf = new byte[BufferSize];
var accumulator = new StringBuilder();
Expand All @@ -63,7 +65,10 @@ private async Task EchoAsync(TcpClient client)
{
break;
}
accumulator.Append(Encoding.UTF8.GetString(buf).TrimEnd('\0'));

var countDecoded = decoder.GetChars(buf, 0, amountReadTask.Result, decoded, 0);
accumulator.Append(decoded, 0, countDecoded);

if (accumulator.ToString().Contains("\n"))
{
var splitMessage = accumulator.ToString().Split('\n').ToList();
Expand Down