|
|
@@ -1,32 +1,34 @@
|
|
|
# DDNS JSON Configuration File Reference
|
|
|
|
|
|
-This document provides detailed information about the DDNS JSON configuration file format and parameters. JSON configuration files have priority between command line arguments and environment variables.
|
|
|
+This document provides detailed information about the JSON configuration file format and parameters for the DDNS tool. JSON configuration files have priority between command line arguments and environment variables.
|
|
|
|
|
|
## Basic Usage
|
|
|
|
|
|
-By default, DDNS looks for a `config.json` file in the current directory. You can also specify a configuration file path using the `-c` parameter:
|
|
|
+By default, DDNS looks for a `config.json` file in the current directory. You can also use the `-c` parameter to specify a configuration file path:
|
|
|
|
|
|
-* Current directory `config.json` (note that Docker working directory is `/ddns/`)
|
|
|
+* Current directory `config.json` (note that Docker runtime directory is `/ddns/`)
|
|
|
* Current user directory `~/.ddns/config.json`
|
|
|
* Linux system directory `/etc/ddns/config.json`
|
|
|
|
|
|
-> Note: When using configuration files in Docker, you need to mount the configuration file to the container's `/ddns/` directory through volume mapping. For details, please refer to the [Docker Usage Documentation](docker.en.md).
|
|
|
+> Note: When using configuration files in Docker, you need to mount the configuration file to the container's `/ddns/` directory through volume mapping. For details, please refer to the [Docker documentation](docker.en.md).
|
|
|
|
|
|
```bash
|
|
|
-# Use default configuration file
|
|
|
-# Will auto-generate configuration file if none exists
|
|
|
-ddns
|
|
|
+# Generate configuration file
|
|
|
+ddns --new-config
|
|
|
+# Specify parameters and configuration file
|
|
|
+ddns --dns dnspod --ipv4 ddns.newfuture.cc --new-config config.json
|
|
|
|
|
|
# Use specified configuration file
|
|
|
ddns -c /path/to/config.json
|
|
|
-
|
|
|
-# Or using Python source code
|
|
|
+# Or use Python source code
|
|
|
python -m ddns -c /path/to/config.json
|
|
|
```
|
|
|
|
|
|
## JSON Schema
|
|
|
|
|
|
-DDNS configuration files follow JSON Schema, and it's recommended to add the `$schema` field to your configuration file for editor auto-completion and validation:
|
|
|
+DDNS configuration files follow JSON Schema standards. It's recommended to add the `$schema` field to your configuration file for editor auto-completion and validation features:
|
|
|
+
|
|
|
+Since v4.1.0, configuration files support single-line comments.
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
@@ -34,449 +36,197 @@ DDNS configuration files follow JSON Schema, and it's recommended to add the `$s
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-## Configuration Parameters Table
|
|
|
-
|
|
|
-| Key | Type | Required | Default Value | Description | Notes |
|
|
|
-| :------: | :----------------: | :------: | :-----------: | :------------------: | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
-| id | string | Yes | None | API Access ID | Cloudflare uses email (leave empty when using Token)<br>HE.net can be empty<br>Huawei Cloud uses Access Key ID (AK) |
|
|
|
-| token | string | Yes | None | API Authorization Token | Some platforms call it secret key |
|
|
|
-| endpoint | string | No | None | API Endpoint URL | For custom or private API deployments, uses default endpoint when empty |
|
|
|
-| dns | string | No | `"dnspod"` | DNS Provider | Available values: 51dns, alidns, aliesa, callback, cloudflare, debug, dnscom, dnspod_com, dnspod, he, huaweidns, noip, tencentcloud |
|
|
|
-| ipv4 | array | No | `[]` | IPv4 Domain List | When `[]`, IPv4 address will not be retrieved and updated |
|
|
|
-| ipv6 | array | No | `[]` | IPv6 Domain List | When `[]`, IPv6 address will not be retrieved and updated |
|
|
|
-| index4 | string\|int\|array | No | `["default"]` | IPv4 Detection Method | See detailed explanation below |
|
|
|
-| index6 | string\|int\|array | No | `["default"]` | IPv6 Detection Method | See detailed explanation below |
|
|
|
-| ttl | number | No | `null` | DNS Resolution TTL | In seconds, uses DNS default policy when not set |
|
|
|
-| line | string | No | `null` | DNS Resolution Line | ISP line selection, supported values depend on DNS provider, e.g., `"default"`, `"telecom"`, `"unicom"`, `"mobile"`, etc. |
|
|
|
-| proxy | string\|array | No | None | HTTP Proxy | Multiple proxies are tried one by one until success, `DIRECT` means direct connection |
|
|
|
-| ssl | string\|boolean | No | `"auto"` | SSL Certificate Verification | `true` (force verification), `false` (disable verification), `"auto"` (auto fallback), or custom CA certificate file path |
|
|
|
-| cache | string\|bool | No | `true` | Enable Record Caching | Normally enabled to avoid frequent updates, default location is `ddns.{hash}.cache` in temp directory, can specify custom path |
|
|
|
-| log | object | No | `null` | Log Configuration (Optional) | Log configuration object, supports `level`, `file`, `format`, `datefmt` parameters |
|
|
|
-
|
|
|
-### log Object Parameters
|
|
|
-
|
|
|
-| Key | Type | Required | Default Value | Description |
|
|
|
-| :-----: | :----: | :------: | :-------------------------------------: | :--------------------: |
|
|
|
-| level | string | No | `INFO` | Log Level |
|
|
|
-| file | string | No | None | Log File Path |
|
|
|
-| format | string | No | `%(asctime)s %(levelname)s [%(module)s]: %(message)s` | Log Format String |
|
|
|
-| datefmt | string | No | `%Y-%m-%dT%H:%M:%S` | Date Time Format |
|
|
|
-
|
|
|
-### index4 and index6 Parameters
|
|
|
-
|
|
|
-The `index4` and `index6` parameters specify IP address detection methods and can use the following values:
|
|
|
-
|
|
|
-* **Number** (e.g., `0`, `1`, `2`...): Use IP address of the Nth network interface
|
|
|
-* **String**:
|
|
|
- * `"default"`: System's default external IP
|
|
|
- * **Comma or semicolon-separated strings**: Support using comma `,` or semicolon `;` to separate multiple detection methods, e.g., `"public,regex:192\\.168\\..*"`
|
|
|
-* **Boolean**: `false` means disable updating corresponding IP type DNS records
|
|
|
-* **Array**: Try different detection methods in order, use the first successful result
|
|
|
-
|
|
|
-## DNS Provider Values
|
|
|
-
|
|
|
-DDNS supports the following DNS providers:
|
|
|
-
|
|
|
-* **51dns**: DNS.COM service (alias for dnscom)
|
|
|
-* **alidns**: Alibaba Cloud DNS
|
|
|
-* **aliesa**: Alibaba Cloud ESA (Edge Security Acceleration)
|
|
|
-* **callback**: Custom callback/webhook
|
|
|
-* **cloudflare**: Cloudflare DNS
|
|
|
-* **debug**: Debug provider (prints IP without updating DNS)
|
|
|
-* **dnscom**: DNS.COM service (same as 51dns)
|
|
|
-* **dnspod**: DNSPod (China)
|
|
|
-* **dnspod_com**: DNSPod International
|
|
|
-* **he**: Hurricane Electric DNS
|
|
|
-* **huaweidns**: Huawei Cloud DNS
|
|
|
-* **noip**: No-IP Dynamic DNS
|
|
|
-* **tencentcloud**: Tencent Cloud DNS
|
|
|
-
|
|
|
-## Custom Callback Configuration
|
|
|
-
|
|
|
-When `dns` is set to `callback`, you can configure custom callbacks as follows:
|
|
|
-
|
|
|
-* `id` field: Fill in the callback URL starting with HTTP or HTTPS, supports variable substitution
|
|
|
-* `token` field: POST request parameters (JSON object or JSON string), uses GET method when empty
|
|
|
-
|
|
|
-For detailed configuration, please refer to: [Callback Provider Configuration Documentation](providers/callback.en.md)
|
|
|
-
|
|
|
-Supported variable substitutions:
|
|
|
-
|
|
|
-| Variable Name | Content | Description |
|
|
|
-|---------------|---------|-------------|
|
|
|
-| `__DOMAIN__` | Full domain name | e.g., `www.example.com` |
|
|
|
-| `__IP__` | IP address | IPv4 or IPv6 address |
|
|
|
-| `__RECORDTYPE__` | DNS record type | e.g., `A`, `AAAA`, `CNAME` |
|
|
|
-| `__TTL__` | Time to live | TTL value in seconds |
|
|
|
-| `__LINE__` | Resolution line | ISP line identifier |
|
|
|
-| `__TIMESTAMP__` | Current timestamp | Unix timestamp |
|
|
|
-
|
|
|
-## Configuration Examples
|
|
|
-
|
|
|
-### Basic Configuration
|
|
|
+## Schema
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
|
|
|
- "dns": "cloudflare",
|
|
|
- "id": "[email protected]",
|
|
|
- "token": "your_cloudflare_token",
|
|
|
- "ipv4": ["example.com"]
|
|
|
-}
|
|
|
-```
|
|
|
+Configuration Parameters Table
|
|
|
|
|
|
-### Advanced Configuration
|
|
|
+| Key Name | Type | Required | Default Value | Parameter Description | Notes |
|
|
|
+| :------: | :--: | :------: | :-----------: | :------------------: | ----- |
|
|
|
+| dns | string | No | None | DNS Provider | Available values: 51dns, alidns, aliesa, callback, cloudflare, debug, dnscom, dnspod_com, dnspod, he, huaweidns, namesilo, noip, tencentcloud |
|
|
|
+| id | string | Yes | None | API Access ID | Configure according to provider documentation (e.g., AccessKeyID) |
|
|
|
+| token | string | Yes | None | API Authorization Token | Configure according to provider documentation (e.g., AccessSecret) |
|
|
|
+| endpoint | string | No | None | API Endpoint URL | For custom or private deployment API addresses, uses default endpoint when empty |
|
|
|
+| ipv4 | array | No | `[]` | IPv4 Domain List | |
|
|
|
+| ipv6 | array | No | `[]` | IPv6 Domain List | |
|
|
|
+| index4 | string\|int\|array | No | `["default"]` | IPv4 Retrieval Method | [See details below](#ipv4-ipv6) |
|
|
|
+| index6 | string\|int\|array | No | `["default"]` | IPv6 Retrieval Method | [See details below](#ipv4-ipv6) |
|
|
|
+| ttl | number | No | `null` | DNS TTL Time | In seconds, uses DNS default policy when not set |
|
|
|
+| line | string | No | `null` | DNS Resolution Line | ISP line selection, supported values depend on DNS provider |
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
|
|
|
- "dns": "cloudflare",
|
|
|
- "id": "[email protected]",
|
|
|
- "token": "your_cloudflare_token",
|
|
|
- "ipv4": ["example.com", "www.example.com", "api.example.com"],
|
|
|
- "ipv6": ["ipv6.example.com"],
|
|
|
- "index4": ["public", "default"],
|
|
|
- "index6": "public",
|
|
|
- "ttl": 600,
|
|
|
- "proxy": ["127.0.0.1:1080", "DIRECT"],
|
|
|
- "cache": "/var/cache/ddns.json",
|
|
|
- "ssl": true,
|
|
|
- "log": {
|
|
|
- "level": "INFO",
|
|
|
- "file": "/var/log/ddns.log",
|
|
|
- "format": "%(asctime)s [%(levelname)s] %(message)s",
|
|
|
- "datefmt": "%Y-%m-%d %H:%M:%S"
|
|
|
- }
|
|
|
-}
|
|
|
-```
|
|
|
+### dns
|
|
|
|
|
|
-### Provider-Specific Examples
|
|
|
+The `dns` parameter specifies the DNS provider identifier. For supported values, please refer to the [Provider List](providers/README.en.md):
|
|
|
|
|
|
-#### Cloudflare (Email + API Key)
|
|
|
+> When in debug mode and no dns parameter is configured, the debug provider is used.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "id": "[email protected]",
|
|
|
- "token": "your_api_key",
|
|
|
- "ipv4": ["example.com", "www.example.com"]
|
|
|
-}
|
|
|
-```
|
|
|
+### id and token
|
|
|
|
|
|
-#### Cloudflare (API Token Only)
|
|
|
+The `id` and `token` parameters are used for API authentication. Their specific meaning and format depend on the selected DNS provider.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_api_token",
|
|
|
- "ipv4": ["example.com", "www.example.com"]
|
|
|
-}
|
|
|
-```
|
|
|
+### endpoint
|
|
|
|
|
|
-#### DNSPod
|
|
|
+The `endpoint` parameter is used to specify a custom API endpoint. Most providers have default endpoints, so modification is not needed unless there are special requirements.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "dnspod",
|
|
|
- "id": "12345",
|
|
|
- "token": "your_dnspod_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "line": "默认"
|
|
|
-}
|
|
|
-```
|
|
|
+Special cases include:
|
|
|
|
|
|
-#### Alibaba Cloud DNS
|
|
|
+* Providers with regional deployment (such as Tencent Cloud, Alibaba Cloud, etc.) need to specify the corresponding regional API endpoint.
|
|
|
+* **Private Cloud Deployment**: If you're using a privately deployed DNS service, you need to specify the corresponding private API endpoint address.
|
|
|
+* **Proxy Forwarding**: If you're using a third-party API proxy service, you need to specify the proxy URL.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "alidns",
|
|
|
- "id": "LTAI4xxxxxxxxxxxxx",
|
|
|
- "token": "your_secret_key",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "line": "default"
|
|
|
-}
|
|
|
-```
|
|
|
+### ipv4-ipv6
|
|
|
|
|
|
-#### Alibaba Cloud ESA
|
|
|
+The `ipv4` and `ipv6` parameters specify the DNS record names to be updated, which can be domain or subdomain lists. You can use array format to specify multiple records.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "aliesa",
|
|
|
- "id": "LTAI4xxxxxxxxxxxxx",
|
|
|
- "token": "your_secret_key",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "endpoint": "https://esa.ap-southeast-1.aliyuncs.com"
|
|
|
-}
|
|
|
-```
|
|
|
+Supported formats:
|
|
|
|
|
|
-#### No-IP
|
|
|
+* When empty, the corresponding IP type DNS records will not be updated.
|
|
|
+* **Single domain**: `"ddns.newfuture.cc"`
|
|
|
+* **Multiple domains**: `["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"]`
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "noip",
|
|
|
- "id": "your_username",
|
|
|
- "token": "your_password",
|
|
|
- "ipv4": ["home.example.com"],
|
|
|
- "endpoint": "https://dynupdate.no-ip.com"
|
|
|
-}
|
|
|
-```
|
|
|
+### index4-index6
|
|
|
|
|
|
-#### Custom Callback (GET)
|
|
|
+The `index4` and `index6` parameters are used to specify the method for obtaining IP addresses. The following values can be used:
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "callback",
|
|
|
- "id": "https://api.example.com/ddns?domain=__DOMAIN__&ip=__IP__",
|
|
|
- "token": "",
|
|
|
- "ipv4": ["example.com"]
|
|
|
-}
|
|
|
-```
|
|
|
+Supported types:
|
|
|
+
|
|
|
+* `false` indicates prohibition of updating the corresponding IP type DNS records
|
|
|
+* **Numbers** (such as `0`, `1`, `2`...): Use the IP address of the Nth network interface
|
|
|
+* `"default"`: System's default IP for external network access
|
|
|
+* `"public"`: Use public IP (queried through API)
|
|
|
+* `"url:http..."`: Get IP through specified URL, e.g., `"url:http://ip.sb"`
|
|
|
+* `"regex:xxx"`: Use regular expression to match IP in local network configuration, e.g., `"regex:192\\.168\\..*"`
|
|
|
+ * Note: Backslashes need to be escaped in JSON, e.g., `"regex:10\\.00\\..*"` matches IPs starting with `10.00.`
|
|
|
+* `"cmd:xxx"`: Execute specified command and use its output as IP
|
|
|
+* `"shell:xxx"`: Use system shell to run command and use its output as IP
|
|
|
|
|
|
-#### Custom Callback (POST)
|
|
|
+Configuration examples:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
- "dns": "callback",
|
|
|
- "id": "https://api.example.com/ddns",
|
|
|
- "token": {
|
|
|
- "api_key": "your_key",
|
|
|
- "domain": "__DOMAIN__",
|
|
|
- "ip": "__IP__",
|
|
|
- "timestamp": "__TIMESTAMP__"
|
|
|
- },
|
|
|
- "ipv4": ["example.com"]
|
|
|
+ "index4": ["public", "url:http://ipv4.icanhazip.com"], // Prefer public IP, fallback to specified URL
|
|
|
+ "index6": ["shell:ip route", "regex:2003:.*"], // Use shell command, fallback to regex matching IPv6 addresses
|
|
|
+ "index4": [0, "public"], // Use first network interface IP, fallback to public IP
|
|
|
+ "index6": "public", // Use public IPv6 address
|
|
|
+ "index4": false // Disable IPv4 record updates
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-#### Custom Endpoint
|
|
|
+### ttl
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "endpoint": "https://api.private-cloudflare.com",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"]
|
|
|
-}
|
|
|
-```
|
|
|
+The `ttl` parameter specifies the Time To Live (TTL) for DNS records in seconds. The default value is `null`, which means using the DNS provider's default TTL policy.
|
|
|
+The specific value range and default value depend on the selected DNS provider.
|
|
|
|
|
|
-### IP Detection Configuration
|
|
|
+### line
|
|
|
|
|
|
-#### Multiple Detection Methods
|
|
|
+The `line` parameter is used to specify DNS resolution lines. Supported values depend on the selected DNS provider.
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "index4": ["public", "default", "regex:192\\.168\\..*"],
|
|
|
- "index6": ["public", 0, 1]
|
|
|
-}
|
|
|
-```
|
|
|
+### proxy
|
|
|
|
|
|
-#### Custom URL Detection
|
|
|
+The `proxy` parameter is used to set HTTP proxy, which can be a single proxy address or an array of multiple proxy addresses. The following formats are supported:
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "index4": "url:https://api.ipify.org",
|
|
|
- "index6": "url:https://api6.ipify.org"
|
|
|
-}
|
|
|
-```
|
|
|
+Proxy types:
|
|
|
|
|
|
-#### Command-based Detection
|
|
|
+* http: `"http://<proxy_host>:<proxy_port>"`
|
|
|
+* https: `"https://<proxy_host>:<proxy_port>"`
|
|
|
+* No proxy: `"DIRECT"`
|
|
|
+
|
|
|
+Configuration examples:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "index4": "cmd:hostname -I | awk '{print $1}'",
|
|
|
- "index6": "cmd:ip -6 addr show | grep global | awk '{print $2}' | cut -d/ -f1"
|
|
|
+ "proxy": "http://127.0.0.1:1080", // Single proxy address
|
|
|
+ "proxy": ["http://127.0.0.1:1080","DIRECT"], // Try proxy first, fallback to direct connection
|
|
|
+ "proxy": null // No proxy
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-### Network Configuration
|
|
|
+> Note: If `proxy` is configured, the proxy only applies to provider requests; IP retrieval APIs will not use the proxy parameter.
|
|
|
|
|
|
-#### Proxy Configuration
|
|
|
+### ssl
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "proxy": [
|
|
|
- "127.0.0.1:1080",
|
|
|
- "socks5://127.0.0.1:1081",
|
|
|
- "http://user:[email protected]:8080",
|
|
|
- "DIRECT"
|
|
|
- ]
|
|
|
-}
|
|
|
-```
|
|
|
+The `ssl` parameter is used to configure SSL verification method. The following values are supported:
|
|
|
|
|
|
-#### SSL Configuration
|
|
|
+* `"auto"`: Auto downgrade to not verify SSL certificates (less secure)
|
|
|
+* `true`: Force SSL certificate verification
|
|
|
+* `false`: Disable SSL verification (insecure)
|
|
|
+* `"/path/to/ca.crt"`: Specify custom CA certificate file
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "ssl": "auto"
|
|
|
-}
|
|
|
-```
|
|
|
+> Note: If `ssl` is configured, all API requests, including provider and IP retrieval APIs, will use this configuration.
|
|
|
|
|
|
-Or with custom CA certificate:
|
|
|
+### cache
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "ssl": "/path/to/custom-ca.pem"
|
|
|
-}
|
|
|
-```
|
|
|
+The `cache` parameter is used to configure DNS record caching method. The following values are supported:
|
|
|
|
|
|
-### Logging Configuration
|
|
|
+* `true`: Enable caching, default location is `ddns.{hash}.cache` in the temporary directory
|
|
|
+* `false`: Disable caching
|
|
|
+* `"/path/to/cache.file"`: Specify custom cache file path
|
|
|
|
|
|
-#### Basic Logging
|
|
|
+### log
|
|
|
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "log": {
|
|
|
- "level": "DEBUG",
|
|
|
- "file": "/var/log/ddns.log"
|
|
|
- }
|
|
|
-}
|
|
|
-```
|
|
|
+The `log` parameter is used to configure logging. It's an object that supports the following fields:
|
|
|
|
|
|
-#### Advanced Logging
|
|
|
+| Key Name | Type | Required | Default Value | Description |
|
|
|
+| :------: | :--: | :------: | :-----------: | :---------: |
|
|
|
+| level | string | No | `INFO` | Log level |
|
|
|
+| file | string | No | None | Log file path |
|
|
|
+| format | string | No | Auto-adjusted | Log format string |
|
|
|
+| datefmt | string | No | `%Y-%m-%dT%H:%M:%S` | Date time format |
|
|
|
+
|
|
|
+## Configuration Example
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
+ "$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
|
|
|
+ "id": "12345",
|
|
|
+ "token": "mytokenkey",
|
|
|
"dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
+ "ipv4": ["ddns.newfuture.cc"],
|
|
|
+ "ipv6": ["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"],
|
|
|
+ "index4": ["public", "regex:192\\.168\\.1\\..*"],
|
|
|
+ "index6": "public",
|
|
|
+ "ttl": 300,
|
|
|
+ "proxy": ["http://127.0.0.1:1080", "DIRECT"],
|
|
|
+ "ssl": "auto",
|
|
|
+ "cache": "/var/cache/ddns.cache",
|
|
|
"log": {
|
|
|
- "level": "INFO",
|
|
|
+ "level": "DEBUG",
|
|
|
"file": "/var/log/ddns.log",
|
|
|
- "format": "[%(asctime)s] %(levelname)s: %(message)s",
|
|
|
"datefmt": "%Y-%m-%d %H:%M:%S"
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
-### Cache Configuration
|
|
|
-
|
|
|
-#### Default Cache
|
|
|
-
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "cache": true
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-#### Custom Cache Location
|
|
|
-
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "cache": "/var/cache/ddns/custom.json"
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-#### Disable Cache
|
|
|
-
|
|
|
-```json
|
|
|
-{
|
|
|
- "dns": "cloudflare",
|
|
|
- "token": "your_token",
|
|
|
- "ipv4": ["example.com"],
|
|
|
- "cache": false
|
|
|
-}
|
|
|
-```
|
|
|
-
|
|
|
-## Configuration File Locations
|
|
|
-
|
|
|
-DDNS searches for configuration files in the following order:
|
|
|
-
|
|
|
-1. **Command line specified**: `-c /path/to/config.json`
|
|
|
-2. **Current directory**: `./config.json`
|
|
|
-3. **User home directory**: `~/.ddns/config.json`
|
|
|
-4. **System directory**: `/etc/ddns/config.json`
|
|
|
-
|
|
|
-The first found configuration file will be used.
|
|
|
-
|
|
|
-## Configuration Validation
|
|
|
-
|
|
|
-DDNS validates the configuration file and provides helpful error messages for invalid configurations:
|
|
|
-
|
|
|
-* **Required fields**: `id` and `token` are required for most providers
|
|
|
-* **Domain format**: Domains must be valid DNS names
|
|
|
-* **Array format**: Domain lists must be arrays of strings
|
|
|
-* **Number format**: TTL must be a positive integer
|
|
|
-* **URL format**: Endpoints must be valid URLs
|
|
|
-
|
|
|
-## Configuration Generation
|
|
|
-
|
|
|
-You can generate a template configuration file using the `--new-config` command line parameter:
|
|
|
-
|
|
|
-```bash
|
|
|
-# Generate default config.json
|
|
|
-ddns --new-config
|
|
|
-
|
|
|
-# Generate with custom filename
|
|
|
-ddns --new-config=my-config.json
|
|
|
-
|
|
|
-# Generate with pre-filled values
|
|
|
-ddns --new-config --dns cloudflare --id [email protected] --token your_token
|
|
|
-```
|
|
|
-
|
|
|
-## Configuration Priority
|
|
|
-
|
|
|
-DDNS uses the following priority order (highest to lowest):
|
|
|
-
|
|
|
-1. **Command line arguments** (highest priority)
|
|
|
-2. **JSON configuration file**
|
|
|
-3. **Environment variables** (lowest priority)
|
|
|
-
|
|
|
-This means command line arguments will override any settings in configuration files or environment variables.
|
|
|
-
|
|
|
-## Best Practices
|
|
|
+## Configuration Priority and Field Override Relationships
|
|
|
|
|
|
-### Security
|
|
|
+The configuration priority order in the DDNS tool is: **Command Line Arguments > JSON Configuration File > Environment Variables**.
|
|
|
|
|
|
-* Store sensitive tokens in separate files with restricted permissions
|
|
|
+* **Command Line Arguments**: Highest priority, will override the same settings in JSON configuration files and environment variables
|
|
|
+* **JSON Configuration File**: Between command line arguments and environment variables, will override settings in environment variables
|
|
|
+* **Environment Variables**: Lowest priority, used when there are no corresponding settings in command line arguments and JSON configuration files
|
|
|
|
|
|
-* Use environment variables for tokens in containerized environments
|
|
|
-* Never commit configuration files with real tokens to version control
|
|
|
+### Configuration Override Example
|
|
|
|
|
|
-### Reliability
|
|
|
+Assuming the following configuration:
|
|
|
|
|
|
-* Use multiple IP detection methods for fallback
|
|
|
+1. **Environment Variable**: `DDNS_TTL=600`
|
|
|
+2. **JSON Configuration File**: `"ttl": 300`
|
|
|
+3. **Command Line Argument**: `--ttl 900`
|
|
|
|
|
|
-* Configure appropriate TTL values for your use case
|
|
|
-* Enable caching to avoid rate limiting
|
|
|
-* Set up proper logging for troubleshooting
|
|
|
+The final effective value is from the command line argument: `ttl=900`
|
|
|
|
|
|
-### Performance
|
|
|
+If no command line argument is provided, the JSON configuration value is used: `ttl=300`
|
|
|
|
|
|
-* Use `"auto"` SSL mode for automatic fallback
|
|
|
+### Special Cases
|
|
|
|
|
|
-* Configure multiple proxy servers for redundancy
|
|
|
-* Set reasonable TTL values to balance speed and reliability
|
|
|
+* When a value in the JSON configuration file is explicitly set to `null`, it will override environment variable settings, equivalent to not setting that value
|
|
|
+* When a key is missing from the JSON configuration file, the corresponding environment variable will be attempted
|
|
|
+* Some parameters (such as `debug`) are only effective under specific configuration methods: the `debug` parameter is only effective in command line, settings in JSON configuration will be ignored
|
|
|
|
|
|
-## See Also
|
|
|
+## Notes
|
|
|
|
|
|
-* [Command Line Arguments](cli.en.md)
|
|
|
-* [Environment Variables Configuration](env.en.md)
|
|
|
-* [Docker Usage](docker.en.md)
|
|
|
-* [Provider-specific Configuration](providers/)
|
|
|
+1. Configuration files use UTF-8 encoding without BOM
|
|
|
+2. All key names in JSON are case-sensitive
|
|
|
+3. For strings that need to use backslashes (such as regular expressions) in configuration files, double escaping is required
|
|
|
+4. The `debug` parameter is ineffective when set in configuration files, only supports command line parameter `--debug`
|
|
|
+5. A template configuration file will be automatically generated in the current directory on first run
|
|
|
+6. It's recommended to use editors that support JSON Schema (such as VSCode) to edit configuration files for auto-completion and validation features
|