From f4e7df02d791e4c5620fe9b547bbbd8910dd30b0 Mon Sep 17 00:00:00 2001 From: Gaein nidb Date: Fri, 7 Jun 2024 12:54:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AliCdnSSLWorker.csproj | 2 +- Clients/RefreshRequestClient.cs | 8 +++----- Services/RefreshRequestService.cs | 9 ++++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AliCdnSSLWorker.csproj b/AliCdnSSLWorker.csproj index 1efa59f..46f8c3a 100644 --- a/AliCdnSSLWorker.csproj +++ b/AliCdnSSLWorker.csproj @@ -8,7 +8,7 @@ Linux . 6.0.2.1 - 6.0.1.1 + 6.0.2.1 diff --git a/Clients/RefreshRequestClient.cs b/Clients/RefreshRequestClient.cs index 6f8eb10..966281b 100644 --- a/Clients/RefreshRequestClient.cs +++ b/Clients/RefreshRequestClient.cs @@ -9,11 +9,9 @@ public class RefreshRequestClient public RefreshRequestClient(HttpClient httpClient, IOptions options) { - var ip = options.Value.IpAddress.ToString(); - if (options.Value.IpAddress.Equals(IPAddress.Any)) - { - ip = IPAddress.Loopback.ToString(); - } + var ip = options.Value.IpAddress.Equals(IPAddress.Any) + ? IPAddress.Loopback + : options.Value.IpAddress; httpClient.BaseAddress = new($"http://{ip}:{options.Value.Port}/"); httpClient.DefaultRequestHeaders.Add( diff --git a/Services/RefreshRequestService.cs b/Services/RefreshRequestService.cs index f1a8790..b98139c 100644 --- a/Services/RefreshRequestService.cs +++ b/Services/RefreshRequestService.cs @@ -2,10 +2,13 @@ namespace AliCdnSSLWorker.Services; -public class RefreshRequestService(RefreshRequestClient client) +public class RefreshRequestService(ILogger logger, RefreshRequestClient client) { public async Task Update() - => (await client.RequestAsync()) - .EnsureSuccessStatusCode(); + { + logger.LogInformation("Send refresh request to {url}", client.Client.BaseAddress); + var resp = await client.RequestAsync(); + resp.EnsureSuccessStatusCode(); + } }