XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

LumaTunnel

【WinUI】LumaTunnel 是一个面向个人多设备的 Windows 代理系统。客户端在本机提供 HTTP/HTTPS CONNECT 与 SOCKS5 TCP 代理,并通过一个受信任 TLS 证书保护的 WSS 会话,将多个 TCP 流复用到自建 Windows Server 节点。

公开
关注 0 Fork 0 Star 0
UTF-8
using LumaTunnel.Shared.Models;

namespace LumaTunnel.Client.Core.Abstractions;

public interface IProxyConnector
{
    ValueTask<Stream> ConnectAsync(ProxyTarget target, CancellationToken cancellationToken = default);
}

public interface IHalfCloseable
{
    ValueTask HalfCloseWriteAsync(CancellationToken cancellationToken = default);
}

public interface IRoutingService
{
    ProxyMode Mode { get; set; }
    IReadOnlyList<RoutingRule> Rules { get; }
    void SetRules(IEnumerable<RoutingRule> rules);
    RouteAction Resolve(ProxyTarget target);
}

public interface ITunnelService : IAsyncDisposable
{
    bool IsConnected { get; }
    event EventHandler<bool>? ConnectionStateChanged;
    Task ConnectAsync(TunnelCredentials credentials, CancellationToken cancellationToken = default);
    ValueTask<Stream> OpenStreamAsync(ProxyTarget target, CancellationToken cancellationToken = default);
    Task DisconnectAsync(CancellationToken cancellationToken = default);
}

public sealed record TunnelCredentials(Uri TunnelUri, string DeviceId, string DeviceToken, string ClientVersion);

public interface IProxyEngineService : IAsyncDisposable
{
    bool IsRunning { get; }
    IReadOnlyCollection<ProxyConnectionInfo> Connections { get; }
    event EventHandler? ConnectionsChanged;
    Task StartAsync(ProxyEngineOptions options, CancellationToken cancellationToken = default);
    Task StopAsync(CancellationToken cancellationToken = default);
}

public sealed record ProxyConnectionInfo(
    Guid Id,
    string Protocol,
    ProxyTarget Target,
    RouteAction Route,
    DateTimeOffset StartedAtUtc,
    long UploadBytes,
    long DownloadBytes);

public interface INodeManagerService : IAsyncDisposable
{
    NodeProfile? ActiveNode { get; }
    IReadOnlyList<NodeProfile> Nodes { get; }
    event EventHandler<NodeProfile?>? ActiveNodeChanged;
    void SetNodes(IEnumerable<NodeProfile> nodes);
    Task<NodeProfile> ConnectBestAsync(CancellationToken cancellationToken = default);
    Task StartMonitoringAsync(CancellationToken cancellationToken = default);
    Task StopMonitoringAsync(CancellationToken cancellationToken = default);
}