Skip to content

Commit

Permalink
fix: IpAddress type error
Browse files Browse the repository at this point in the history
  • Loading branch information
nidbCN committed Dec 28, 2024
1 parent d0716e7 commit f25083a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions AliCdnSSLWorker/Clients/RefreshRequestClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Net;
using AliCdnSSLWorker.Configs;
using AliCdnSSLWorker.Extensions;
using Microsoft.Extensions.Options;

namespace AliCdnSSLWorker.Clients;
Expand All @@ -9,14 +10,17 @@ public class RefreshRequestClient

public RefreshRequestClient(HttpClient httpClient, IOptions<ForceMonitorConfig> options)
{
var ip = options.Value.Ip.Equals(IPAddress.Any)
var ipAddress = options.Value.GetIpAddress();

var ip = ipAddress.Equals(IPAddress.Any)
? IPAddress.Loopback
: options.Value.Ip;
: ipAddress;
var port = options.Value.Port;

httpClient.BaseAddress = new($"http://{ip}:{options.Value.Port}/");
httpClient.BaseAddress = new($"http://{ip}:{port}/");
httpClient.DefaultRequestHeaders.Add(
"User-Agent",
$"AliCdnSSLWorker/{GetType().Assembly.GetName().Version}"
$"{nameof(AliCdnSSLWorker)}/{GetType().Assembly.GetName().Version}"
);

Client = httpClient;
Expand Down

0 comments on commit f25083a

Please sign in to comment.