mirror of
https://github.com/snltty/linker.git
synced 2025-09-27 13:32:14 +08:00
185
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
@@ -85,6 +84,14 @@ namespace linker.libs.extends
|
|||||||
new Span<byte>(p, sizeof(int)).CopyTo(memory.Span);
|
new Span<byte>(p, sizeof(int)).CopyTo(memory.Span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static unsafe void ToBytes(this int value, Span<byte> span)
|
||||||
|
{
|
||||||
|
ref int v = ref value;
|
||||||
|
fixed (void* p = &v)
|
||||||
|
{
|
||||||
|
new Span<byte>(p, sizeof(int)).CopyTo(span);
|
||||||
|
}
|
||||||
|
}
|
||||||
public static unsafe void ToBytes(this int[] value, Memory<byte> memory)
|
public static unsafe void ToBytes(this int[] value, Memory<byte> memory)
|
||||||
{
|
{
|
||||||
fixed (void* p = &value[0])
|
fixed (void* p = &value[0])
|
||||||
|
@@ -66,9 +66,18 @@ namespace linker.messenger.flow
|
|||||||
ReceiveBytes = online | total;
|
ReceiveBytes = online | total;
|
||||||
SendtBytes = servers.Count(c => time - c.Value.Time < 15000);
|
SendtBytes = servers.Count(c => time - c.Value.Time < 15000);
|
||||||
Version.Increment();
|
Version.Increment();
|
||||||
}
|
|
||||||
catch (Exception)
|
if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG)
|
||||||
{
|
{
|
||||||
|
LoggerHelper.Instance.Debug($"online:{online},total:{total},server:{SendtBytes}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG)
|
||||||
|
{
|
||||||
|
LoggerHelper.Instance.Error(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.CompletedTask.ConfigureAwait(false);
|
await Task.CompletedTask.ConfigureAwait(false);
|
||||||
@@ -100,8 +109,12 @@ namespace linker.messenger.flow
|
|||||||
{
|
{
|
||||||
Report();
|
Report();
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG)
|
||||||
|
{
|
||||||
|
LoggerHelper.Instance.Error(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
@@ -115,17 +128,12 @@ namespace linker.messenger.flow
|
|||||||
Lon = c.Count() == 1 ? c.First().Lon : c.Average(c => c.Lon)
|
Lon = c.Count() == 1 ? c.First().Lon : c.Average(c => c.Lon)
|
||||||
}).ToList();
|
}).ToList();
|
||||||
byte[] netBytes = serializer.Serialize(nets);
|
byte[] netBytes = serializer.Serialize(nets);
|
||||||
byte[] buffer = ArrayPool<byte>.Shared.Rent(9 + netBytes.Length);
|
Span<byte> buffer = stackalloc byte[9 + netBytes.Length];
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
signCaching.GetOnline(out int total, out int onlone);
|
signCaching.GetOnline(out int total, out int onlone);
|
||||||
buffer[0] = (byte)ResolverType.FlowReport;
|
buffer[0] = (byte)ResolverType.FlowReport;
|
||||||
onlone.ToBytes(buffer.AsMemory(1));
|
onlone.ToBytes(buffer.Slice(1));
|
||||||
total.ToBytes(buffer.AsMemory(5));
|
total.ToBytes(buffer.Slice(5));
|
||||||
|
netBytes.CopyTo(buffer.Slice(9));
|
||||||
netBytes.CopyTo(buffer.AsMemory(9));
|
|
||||||
|
|
||||||
|
|
||||||
using UdpClient udpClient = new UdpClient(AddressFamily.InterNetwork);
|
using UdpClient udpClient = new UdpClient(AddressFamily.InterNetwork);
|
||||||
udpClient.Client.WindowsUdpBug();
|
udpClient.Client.WindowsUdpBug();
|
||||||
@@ -134,12 +142,9 @@ namespace linker.messenger.flow
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
domain = "127.0.0.1";
|
domain = "127.0.0.1";
|
||||||
#endif
|
#endif
|
||||||
udpClient.Send(buffer.AsSpan(0, 9 + netBytes.Length), domain, 1802);
|
udpClient.Send(buffer.Slice(0, 9 + netBytes.Length), domain, 1802);
|
||||||
}
|
|
||||||
catch (Exception)
|
udpClient.Dispose();
|
||||||
{
|
|
||||||
}
|
|
||||||
ArrayPool<byte>.Shared.Return(buffer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
v1.8.5
|
v1.8.5
|
||||||
2025-06-24 17:14:47
|
2025-06-25 14:44:35
|
||||||
1. 一些累计更新
|
1. 一些累计更新
|
||||||
2. 备用信标服务器
|
2. 备用信标服务器
|
||||||
3. 设置默认中继节点
|
3. 设置默认中继节点
|
||||||
|
Reference in New Issue
Block a user