This commit is contained in:
snltty
2025-09-12 17:21:56 +08:00
parent cad0e2e248
commit 368ce5fd05
8 changed files with 30 additions and 37 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>linker.web</title><link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/><script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script><script defer="defer" src="js/chunk-vendors.e9b4f2f4.js"></script><script defer="defer" src="js/app.42ac0ef5.js"></script><link href="css/chunk-vendors.d8267b33.css" rel="stylesheet"><link href="css/app.e16885f2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but linker.web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>linker.web</title><link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/><script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script><script defer="defer" src="js/chunk-vendors.e9b4f2f4.js"></script><script defer="defer" src="js/app.9799f14c.js"></script><link href="css/chunk-vendors.d8267b33.css" rel="stylesheet"><link href="css/app.e16885f2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but linker.web doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -108,32 +108,20 @@ namespace linker.messenger.relay.messenger
if (signCaching.TryGet(connection.Id, info.RemoteMachineId, out SignCacheInfo from, out SignCacheInfo to) == false)
{
if (from == null)
{
LoggerHelper.Instance.Error($"[relay] from null");
}
else if (to == null)
{
LoggerHelper.Instance.Error($"[relay] to null");
}
else
{
LoggerHelper.Instance.Error($"[relay] {from.Id}({from.MachineName})[{from.GroupId}] to {to.Id}({to.MachineName})[{to.GroupId}] fail");
}
LoggerHelper.Instance.Error($"[relay] fail info {info.ToJson()}");
connection.Write(serializer.Serialize(new RelayAskResultInfo170 { }));
return;
}
var nodes = (await GetNodes(from).ConfigureAwait(false)).Select(c => (RelayServerNodeReportInfo170)c).ToList();
RelayAskResultInfo170 result = new()
{
Nodes = (await GetNodes(from).ConfigureAwait(false)).Select(c => (RelayServerNodeReportInfo170)c).ToList()
Nodes = nodes
};
if (result.Nodes.Count > 0)
{
result.FlowingId = await relayServerTransfer.AddRelay(from, to, info);
result.FlowingId = relayServerTransfer.AddRelay(from, to, info);
}
connection.Write(serializer.Serialize(result));
}
@@ -208,10 +196,10 @@ namespace linker.messenger.relay.messenger
/// <param name="connection"></param>
/// <returns></returns>
[MessengerId((ushort)RelayMessengerIds.NodeGetCache)]
public void NodeGetCache(IConnection connection)
public async Task NodeGetCache(IConnection connection)
{
string key = serializer.Deserialize<string>(connection.ReceiveRequestWrap.Payload.Span);
RelayCacheInfo cache = relayServerTransfer.TryGetRelayCache(key, string.Empty);
RelayCacheInfo cache = await relayServerTransfer.TryGetRelayCache(key, string.Empty);
if (cache != null)
{
byte[] sendt = serializer.Serialize(cache);
@@ -224,11 +212,11 @@ namespace linker.messenger.relay.messenger
}
}
[MessengerId((ushort)RelayMessengerIds.NodeGetCache186)]
public void NodeGetCache186(IConnection connection)
public async Task NodeGetCache186(IConnection connection)
{
relayServerReportResolver.Add(connection.ReceiveRequestWrap.Payload.Length, 0);
ValueTuple<string, string> key = serializer.Deserialize<ValueTuple<string, string>>(connection.ReceiveRequestWrap.Payload.Span);
RelayCacheInfo cache = relayServerTransfer.TryGetRelayCache(key.Item1, key.Item2);
RelayCacheInfo cache = await relayServerTransfer.TryGetRelayCache(key.Item1, key.Item2);
if (cache != null)
{
byte[] sendt = serializer.Serialize(cache);

View File

@@ -1,4 +1,5 @@
using linker.libs;
using linker.libs.extends;
using linker.libs.timer;
using linker.messenger.relay.client.transport;
using linker.messenger.relay.messenger;
@@ -41,7 +42,7 @@ namespace linker.messenger.relay.server
}
public async Task<ulong> AddRelay(SignCacheInfo from, SignCacheInfo to, RelayInfo170 info)
public ulong AddRelay(SignCacheInfo from, SignCacheInfo to, RelayInfo170 info)
{
ulong flowingId = Interlocked.Increment(ref relayFlowingId);
@@ -54,29 +55,25 @@ namespace linker.messenger.relay.server
ToName = to.MachineName,
GroupId = to.GroupId,
Validated = from.Super,
UserId = from.UserId,
};
if (reports.TryGetValue(info.NodeId, out var node) == false)
if (relayCaching.TryAdd($"{cache.FromId}->{cache.ToId}->{flowingId}", cache, 15000) == false)
{
return 0;
}
cache.Validated = from.Super || await relayServerWhiteListStore.Contains(from.UserId, info.NodeId);
if (cache.Validated == false)
{
cache.Cdkey = (await relayServerCdkeyStore.GetAvailable(from.UserId).ConfigureAwait(false)).Select(c => new RelayCdkeyInfo { Bandwidth = c.Bandwidth, Id = c.Id, LastBytes = c.LastBytes }).ToList();
if (cache.Cdkey.Count <= 0 && node.Public == false) return 0;
}
bool added = relayCaching.TryAdd($"{cache.FromId}->{cache.ToId}->{flowingId}", cache, 15000);
if (added == false) return 0;
return flowingId;
}
public RelayCacheInfo TryGetRelayCache(string key, string nodeid)
public async Task<RelayCacheInfo> TryGetRelayCache(string key, string nodeid)
{
if (relayCaching.TryGetValue(key, out RelayCacheInfo cache) && reports.TryGetValue(nodeid, out var node))
{
cache.Validated = cache.Validated || await relayServerWhiteListStore.Contains(cache.UserId, node.Id);
if (cache.Validated == false)
{
cache.Cdkey = (await relayServerCdkeyStore.GetAvailable(cache.UserId).ConfigureAwait(false)).Select(c => new RelayCdkeyInfo { Bandwidth = c.Bandwidth, Id = c.Id, LastBytes = c.LastBytes }).ToList();
if (cache.Cdkey.Count == 0 && node.Public == false) return null;
}
return cache;
}
return null;
@@ -189,7 +186,7 @@ namespace linker.messenger.relay.server
.Where(c =>
{
return validated || nodes.Contains(c.Id)
|| (c.Public && (c.ConnectionRatio < c.MaxConnection && (c.MaxGbTotal == 0 || (c.MaxGbTotal > 0 && c.MaxGbTotalLastBytes > 0))));
|| (c.Public && c.ConnectionRatio < c.MaxConnection && (c.MaxGbTotal == 0 || (c.MaxGbTotal > 0 && c.MaxGbTotalLastBytes > 0)));
})
.OrderByDescending(c => c.LastTicks);

View File

@@ -417,6 +417,11 @@ namespace linker.messenger.relay.server
public string GroupId { get; set; }
public bool Validated { get; set; }
public List<RelayCdkeyInfo> Cdkey { get; set; } = [];
/// <summary>
/// 仅本地缓存可用
/// </summary>
public string UserId { get; set; } = string.Empty;
}
public sealed class RelayTrafficCacheInfo
{

View File

@@ -1,5 +1,5 @@
v1.9.1
2025-09-12 15:50:59
2025-09-12 17:21:56
1. 一些累计更新
2. 服务器转发多节点
3. 虚拟网卡下伪造ACK为TCP-in-TCP隧道提速