Updated
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<TargetFrameworks>.netstandard2.1; net6.0; net7.0; net8.0; net4.8;</TargetFrameworks>
|
<TargetFrameworks>.netstandard2.1; net6.0; net7.0; net8.0; net4.8;</TargetFrameworks>
|
||||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<FileVersion>1.3.6</FileVersion>
|
<FileVersion>1.3.7</FileVersion>
|
||||||
<Authors>EonaCat (Jeroen Saey)</Authors>
|
<Authors>EonaCat (Jeroen Saey)</Authors>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Company>EonaCat (Jeroen Saey)</Company>
|
<Company>EonaCat (Jeroen Saey)</Company>
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<EVRevisionFormat>1.3.6+{chash:10}.{c:ymd}</EVRevisionFormat>
|
<EVRevisionFormat>1.3.7+{chash:10}.{c:ymd}</EVRevisionFormat>
|
||||||
<EVDefault>true</EVDefault>
|
<EVDefault>true</EVDefault>
|
||||||
<EVInfo>true</EVInfo>
|
<EVInfo>true</EVInfo>
|
||||||
<EVTagMatch>v[0-9]*</EVTagMatch>
|
<EVTagMatch>v[0-9]*</EVTagMatch>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class Syslog : IDisposable
|
|||||||
{
|
{
|
||||||
private string _Hostname = "127.0.0.1";
|
private string _Hostname = "127.0.0.1";
|
||||||
private int _Port = 514;
|
private int _Port = 514;
|
||||||
|
private bool IsConnected { get; set; }
|
||||||
|
|
||||||
internal UdpClient Udp;
|
internal UdpClient Udp;
|
||||||
|
|
||||||
@@ -56,14 +57,23 @@ public class Syslog : IDisposable
|
|||||||
|
|
||||||
private void SetUdp()
|
private void SetUdp()
|
||||||
{
|
{
|
||||||
DisposeUdp();
|
try
|
||||||
Udp = new UdpClient(_Hostname, _Port);
|
{
|
||||||
|
DisposeUdp();
|
||||||
|
Udp = new UdpClient(_Hostname, _Port);
|
||||||
|
IsConnected = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
IsConnected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisposeUdp()
|
private void DisposeUdp()
|
||||||
{
|
{
|
||||||
if (Udp != null)
|
if (Udp != null)
|
||||||
{
|
{
|
||||||
|
IsConnected = false;
|
||||||
Udp.Dispose();
|
Udp.Dispose();
|
||||||
Udp = null;
|
Udp = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ namespace EonaCat.Logger.Servers.Tcp
|
|||||||
private int _Port = 514;
|
private int _Port = 514;
|
||||||
internal TcpClient _tcp;
|
internal TcpClient _tcp;
|
||||||
|
|
||||||
|
private bool IsConnected { get; set; }
|
||||||
public string Nickname { get; set; }
|
public string Nickname { get; set; }
|
||||||
public string IpPort => _Hostname + ":" + _Port;
|
public string IpPort => _Hostname + ":" + _Port;
|
||||||
|
|
||||||
@@ -52,14 +53,23 @@ namespace EonaCat.Logger.Servers.Tcp
|
|||||||
|
|
||||||
internal void SetTcp()
|
internal void SetTcp()
|
||||||
{
|
{
|
||||||
DisposeTcp();
|
try
|
||||||
_tcp = new TcpClient(_Hostname, _Port);
|
{
|
||||||
|
DisposeTcp();
|
||||||
|
_tcp = new TcpClient(_Hostname, _Port);
|
||||||
|
IsConnected = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
IsConnected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DisposeTcp()
|
internal void DisposeTcp()
|
||||||
{
|
{
|
||||||
if (_tcp != null)
|
if (_tcp != null)
|
||||||
{
|
{
|
||||||
|
IsConnected = false;
|
||||||
_tcp.Close();
|
_tcp.Close();
|
||||||
_tcp.Dispose();
|
_tcp.Dispose();
|
||||||
_tcp = null;
|
_tcp = null;
|
||||||
@@ -84,9 +94,17 @@ namespace EonaCat.Logger.Servers.Tcp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var stream = _tcp.GetStream();
|
if (!IsConnected)
|
||||||
await stream.WriteAsync(data, 0, data.Length);
|
{
|
||||||
await stream.FlushAsync();
|
SetTcp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsConnected)
|
||||||
|
{
|
||||||
|
using var stream = _tcp.GetStream();
|
||||||
|
await stream.WriteAsync(data, 0, data.Length);
|
||||||
|
await stream.FlushAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task WriteAsync(string data)
|
internal async Task WriteAsync(string data)
|
||||||
@@ -101,10 +119,18 @@ namespace EonaCat.Logger.Servers.Tcp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sendData = Encoding.UTF8.GetBytes(data);
|
if (!IsConnected)
|
||||||
using var stream = _tcp.GetStream();
|
{
|
||||||
await stream.WriteAsync(sendData, 0, sendData.Length);
|
SetTcp();
|
||||||
await stream.FlushAsync();
|
}
|
||||||
|
|
||||||
|
if (IsConnected)
|
||||||
|
{
|
||||||
|
var sendData = Encoding.UTF8.GetBytes(data);
|
||||||
|
using var stream = _tcp.GetStream();
|
||||||
|
await stream.WriteAsync(sendData, 0, sendData.Length);
|
||||||
|
await stream.FlushAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~Tcp()
|
~Tcp()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ namespace EonaCat.Logger.Servers.Udp
|
|||||||
private int _Port = 514;
|
private int _Port = 514;
|
||||||
internal UdpClient _udp;
|
internal UdpClient _udp;
|
||||||
|
|
||||||
|
private bool IsConnected { get; set; }
|
||||||
public string Nickname { get; set; }
|
public string Nickname { get; set; }
|
||||||
public string IpPort => _Hostname + ":" + _Port;
|
public string IpPort => _Hostname + ":" + _Port;
|
||||||
|
|
||||||
@@ -53,14 +54,23 @@ namespace EonaCat.Logger.Servers.Udp
|
|||||||
|
|
||||||
internal void SetUdp()
|
internal void SetUdp()
|
||||||
{
|
{
|
||||||
DisposeUdp();
|
try
|
||||||
_udp = new UdpClient(_Hostname, _Port);
|
{
|
||||||
|
DisposeUdp();
|
||||||
|
_udp = new UdpClient(_Hostname, _Port);
|
||||||
|
IsConnected = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
IsConnected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void DisposeUdp()
|
internal void DisposeUdp()
|
||||||
{
|
{
|
||||||
if (_udp != null)
|
if (_udp != null)
|
||||||
{
|
{
|
||||||
|
IsConnected = false;
|
||||||
_udp.Dispose();
|
_udp.Dispose();
|
||||||
_udp = null;
|
_udp = null;
|
||||||
}
|
}
|
||||||
@@ -79,19 +89,27 @@ namespace EonaCat.Logger.Servers.Udp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_udp.DontFragment = dontFragment;
|
if (!IsConnected)
|
||||||
|
|
||||||
int maxChunkSize = MaxUdpPacketSize;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
while (offset < data.Length)
|
|
||||||
{
|
{
|
||||||
int chunkSize = Math.Min(maxChunkSize, data.Length - offset);
|
SetUdp();
|
||||||
byte[] chunk = new byte[chunkSize];
|
}
|
||||||
Array.Copy(data, offset, chunk, 0, chunkSize);
|
|
||||||
|
|
||||||
await _udp.SendAsync(chunk, chunk.Length);
|
if (IsConnected)
|
||||||
offset += chunkSize;
|
{
|
||||||
|
_udp.DontFragment = dontFragment;
|
||||||
|
|
||||||
|
int maxChunkSize = MaxUdpPacketSize;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
while (offset < data.Length)
|
||||||
|
{
|
||||||
|
int chunkSize = Math.Min(maxChunkSize, data.Length - offset);
|
||||||
|
byte[] chunk = new byte[chunkSize];
|
||||||
|
Array.Copy(data, offset, chunk, 0, chunkSize);
|
||||||
|
|
||||||
|
await _udp.SendAsync(chunk, chunk.Length);
|
||||||
|
offset += chunkSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,20 +120,28 @@ namespace EonaCat.Logger.Servers.Udp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sendData = Encoding.UTF8.GetBytes(data);
|
if (!IsConnected)
|
||||||
_udp.DontFragment = dontFragment;
|
|
||||||
|
|
||||||
int maxChunkSize = MaxUdpPacketSize;
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
while (offset < sendData.Length)
|
|
||||||
{
|
{
|
||||||
int chunkSize = Math.Min(maxChunkSize, sendData.Length - offset);
|
SetUdp();
|
||||||
byte[] chunk = new byte[chunkSize];
|
}
|
||||||
Array.Copy(sendData, offset, chunk, 0, chunkSize);
|
|
||||||
|
|
||||||
await _udp.SendAsync(chunk, chunk.Length);
|
if (IsConnected)
|
||||||
offset += chunkSize;
|
{
|
||||||
|
var sendData = Encoding.UTF8.GetBytes(data);
|
||||||
|
_udp.DontFragment = dontFragment;
|
||||||
|
|
||||||
|
int maxChunkSize = MaxUdpPacketSize;
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
|
while (offset < sendData.Length)
|
||||||
|
{
|
||||||
|
int chunkSize = Math.Min(maxChunkSize, sendData.Length - offset);
|
||||||
|
byte[] chunk = new byte[chunkSize];
|
||||||
|
Array.Copy(sendData, offset, chunk, 0, chunkSize);
|
||||||
|
|
||||||
|
await _udp.SendAsync(chunk, chunk.Length);
|
||||||
|
offset += chunkSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user