LumaTunnel
【WinUI】LumaTunnel 是一个面向个人多设备的 Windows 代理系统。客户端在本机提供 HTTP/HTTPS CONNECT 与 SOCKS5 TCP 代理,并通过一个受信任 TLS 证书保护的 WSS 会话,将多个 TCP 流复用到自建 Windows Server 节点。
关注
0
Fork
0
Star
0
using System.Net.Sockets;
using LumaTunnel.Client.Core.Abstractions;
using LumaTunnel.Shared.Models;
namespace LumaTunnel.Client.Core.Networking;
public sealed class DirectConnector(TimeSpan? connectTimeout = null) : IProxyConnector
{
private readonly TimeSpan _connectTimeout = connectTimeout ?? TimeSpan.FromSeconds(10);
public async ValueTask<Stream> ConnectAsync(ProxyTarget target, CancellationToken cancellationToken = default)
{
var client = new TcpClient { NoDelay = true };
try
{
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
timeout.CancelAfter(_connectTimeout);
await client.ConnectAsync(target.Host, target.Port, timeout.Token).ConfigureAwait(false);
return new OwnedTcpStream(client);
}
catch
{
client.Dispose();
throw;
}
}
}
using System.Net.Sockets;
using LumaTunnel.Client.Core.Abstractions;
using LumaTunnel.Shared.Models;
namespace LumaTunnel.Client.Core.Networking;
public sealed class DirectConnector(TimeSpan? connectTimeout = null) : IProxyConnector
{
private readonly TimeSpan _connectTimeout = connectTimeout ?? TimeSpan.FromSeconds(10);
public async ValueTask<Stream> ConnectAsync(ProxyTarget target, CancellationToken cancellationToken = default)
{
var client = new TcpClient { NoDelay = true };
try
{
using var timeout = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken);
timeout.CancelAfter(_connectTimeout);
await client.ConnectAsync(target.Host, target.Port, timeout.Token).ConfigureAwait(false);
return new OwnedTcpStream(client);
}
catch
{
client.Dispose();
throw;
}
}
}