Hua.DDNS
A dynamic DNS update system service built with .NET 8.0 and Quartz.Net.
Features
- Multi-Platform Support: Supports multiple DNS providers
- DnsPod (Tencent Cloud)
- Alibaba Cloud DNS
- Namesilo
- SSL Certificate Download: Automatic SSL certificate download from Alibaba Cloud and Tencent Cloud
- Scheduled Tasks: Flexible task scheduling using Quartz.Net with Cron expressions
- Windows Service: Can run as a Windows service using NSSM
- Docker Support: Ready for containerized deployment
- Logging: Comprehensive logging with Serilog
- Database Support: PostgreSQL for data persistence
Requirements
- .NET 8.0 SDK (for building)
- .NET 8.0 Runtime (for running)
- PostgreSQL (optional, for database features)
- Windows (for Windows Service mode) or Linux/Docker
Installation
Windows Service Deployment
-
Build the project:
dotnet publish -c Release -o ./publish -
Copy the
publishfolder to your desired location -
Configure the
appsettings.jsonfile (see Configuration section below) -
Edit
InstallServiceByNssm.batto set your preferred service name and path -
Run
InstallServiceByNssm.batas administrator to install the service -
The service will start automatically
Docker Deployment
-
Build the Docker image:
docker build -t hua.ddns . -
Run the container:
docker run -d \ -v /path/to/appsettings.json:/app/appsettings.json \ -v /path/to/logs:/app/Log \ hua.ddns
Configuration
Basic Configuration
Configure the appsettings.json file with your settings:
{
"ConnectionStrings": {
"pgConnection": "Host=127.0.0.1;Port=5432;Database=Worker;Username=Worker;Password=123456;"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"App": {
"GetIpv4Url": "http://47.108.74.59:8001/api/NetWork/GetIp",
"AppJob": {
"Corn": "0/5 * * * * ?"
}
},
"DDNS": {
"Platform": 2,
"Domain": "example.com",
"SubDomainArray": [ "www", "api", "dev" ],
"type": "A",
"time": "30"
},
"SslDownload": {
"Enabled": true,
"Corn": "0 0 2 * * ?",
"Platform": 2,
"SavePath": "D:\\Paths\\ssl",
"ExpireDays": 10000,
"DownloadItems": [
{
"Domain": "www.example.com",
"FileName": "www.example.com.pem"
}
]
},
"TencentCloud": {
"SecretId": "your-secret-id",
"SecretKey": "your-secret-key",
"Region": "ap-guangzhou",
"Dnspod": {
"Endpoint": "dnspod.tencentcloudapi.com"
}
},
"AliCloud": {
"AccessKeyId": "your-access-key-id",
"AccessKeySecret": "your-access-key-secret",
"RegionId": "cn-hangzhou",
"Endpoint": "alidns.cn-hangzhou.aliyuncs.com"
},
"Namesilo": {
"ApiKey": "your-api-key"
}
}
Configuration Details
DDNS Configuration
- Platform: DNS provider selection
1: Alibaba Cloud2: Tencent Cloud (DnsPod)3: Namesilo
- Domain: Your main domain name
- SubDomainArray: List of subdomains to update
- type: DNS record type (A, AAAA, etc.)
- time: Update interval in seconds
SSL Download Configuration
- Enabled: Enable/disable SSL certificate download
- Corn: Cron expression for download schedule
- Platform: SSL provider (same as DDNS Platform)
- SavePath: Directory to save SSL certificates
- ExpireDays: Days before certificate expiration to trigger download
- DownloadItems: List of domains and filenames for certificates
Cron Expressions
Use Cron Expression Generator to create custom schedules.
Examples:
0/5 * * * * ?- Every 5 seconds0 0 2 * * ?- Every day at 2:00 AM0 0 * * * ?- Every hour
Building
Prerequisites
- .NET 8.0 SDK
Build Steps
-
Clone the repository:
git clone <repository-url> cd Hua.DDNS -
Restore dependencies:
dotnet restore -
Build the solution:
dotnet build -c Release -
Run the application:
dotnet run --project Hua.DDNS/Hua.DDNS.csproj
Project Structure
Hua.DDNS/
├── Common/ # Common utilities and helpers
│ ├── Config/ # Configuration classes and options
│ ├── Http/ # HTTP helper classes
│ ├── FileHelper.cs
│ └── SqlHelper.cs
├── DDNSProviders/ # DNS provider implementations
│ ├── Ali/ # Alibaba Cloud DNS provider
│ ├── Dnspod/ # Tencent Cloud DNS provider
│ ├── Namesilo/ # Namesilo DNS provider
│ └── ...
├── Jobs/ # Scheduled jobs
│ ├── AppJob.cs
│ ├── NewJob.cs
│ └── SslDownloadJob.cs
├── Models/ # Data models
├── SslProviders/ # SSL certificate providers
│ ├── Ali/ # Alibaba Cloud SSL provider
│ └── Tencent/ # Tencent Cloud SSL provider
└── Start/ # Application entry point
License
This project is licensed under the MIT License - see the LICENSE.txt file for details.
Support
For issues and questions, please open an issue on the project repository.