diff --git a/AliCloudDynamicDNS/AliCloudDynamicDNS.csproj b/AliCloudDynamicDNS/AliCloudDynamicDNS.csproj index 8266181..6c857ca 100644 --- a/AliCloudDynamicDNS/AliCloudDynamicDNS.csproj +++ b/AliCloudDynamicDNS/AliCloudDynamicDNS.csproj @@ -2,14 +2,13 @@ Exe - net6.0 - 8.0 - 0.0.3 + net8.0 + 0.0.4 - - + + diff --git a/AliCloudDynamicDNS/Configuration/ConfigurationModel.cs b/AliCloudDynamicDNS/Configuration/ConfigurationModel.cs index 153520a..2aa3a6f 100644 --- a/AliCloudDynamicDNS/Configuration/ConfigurationModel.cs +++ b/AliCloudDynamicDNS/Configuration/ConfigurationModel.cs @@ -20,6 +20,11 @@ public class ConfigurationModel // 主域名。 public string MainDomain { get; set; } + /// + /// 公网 IP 获取服务器地址。 + /// + public string PublicIpServer { get; set; } + // 需要批量变更的子域名记录集合。 public List SubDomains { get; set; } } diff --git a/AliCloudDynamicDNS/Dockerfile b/AliCloudDynamicDNS/Dockerfile index 32b35ea..4f7fe17 100644 --- a/AliCloudDynamicDNS/Dockerfile +++ b/AliCloudDynamicDNS/Dockerfile @@ -1,10 +1,10 @@ -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS builder +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS builder WORKDIR /build COPY . . RUN dotnet restore RUN dotnet publish -c Release -o /publish -FROM mcr.microsoft.com/dotnet/runtime:6.0 AS runtime +FROM mcr.microsoft.com/dotnet/runtime:8.0 AS runtime WORKDIR /app COPY --from=builder /publish . diff --git a/AliCloudDynamicDNS/Threading/StrongTimer.cs b/AliCloudDynamicDNS/Threading/StrongTimer.cs index ae21bb5..89c707b 100644 --- a/AliCloudDynamicDNS/Threading/StrongTimer.cs +++ b/AliCloudDynamicDNS/Threading/StrongTimer.cs @@ -60,7 +60,7 @@ public void Stop() } } - private void Callback(object? state) + private void Callback(object state) { lock (_taskTimer) { diff --git a/AliCloudDynamicDNS/Utility/NetworkHelper.cs b/AliCloudDynamicDNS/Utility/NetworkHelper.cs index 6c5cc9f..e6a90b5 100644 --- a/AliCloudDynamicDNS/Utility/NetworkHelper.cs +++ b/AliCloudDynamicDNS/Utility/NetworkHelper.cs @@ -1,6 +1,7 @@ using System; using System.Net.Http; using System.Threading.Tasks; +using AliCloudDynamicDNS.Configuration; namespace AliCloudDynamicDNS.Utility { @@ -12,7 +13,7 @@ public static async Task GetPublicNetworkIp() { using (var client = new HttpClient()) { - using (var request = new HttpRequestMessage(HttpMethod.Get, "http://182.254.141.185:9990/get-ip")) + using (var request = new HttpRequestMessage(HttpMethod.Get, ConfigurationHelper.Configuration.PublicIpServer)) { using (var response = await client.SendAsync(request)) { diff --git a/AliCloudDynamicDNS/settings.json.example b/AliCloudDynamicDNS/settings.json.example index 93d185d..a9a3259 100644 --- a/AliCloudDynamicDNS/settings.json.example +++ b/AliCloudDynamicDNS/settings.json.example @@ -5,6 +5,8 @@ "AccessKey": "AccessKey", // 主域名。 "MainDomain": "example.com", + // 公网 IP 获取服务器地址。 + "PublicIpServer": "https://api.myzony.com/get-ip", // 需要批量变更的子域名记录集合。 "SubDomains": [ { diff --git a/README.md b/README.md index e9e835f..708241f 100644 --- a/README.md +++ b/README.md @@ -12,28 +12,30 @@ AliCloudDynamicDNS 是基于 .NET Core 开发的动态 DNS 解析工具,借助 ```json { - // 阿里云的 Access Id。 - "AccessId": "AccessId", - // 阿里云的 Access Key。 - "AccessKey": "AccessKey", - // 主域名。 - "MainDomain": "example.com", - // 需要批量变更的子域名记录集合。 - "SubDomains": [ - { - // 子域名记录类型。 - "Type": "A", - // 子域名记录前缀。 - "SubDomain": "sub1", - // TTL 时间。 - "Interval": 600 - }, - { - "Type": "A", - "SubDomain": "sub2", - "Interval": 600 - } - ] + // 阿里云的 Access Id。 + "AccessId": "AccessId", + // 阿里云的 Access Key。 + "AccessKey": "AccessKey", + // 主域名。 + "MainDomain": "example.com", + // 公网 IP 获取服务器地址。 + "PublicIpServer": "https://api.myzony.com/get-ip", + // 需要批量变更的子域名记录集合。 + "SubDomains": [ + { + // 子域名记录类型。 + "Type": "A", + // 子域名记录前缀。 + "SubDomain": "sub1", + // TTL 时间。 + "Interval": 600 + }, + { + "Type": "A", + "SubDomain": "sub2", + "Interval": 600 + } + ] } ```