Publish Zonghengjia Windows 0.3.13 client source
This commit is contained in:
+13
-5
@@ -7,7 +7,7 @@ namespace UCVL.VPNPlus;
|
||||
|
||||
internal sealed class VpnApiClient : IDisposable
|
||||
{
|
||||
internal const string BaseAddress = "https://vpn.example.invalid/";
|
||||
internal const string BaseAddress = "https://" + PlatformBootstrapTransport.Host + "/";
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
@@ -76,13 +76,21 @@ internal sealed class VpnApiClient : IDisposable
|
||||
|
||||
internal async Task<ConfigResponse> GetConfigAsync(string token, string nodeSlug, string routeMode, CancellationToken cancellationToken, IEnumerable<string>? excluded = null)
|
||||
{
|
||||
var url = $"api/v1/client/config/?node={Uri.EscapeDataString(nodeSlug)}&route={Uri.EscapeDataString(routeMode)}";
|
||||
if (nodeSlug == "auto") url += "&new_connection=1";
|
||||
if (excluded is not null) url += "&exclude=" + Uri.EscapeDataString(string.Join(",", excluded));
|
||||
using var request = AuthorizedRequest(HttpMethod.Get, url, token);
|
||||
using var request = AuthorizedRequest(HttpMethod.Get, ConfigPath(nodeSlug, routeMode, excluded), token);
|
||||
return await SendAsync<ConfigResponse>(request, cancellationToken);
|
||||
}
|
||||
|
||||
internal static string ConfigPath(string nodeSlug, string routeMode, IEnumerable<string>? excluded)
|
||||
{
|
||||
var url = $"api/v1/client/config/?node={Uri.EscapeDataString(nodeSlug)}&route={Uri.EscapeDataString(routeMode)}";
|
||||
if (nodeSlug == "auto" && excluded is not null)
|
||||
{
|
||||
var failed = string.Join(",", excluded);
|
||||
if (failed.Length != 0) url += "&exclude=" + Uri.EscapeDataString(failed);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
internal async Task LogoutAsync(string token, CancellationToken cancellationToken)
|
||||
{
|
||||
using var request = AuthorizedRequest(HttpMethod.Post, "api/v1/client/logout/", token);
|
||||
|
||||
Reference in New Issue
Block a user