- Updated the VPN configuration commands and handlers to eliminate the device limit parameter, simplifying the configuration process. - Adjusted related API documentation to reflect the removal of device limit management, clarifying that this setting is now handled directly in the 3x-ui by node administrators. - Enhanced the overall codebase by removing unnecessary device limit references across various components, ensuring a cleaner and more maintainable code structure.
58 lines
2.5 KiB
C#
58 lines
2.5 KiB
C#
using PnvPanel.Application.Common.Interfaces;
|
|
using PnvPanel.Application.Common.Models;
|
|
using PnvPanel.Domain.Inbounds;
|
|
using PnvPanel.Domain.Nodes;
|
|
|
|
namespace PnvPanel.IntegrationTests.TestSupport;
|
|
|
|
/// <summary>
|
|
/// Заглушка 3x-ui для интеграционных тестов — реальной панели нет. Возвращает успех для проб/CRUD
|
|
/// клиентов, отдаёт один синтетический inbound на ноду для сценариев с SyncNode.
|
|
/// </summary>
|
|
public sealed class FakeXuiPanelGateway : IXuiPanelGateway
|
|
{
|
|
public Result ValidateBaseAddress(Uri baseAddress) => Result.Success();
|
|
|
|
public Task<NodeProbeResult> ProbeAsync(Node node, CancellationToken cancellationToken)
|
|
=> Task.FromResult(new NodeProbeResult(true, null));
|
|
|
|
public Task<Result<IReadOnlyList<RemoteInboundInfo>>> ListInboundsAsync(Node node, CancellationToken cancellationToken)
|
|
{
|
|
IReadOnlyList<RemoteInboundInfo> inbounds =
|
|
[
|
|
new RemoteInboundInfo("1", VpnProtocol.Vless, "Test inbound", 443),
|
|
];
|
|
|
|
return Task.FromResult(Result.Success(inbounds));
|
|
}
|
|
|
|
public void InvalidateClient(Guid nodeId)
|
|
{
|
|
}
|
|
|
|
public Task<Result<string>> AddClientAsync(
|
|
Node node, string inboundRemoteId, VpnProtocol protocol, string clientEmail, string clientName,
|
|
CancellationToken cancellationToken)
|
|
=> Task.FromResult(Result.Success(Guid.NewGuid().ToString()));
|
|
|
|
public Task<Result> RemoveClientAsync(
|
|
Node node, string inboundRemoteId, string clientExternalId, VpnProtocol protocol, CancellationToken cancellationToken)
|
|
=> Task.FromResult(Result.Success());
|
|
|
|
public Task<Result> UpdateClientAsync(
|
|
Node node, string inboundRemoteId, string clientExternalId, VpnProtocol protocol,
|
|
string name, bool enable, CancellationToken cancellationToken)
|
|
=> Task.FromResult(Result.Success());
|
|
|
|
public Task<Result<string>> BuildConnectionStringAsync(
|
|
Node node, Inbound inbound, string clientExternalId, string clientName, string publicHost, CancellationToken cancellationToken)
|
|
=> Task.FromResult(Result.Success("vless://fake-connection-string"));
|
|
|
|
public Task<Result<IReadOnlyDictionary<string, ClientTrafficInfo>>> GetClientTrafficAsync(
|
|
Node node, string inboundRemoteId, CancellationToken cancellationToken)
|
|
{
|
|
IReadOnlyDictionary<string, ClientTrafficInfo> traffic = new Dictionary<string, ClientTrafficInfo>();
|
|
return Task.FromResult(Result.Success(traffic));
|
|
}
|
|
}
|