This commit is contained in:
snltty
2025-06-25 14:44:35 +08:00
parent 89c9806d97
commit f7b417fc62
3 changed files with 37 additions and 25 deletions

View File

@@ -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])

View File

@@ -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();
if (LoggerHelper.Instance.LoggerLevel <= LoggerTypes.DEBUG)
{
LoggerHelper.Instance.Debug($"online:{online},total:{total},server:{SendtBytes}");
}
} }
catch (Exception) 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,31 +128,23 @@ 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];
signCaching.GetOnline(out int total, out int onlone);
buffer[0] = (byte)ResolverType.FlowReport;
onlone.ToBytes(buffer.Slice(1));
total.ToBytes(buffer.Slice(5));
netBytes.CopyTo(buffer.Slice(9));
try using UdpClient udpClient = new UdpClient(AddressFamily.InterNetwork);
{ udpClient.Client.WindowsUdpBug();
signCaching.GetOnline(out int total, out int onlone);
buffer[0] = (byte)ResolverType.FlowReport;
onlone.ToBytes(buffer.AsMemory(1));
total.ToBytes(buffer.AsMemory(5));
netBytes.CopyTo(buffer.AsMemory(9)); string domain = "linker.snltty.com";
using UdpClient udpClient = new UdpClient(AddressFamily.InterNetwork);
udpClient.Client.WindowsUdpBug();
string domain = "linker.snltty.com";
#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);
} }
} }

View File

@@ -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. 设置默认中继节点