From c78e7a248c0a5b9e52c3a81e6e10c2402d9253ea Mon Sep 17 00:00:00 2001 From: ShaoHua <345265198@qqcom> Date: Thu, 1 Jan 2026 23:15:00 +0800 Subject: [PATCH] reload readme doc --- README.md | 214 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 185 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 08c6591..c056422 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,67 @@ -## Purpose +# Hua.DDNS -A system service for dynamic update DNS record by `net6` with `Quartz.Net`. only Support [DnsPod](https://docs.dnspod.cn/api/add-domain/)、[AlibabaCloud]([阿里云 OpenAPI 开发者门户 (aliyun.com)](https://next.api.aliyun.com/document/Alidns/2015-01-09))、[Namesilo](https://www.namesilo.com/api-reference) +A dynamic DNS update system service built with .NET 8.0 and Quartz.Net. -## Deploy +## Features -1. Copy the folder `\bin\Debug\net6.0` to a new path and open it . -2. Configure the `App` option in `appsetting.json` file. -3. In Windows system, configure the service name in `InstallServiceByNssm.bat` file , and then double click the BAT file. +- **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 -## Building -Check and configure the `App` option in `appsetting.json` file, and then click the `Hua.DDNS.sln` file open the solution. +## 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 -Example of config in `appsetting.json` +### Basic Configuration + +Configure the `appsettings.json` file with your settings: + ```json { "ConnectionStrings": { @@ -26,32 +74,140 @@ Example of config in `appsetting.json` } }, "App": { + "GetIpv4Url": "http://47.108.74.59:8001/api/NetWork/GetIp", "AppJob": { - "Corn": "* * * * * ?" //https://cron.qqe2.com/ + "Corn": "0/5 * * * * ?" } }, "DDNS": { - "Platform": 3, //1 Ali 2 Tencent 3 Namesilo - // 主域名 - "Domain": "we965.com", - // 子域名前缀 - "SubDomainArray": [ "git", "webutil", "dev" ], - // 记录类型 + "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": "1111" - }, - "Dnspod": { - "Id": "1111", - "Key": "1111", - "Endpoint": "1111" - }, - "Ali": { - "Id": "1111", - "Key": "1111", - "Endpoint": "1111" + "ApiKey": "your-api-key" } -} \ No newline at end of file +} +``` + +### 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. \ No newline at end of file