mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
geetest verify
This commit is contained in:
@@ -34,7 +34,7 @@ internal sealed partial class ExceptionRecorder
|
|||||||
#if RELEASE
|
#if RELEASE
|
||||||
#pragma warning disable VSTHRD002
|
#pragma warning disable VSTHRD002
|
||||||
serviceProvider
|
serviceProvider
|
||||||
.GetRequiredService<Web.Hutao.HomaLogUploadClient>()
|
.GetRequiredService<Web.Hutao.Log.HomaLogUploadClient>()
|
||||||
.UploadLogAsync(serviceProvider, e.Exception)
|
.UploadLogAsync(serviceProvider, e.Exception)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Snap.Hutao.Web.Hutao.GachaLog;
|
|||||||
using Snap.Hutao.Web.Response;
|
using Snap.Hutao.Web.Response;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
||||||
namespace Snap.Hutao.Web.Hutao;
|
namespace Snap.Hutao.Web.Hutao.GachaLog;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 胡桃祈愿记录API客户端
|
/// 胡桃祈愿记录API客户端
|
||||||
19
src/Snap.Hutao/Snap.Hutao/Web/Hutao/Geetest/GeetestData.cs
Normal file
19
src/Snap.Hutao/Snap.Hutao/Web/Hutao/Geetest/GeetestData.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hutao.Geetest;
|
||||||
|
|
||||||
|
internal sealed class GeetestData
|
||||||
|
{
|
||||||
|
[JsonPropertyName("gt")]
|
||||||
|
public string Gt { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("challenge")]
|
||||||
|
public string Challenge { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("validate")]
|
||||||
|
public string Validate { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("type")]
|
||||||
|
public string Type { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hutao.Geetest;
|
||||||
|
|
||||||
|
internal sealed class GeetestResponse
|
||||||
|
{
|
||||||
|
[JsonPropertyName("code")]
|
||||||
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
[JsonPropertyName("info")]
|
||||||
|
public string Info { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("data")]
|
||||||
|
public GeetestData Data { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("times")]
|
||||||
|
public int Times { get; set; } = default!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||||
|
using Snap.Hutao.Service.Hutao;
|
||||||
|
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||||
|
using Snap.Hutao.Web.Response;
|
||||||
|
using System.Net.Http;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Web.Hutao.Geetest;
|
||||||
|
|
||||||
|
[ConstructorGenerated(ResolveHttpClient = true)]
|
||||||
|
[HttpClient(HttpClientConfiguration.Default)]
|
||||||
|
internal sealed partial class HomaGeetestClient
|
||||||
|
{
|
||||||
|
private readonly HttpClient httpClient;
|
||||||
|
private readonly JsonSerializerOptions options;
|
||||||
|
private readonly ILogger<HomaGeetestClient> logger;
|
||||||
|
private readonly HutaoUserOptions hutaoUserOptions;
|
||||||
|
|
||||||
|
public async ValueTask<GeetestResponse> VerifyAsync(string gt, string challenge, CancellationToken token)
|
||||||
|
{
|
||||||
|
httpClient.DefaultRequestHeaders.Authorization = new("Bearer", hutaoUserOptions.Token);
|
||||||
|
|
||||||
|
GeetestResponse? resp = await httpClient
|
||||||
|
.TryCatchGetFromJsonAsync<GeetestResponse>(HutaoEndpoints.GeetestVerify(gt,challenge), options, logger, token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
ArgumentNullException.ThrowIfNull(resp);
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ using Snap.Hutao.Web.Hutao.Log;
|
|||||||
using Snap.Hutao.Web.Response;
|
using Snap.Hutao.Web.Response;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
|
||||||
namespace Snap.Hutao.Web.Hutao;
|
namespace Snap.Hutao.Web.Hutao.Log;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 胡桃日志客户端
|
/// 胡桃日志客户端
|
||||||
@@ -18,6 +18,13 @@ internal static class HutaoEndpoints
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string StaticHutao = "static.hut.ao";
|
public const string StaticHutao = "static.hut.ao";
|
||||||
|
|
||||||
|
#region
|
||||||
|
public static string GeetestVerify(string gt, string challenge)
|
||||||
|
{
|
||||||
|
return $"{HomaSnapGenshinApi}/Geetest/Verify?gt={gt}&challenge={challenge}";
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region GachaLog
|
#region GachaLog
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user