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 System.Net;
using LumaTunnel.Server.Core.Runtime;
using LumaTunnel.Shared.Models;
using XFEExtension.NetCore.ServerInteractive.Attributes;
using XFEExtension.NetCore.ServerInteractive.Implements.CoreService;

namespace LumaTunnel.Server.Core.Services;

public partial class NodeStatusService : ServerCoreStandardServiceBase
{
    [EntryPoint("v1/node/status")]
    public async Task GetStatusAsync()
    {
        string? deviceId = Json > "deviceId";
        string? deviceToken = Json > "deviceToken";
        var runtime = ServerRuntime.Current;

        if (string.IsNullOrWhiteSpace(deviceId)
            || string.IsNullOrWhiteSpace(deviceToken)
            || !runtime.Devices.Validate(deviceId, deviceToken, out var device))
        {
            await CloseWithError("Invalid device credentials.", HttpStatusCode.Unauthorized).ConfigureAwait(false);
            return;
        }

        var deviceTotals = runtime.Traffic.GetDevice(deviceId);
        await Close(new NodeStatusDto(
            runtime.Settings.NodeId,
            runtime.Settings.NodeName,
            typeof(NodeStatusService).Assembly.GetName().Version?.ToString(3) ?? "0.1.0",
            DateTimeOffset.UtcNow,
            runtime.Traffic.ActiveConnections,
            deviceTotals.ActiveConnections,
            deviceTotals.UploadBytes + device!.UploadBytes,
            deviceTotals.DownloadBytes + device.DownloadBytes,
            runtime.Settings.MaxConnections,
            ["http-connect", "socks5-connect", "tcp-multiplex", "device-revocation"])).ConfigureAwait(false);
    }
}