# 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](https://docs.dnspod.cn/api/add-domain/) (Tencent Cloud) - [Alibaba Cloud DNS](https://next.api.aliyun.com/document/Alidns/2015-01-09) - [Namesilo](https://www.namesilo.com/api-reference) - **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 1. Build the project: ```bash dotnet publish -c Release -o ./publish ``` 2. Copy the `publish` folder to your desired location 3. Configure the `appsettings.json` file (see Configuration section below) 4. Edit `InstallServiceByNssm.bat` to set your preferred service name and path 5. Run `InstallServiceByNssm.bat` as administrator to install the service 6. The service will start automatically ### Docker Deployment 1. Build the Docker image: ```bash docker build -t hua.ddns . ``` 2. Run the container: ```bash 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: ```json { "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 Cloud - `2`: 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](https://cron.qqe2.com/) to create custom schedules. Examples: - `0/5 * * * * ?` - Every 5 seconds - `0 0 2 * * ?` - Every day at 2:00 AM - `0 0 * * * ?` - Every hour ## Building ### Prerequisites - .NET 8.0 SDK ### Build Steps 1. Clone the repository: ```bash git clone cd Hua.DDNS ``` 2. Restore dependencies: ```bash dotnet restore ``` 3. Build the solution: ```bash dotnet build -c Release ``` 4. Run the application: ```bash 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](LICENSE.txt) file for details. ## Support For issues and questions, please open an issue on the project repository.