This commit is contained in:
snltty
2025-07-17 01:00:22 +08:00
parent 3891da47af
commit 531b2594de
3 changed files with 18 additions and 3 deletions

View File

@@ -183,6 +183,7 @@ namespace linker.plugins.sforward.messenger
else
{
sForwardServerCahing.TryRemove(sForwardAddInfo.Domain, connection.Id, out _);
proxy.StopHttp(sForwardAddInfo.Domain);
result.Message = $"domain 【{sForwardAddInfo.Domain}】 remove success";
}

View File

@@ -11,6 +11,7 @@ namespace linker.plugins.sforward.proxy
{
private ConcurrentDictionary<int, AsyncUserToken> tcpListens = new ConcurrentDictionary<int, AsyncUserToken>();
private ConcurrentDictionary<ulong, TaskCompletionSource<Socket>> tcpConnections = new ConcurrentDictionary<ulong, TaskCompletionSource<Socket>>();
private ConcurrentDictionary<ulong, AsyncUserToken> httpConnections = new ConcurrentDictionary<ulong, AsyncUserToken>();
public Func<int, ulong, Task<bool>> TunnelConnect { get; set; } = async (port, id) => { return await Task.FromResult(false).ConfigureAwait(false); };
public Func<string, int, ulong, Task<bool>> WebConnect { get; set; } = async (host, port, id) => { return await Task.FromResult(false).ConfigureAwait(false); };
@@ -120,10 +121,11 @@ namespace linker.plugins.sforward.proxy
return;
}
string key = token.ListenPort.ToString();
//是web的去获取host请求头匹配不同的服务
if (token.IsWeb)
{
httpConnections.TryAdd(id, token);
key = token.Host = GetHost(buffer1.AsMemory(0, length));
if (string.IsNullOrWhiteSpace(token.Host))
{
@@ -179,7 +181,7 @@ namespace linker.plugins.sforward.proxy
finally
{
tcpConnections.TryRemove(id, out _);
httpConnections.TryRemove(id, out _);
}
}
@@ -203,6 +205,18 @@ namespace linker.plugins.sforward.proxy
CloseClientSocket(userToken);
}
}
public void StopHttp(string host)
{
foreach (var item in httpConnections.Where(c=>c.Value.Host == host).Select(c=>c.Key).ToList())
{
if (httpConnections.TryRemove(item,out var token))
{
CloseClientSocket(token);
}
}
}
private readonly byte[] hostBytes = Encoding.UTF8.GetBytes("Host: ");
private readonly byte[] wrapBytes = Encoding.UTF8.GetBytes("\r\n");

View File

@@ -1,5 +1,5 @@
v1.8.7
2025-07-16 23:40:39
2025-07-17 01:00:22
1. 一些累计更新
2. 暗色模式
3. 服务器穿透白名单、匿名连接