f99fd8f0b3 feat(provider): add EdgeOne DNS provider for non-accelerated domain records (#588)
* Initial plan

* feat(provider): add EdgeOne DNS provider for non-accelerated domains

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(provider): add EdgeOne DNS documentation for non-accelerated domains

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* fix(provider): update EdgeOne provider aliases per feedback

- Acceleration domains: edgeone, edgeone_acc, teo_acc
- DNS records: edgeone_dns, teo_dns, edgeone_noacc
- Removed: teo, tencentedgeone, neo_acc, neo
- Updated documentation to reflect new aliases

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* feat(provider): add extra parameter support and update documentation index

- Add edgeone_dns to provider index documentation (README.md)
- Add "teo" alias for backward compatibility (not documented)
- Enable EdgeOneProvider to support both acceleration and DNS records via extra['dns_record'] parameter
- Update provider aliases and documentation

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs: create comprehensive new-provider agent guide

- Add detailed step-by-step guide for creating new DNS providers
- Include API analysis, implementation, testing, and documentation steps
- Provide code templates and examples for both BaseProvider and SimpleProvider
- Add completion checklist and common pitfalls
- Document all requirements including compatibility checks and index updates

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(provider): change extra parameter from dns_record to teoDomainType

- Change EdgeOneProvider to use teoDomainType parameter instead of dns_record
- Support values: "dns" or "acceleration" (default)
- Parameter is case-insensitive
- EdgeOneDnsProvider now uses extra parameter to control behavior
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(provider): simplify EdgeOneDnsProvider with helper method

- Extract common extra parameter preparation into _prepare_extra() method
- Reduces code duplication across _query_record, _create_record, _update_record
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(provider): make EdgeOneDnsProvider more elegant and concise

- Use class attribute _default_domain_type = "dns" for clarity
- Replace _prepare_extra() with inline setdefault() for more Pythonic code
- setdefault() allows users to override teoDomainType if needed
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(provider): use options instead of extra for teoDomainType

- Move teoDomainType from per-call extra to instance-level options
- More appropriate since provider type is fixed per instance
- EdgeOneProvider reads teoDomainType from self.options at initialization
- EdgeOneDnsProvider sets teoDomainType="dns" in __init__
- Simplified implementation: 28 lines vs 43 lines for EdgeOneDnsProvider
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(provider): support both extra and options for teoDomainType with priority

- Remove __init__ from EdgeOneProvider, read directly from self.options
- Support teoDomainType in both extra (per-call) and options (initialization)
- extra parameter has higher priority than options
- Priority: extra > options > default ("acceleration")
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(provider): add teoDomainType parameter documentation for EdgeOne

- Document how to switch between acceleration domains and DNS records
- Explain extra.teoDomainType parameter usage
- Add configuration examples for both modes
- Update parameter tables with teoDomainType and extra
- Document priority: extra > initialization parameter
- Add bilingual documentation (Chinese and English)

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(provider): remove initialization parameter config example from EdgeOne

- Remove the example showing teoDomainType via initialization parameters
- Only document usage via extra parameter
- Remove priority note since only one method is documented
- Keep recommendation to use EdgeOneDnsProvider for cleaner code
- Update both Chinese and English documentation

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(agent): update new-provider guide with relative paths and schema notes

- Update CLI compatibility note to mention checking --dns parameter choices
- Change schema note to only require v4.0 (latest format) updates
- Replace "multi-provider format" with "latest schema format"
- Convert all absolute paths to relative paths from project root
- Remove /home/runner/work/DDNS/DDNS/ prefix from all file paths

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(agent): correct latest schema version to v4.1

- Update schema compatibility section to reference v4.1 instead of v4.0
- v4.1 is the latest schema format that requires updates

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* feat(config): add edgeone_dns to CLI and schema v4.1

- Add edgeone_dns to CLI --dns parameter choices
- Add edgeone_dns to schema v4.1 provider enum (both legacy and multi-provider sections)
- Update provider descriptions to include EdgeOne DNS

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor labels_to_prompts_mapping format

* fix(provider): filter teoDomainType from extra params before API call

- Remove teoDomainType from extra dict before passing to Tencent Cloud API
- Fixes "UnknownParameter - The parameter `extra_teoDomainType` is not recognized" error
- teoDomainType is internal parameter for routing, not for API requests
- All 55 tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(provider): update schema references to v4.1.json in EdgeOne docs

- Update all $schema references from v4.0.json to v4.1.json
- Applied to edgeone.md, edgeone.en.md, edgeone_dns.md, edgeone_dns.en.md
- Ensures documentation references the latest schema format

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* Changes before error encountered

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* fix(config): preserve nested extra dict from JSON/ENV config

- Process "extra" dict before extra_ prefixed keys to avoid flattening
- Fixes issue where {"extra":{"teoDomainType":"dns"}} was incorrectly transformed to {"extra_teoDomainType":"dns"}
- Maintains backward compatibility with extra_ prefixed keys
- Priority: explicit extra dict > extra_ prefixed keys > unknown keys

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/test_provider_edgeone_dns.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update tests/test_provider_edgeone_dns.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* style: apply ruff formatting fixes

- Format 9 files with ruff
- Fix 2 linting issues automatically
- One complexity warning remains (C901) but doesn't affect functionality
- All code now follows consistent formatting standards

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(agent): add ruff installation instructions to new-provider guide

- Add pip3 install ruff command before formatting/linting steps
- Ensures developers have required tools before running verification
- Prevents common setup errors

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* docs(config): clarify extra dict and extra_ prefix priority within config sources

- Add comments explaining that extra_ prefixed keys override nested extra dict values within the same source
- Improves code documentation clarity for config flattening logic
- Addresses feedback about intra-source priority ordering

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

* refactor(config): reduce complexity of _collect_extra method

- Extract _process_extra_from_source helper method to reduce cyclomatic complexity
- Fixes ruff C901 error (complexity was 14, now under threshold)
- Maintains all existing functionality and test coverage
- All 60 extra-related tests passing

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Co-authored-by: New Future <NewFuture@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-15 16:44:59 +00:00
2025-07-15 00:48:45 +08:00
2018-07-22 16:42:58 +08:00
2025-06-03 13:33:05 +00:00
2019-05-01 22:55:09 +08:00
2025-06-18 16:53:10 +00:00

DDNS

Automatically update DNS records to the current IP address, supporting IPv4 and IPv6, local (private) IP and public IP. Proxy mode supported, with automatic DNS record creation.

Github Release PyPI Docker Image Version Build Status Publish


Features

Usage

① Installation

Choose one of the following methods: Docker, binary version, pip version, or source code execution.

Docker version is recommended for best compatibility, small size, and optimized performance.

  • For detailed instructions and advanced usage, see Docker Usage Documentation

    Supports command line, configuration file, and environment variable parameters
    • Command line CLI

      docker run newfuture/ddns -h
      
    • Using configuration file (Docker working directory /ddns/, default config location /ddns/config.json):

      docker run -d -v /host/config/:/ddns/ --network host newfuture/ddns
      
    • Using environment variables:

      docker run -d \
        -e DDNS_DNS=dnspod \
        -e DDNS_ID=12345 \
        -e DDNS_TOKEN=mytokenkey \
        -e DDNS_IPV4=ddns.newfuture.cc \
        --network host \
        newfuture/ddns
      
  • Binary Version (Single file, no Python required)

    Go to releases to download the corresponding version

    Or use the one‑click installation script to automatically download and install the binary for your platform:

    curl -#fSL https://ddns.newfuture.cc/install.sh | sh
    

    Note: Installing to system directories (e.g., /usr/local/bin) may require root or sudo; if permissions are insufficient, run as sudo sh.

    For detailed instructions, see Installation Documentation

  • pip Installation (Requires pip or easy_install)

    1. Install ddns: pip install ddns or easy_install ddns
    2. Run: ddns -h or python -m ddns
  • Source Code Execution (No dependencies, requires Python environment)

    1. Clone or download this repository and extract
    2. Run python -m ddns

② Quick Configuration

  1. Apply for API token, fill in the corresponding id and token fields:

  2. Modify the configuration file, ipv4 and ipv6 fields for domains to be updated, refer to configuration instructions for details

Detailed Configuration

All fields can be configured through three methods, with priority: Command Line Parameters > JSON Configuration File > Environment Variables

  1. Command Line Parameters ddns --key=value (use ddns -h for details), highest priority
  2. JSON Configuration File (null values are considered valid and will override environment variable settings; if no corresponding key exists, environment variables will be used)
  3. Environment Variables with DDNS_ prefix plus key in uppercase or lowercase, dots converted to underscores (${ddns_id} or ${DDNS_ID}, ${DDNS_LOG_LEVEL})

📖 Environment Variables Documentation: See Environment Variables Configuration for detailed usage and examples of all environment variables

config.json Configuration File
  • A template configuration file will be automatically generated on first run
  • Use -c to specify a configuration file (defaults to config.json in the current directory)
  • Recommended to use editors that support JsonSchema like VSCode for editing configuration files
  • See JSON Configuration File Documentation for complete configuration options and examples
ddns -c path/to/config.json
# Or run with Python
python -m ddns -c /path/to/config.json
# Remote configuration file
ddns -c https://ddns.newfuture.cc/tests/config/debug.json

Configuration Parameters Table

key type required default description tips
id string √ N/A API Access ID Cloudflare uses email (leave empty when using Token)
HE.net can be left empty
Huawei Cloud uses Access Key ID (AK)
token string √ N/A API Auth Token Some platforms call it secret key, remove when sharing feedback
dns string No "dnspod" DNS Provider Alibaba DNS: alidns, Alibaba ESA: aliesa, Cloudflare: cloudflare, DNS.COM: dnscom, DNSPOD China: dnspod, DNSPOD International: dnspod_com, HE.net: he, Huawei Cloud: huaweidns, NameSilo: namesilo, Tencent Cloud: tencentcloud, Tencent EdgeOne: edgeone, No-IP: noip, Custom Callback: callback. Some providers have detailed configuration docs
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 Get Method Can set network interface, private, public, regex etc.
index6 string|int|array No "default" IPv6 Get Method Can set network interface, private, public, regex etc.
ttl number No null DNS Resolution TTL Uses DNS default policy when not set
proxy string|array No N/A HTTP Proxy Format: http://host:port Multiple proxies tried sequentially until success, DIRECT for direct connection
ssl string|boolean No "auto" SSL Certificate Verification true (force verify), false (disable verify), "auto" (auto downgrade) or custom CA certificate file path
debug bool No false Enable Debug Debug mode, only effective with command line parameter --debug
cache string|bool No true Cache Records Keep enabled normally to avoid frequent updates, default location is ddns.cache in temp directory, can also specify a specific path
log object No null Log Config (Optional) Log configuration object, supports level, file, format, datefmt parameters

index4 and index6 Parameter Description

  • Numbers (0, 1, 2, 3, etc.): The i-th network interface IP
  • String "default" (or no this field): System default IP for external access
  • String "public": Use public IP (query via public API, simplified URL mode)
  • String "url:xxx": Open URL xxx (e.g., "url:http://ip.sb"), extract IP address from returned data
  • String "regex:xxx" Regular expression (e.g., "regex:192.*"): Extract the first IP address matching from ifconfig/ipconfig, note JSON escaping (\ should be written as \\)
    • "192.*" matches all IPs starting with 192 (note: regex: cannot be omitted)
    • To match 10.00.xxxx, write as "regex:10\\.00\\..*" ("\\" JSON escapes to \)
  • String "cmd:xxxx": Execute command xxxx and use stdout output as target IP
  • String "shell:xxx": Use system shell to run xxx, and use stdout result as target IP
  • false: Force disable IPv4 or IPv6 DNS resolution updates
  • List: Execute index rules in the list sequentially, using the first successful result as target IP
    • For example, ["public", "regex:172\\..*"] will first query public API, then look for local IPs starting with 172 if no IP is obtained

Custom Callback Configuration

  • id field: Fill in callback URL starting with HTTP or HTTPS, HTTPS recommended, supports variable replacement
  • token field: POST request parameters (JSON object or JSON string), use GET request if this field is empty or missing. When JSON parameter values contain constants from the table below, they will be automatically replaced with actual content

For detailed configuration guide, see: Callback Provider Configuration

Constant Name Constant Content Description
__DOMAIN__ DDNS Domain
__IP__ Obtained corresponding type IP address
__RECORDTYPE__ DDNS Record Type
__TTL__ DDNS TTL
__TIMESTAMP__ Request timestamp With decimal

Configuration Example

{
  "$schema": "https://ddns.newfuture.cc/schema/v4.0.json",
  "id": "12345",
  "token": "mytokenkey",
  "dns": "dnspod or dnspod_com or alidns or aliesa or dnscom or cloudflare or he or huaweidns or namesilo or tencentcloud or noip or callback",
  "ipv4": ["ddns.newfuture.cc", "ipv4.ddns.newfuture.cc"],
  "ipv6": ["ddns.newfuture.cc", "ipv6.ddns.newfuture.cc"],
  "index4": 0,
  "index6": "public",
  "ttl": 600,
  "proxy": ["http://127.0.0.1:1080", "DIRECT"],
  "log": {
    "level": "DEBUG",
    "file": "dns.log",
    "datefmt": "%Y-%m-%dT%H:%M:%S"
  }
}

Configuration Priority and Field Override Relationship

If the same configuration item is set in multiple places, the following priority rules apply:

  • Command Line Parameters: Highest priority, overrides all other settings
  • JSON Configuration File: Between command line and environment variables, overrides environment variable settings
  • Environment Variables: Lowest priority, used when not set by other methods

Advanced Usage:

  • JSON configuration file can contain only partial fields, missing fields will use environment variables
  • Environment variables support both uppercase and lowercase formats
  • Support for nested configuration through dot notation converted to underscores

Scheduled Tasks

Use built-in task command to set up scheduled tasks (checks IP every 5 minutes by default for automatic updates)

DDNS provides a built-in task subcommand for managing scheduled tasks with cross-platform automated deployment:

Basic Usage

# Install scheduled task (default 5-minute interval)
ddns task --install --dns dnspod --id your_id --token your_token --ipv4 your.domain.com

# Check task status
ddns task --status

# Uninstall scheduled task
ddns task --uninstall

Supported Systems

  • Windows: Uses Task Scheduler
  • Linux: Automatically selects systemd or crontab
  • macOS: Uses launchd

Advanced Management

# Install with custom interval (minutes)
ddns task --install 10 -c /etc/ddns/config.json

# Enable/disable tasks
ddns task --enable
ddns task --disable

New Feature Advantages:

  • ✅ Cross-platform automatic system detection
  • ✅ Automatically overwrites existing tasks without manual uninstallation
  • ✅ Supports all DDNS configuration parameters
  • ✅ Unified command-line interface

For detailed configuration guide, see: CLI Parameters Documentation

Docker

Docker images, without additional parameters, have a scheduled task enabled by default that runs every 5 minutes

FAQ

Windows Server [SSL: CERTIFICATE_VERIFY_FAILED]

Windows Server default security policy will prohibit any untrusted SSL certificates. You can manually add the corresponding certificates #56

Use the system's built-in IE browser to visit the corresponding API once:

Troubleshooting and Feedback
  1. First confirm whether it's a system/network environment issue
  2. Search for similar issues in issues
  3. If neither of the above can solve the problem or you're sure it's a bug, create a new issue here
    • Enable --debug
    • Include these contents: running version and method, system environment, error logs, configuration file with id/token removed
    • For source code execution, specify the Python environment used

Contributors

License

MIT

Star History

Star History Chart

S
Description
No description provided
Readme MIT
6.4 MiB
Languages
Python 88.6%
JavaScript 4.3%
CSS 3.1%
Shell 1.7%
HTML 1.6%
Other 0.7%