Skip to content

Commit

Permalink
fix: Fixed the issue with not being able to retrieve the public IP ad…
Browse files Browse the repository at this point in the history
…dress.
  • Loading branch information
zony@myzony.com authored and zony@myzony.com committed Nov 19, 2023
1 parent dac694b commit de3bc77
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 31 deletions.
9 changes: 4 additions & 5 deletions AliCloudDynamicDNS/AliCloudDynamicDNS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>8.0</LangVersion>
<Version>0.0.3</Version>
<TargetFramework>net8.0</TargetFramework>
<Version>0.0.4</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Nito.AsyncEx.Context" Version="5.1.2" />
</ItemGroup>

Expand Down
5 changes: 5 additions & 0 deletions AliCloudDynamicDNS/Configuration/ConfigurationModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public class ConfigurationModel
// 主域名。
public string MainDomain { get; set; }

/// <summary>
/// 公网 IP 获取服务器地址。
/// </summary>
public string PublicIpServer { get; set; }

// 需要批量变更的子域名记录集合。
public List<SubDomainRecord> SubDomains { get; set; }
}
Expand Down
4 changes: 2 additions & 2 deletions AliCloudDynamicDNS/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 .

Expand Down
2 changes: 1 addition & 1 deletion AliCloudDynamicDNS/Threading/StrongTimer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void Stop()
}
}

private void Callback(object? state)
private void Callback(object state)
{
lock (_taskTimer)
{
Expand Down
3 changes: 2 additions & 1 deletion AliCloudDynamicDNS/Utility/NetworkHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using AliCloudDynamicDNS.Configuration;

namespace AliCloudDynamicDNS.Utility
{
Expand All @@ -12,7 +13,7 @@ public static async Task<string> 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))
{
Expand Down
2 changes: 2 additions & 0 deletions AliCloudDynamicDNS/settings.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"AccessKey": "AccessKey",
// 主域名。
"MainDomain": "example.com",
// 公网 IP 获取服务器地址。
"PublicIpServer": "https://api.myzony.com/get-ip",
// 需要批量变更的子域名记录集合。
"SubDomains": [
{
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
```

Expand Down

0 comments on commit de3bc77

Please sign in to comment.