5 Commits
Author SHA1 Message Date
06fceed0f7 feat(cache): add configurable cache max age (#709)
* feat(cache): add configurable cache max age

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

* test(cache): cover cache max age integration paths

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

* test(cache): fix portable regression test formatting

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

* style(test): format cache max age run test

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

---------

Co-authored-by: Future New (WEILAI LIU) <weilail@microsoft.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-06 17:59:40 +08:00
96b4ca2e0c feat(config): 支持多配置文件和多服务商 优化http support multi config/providers (#531)
* Initial plan

* Implement multi-provider and multi-config file support

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

* Complete multi-provider and multi-config support with comprehensive testing

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

* Address code review feedback: fix exit behavior, remove special env handling, fix log level

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

* Add object-with-configs array support for improved JSON schema validation

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

* Address code review feedback: simplify config path handling, remove load_config function, and improve debug provider logic

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

* Address final code review feedback: improve log handling, provider logging, and debug assignment logic

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

* Address final review feedback: simplify debug provider logic and remove array format support

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

* Fix lint issues: remove whitespace from blank lines and apply black formatting

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

* Implement schema v4.1 with multi-provider support using providers array format

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

* Address code review feedback: rename tests, use global log settings, simplify config logic, remove configs format support

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

* Fix lint issues and simplify complex functions to reduce cyclomatic complexity

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

* Address code review feedback: enhance config functions and inline simple logic

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

* Fix Python 2.7 compatibility and lint issues in test_config_schema_v4_1.py

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

* Simplify config logic, fix Python 2.7 compatibility, and improve code formatting

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

* Optimize config logic and enhance schema v4.0/v4.1 compatibility tests

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

* Update file.py

* Update file.py

* Update file.py

* Update file.py

* Fix critical bug in multi-provider config processing and clean up lint issues

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

* fix

* 优化测试代码格式,移除多余空行并调整注释位置
* refactor: update HTTP request handling and improve error processing

- Refactored imports for better clarity and organization.
- Added custom HTTP error processor to handle all HTTP error status codes gracefully.
- Enhanced SSL certificate loading with additional paths for Windows.
- Updated test cases to use HTTP instead of HTTPS for testing endpoints.
- Added tests for handling HTTP 400 Bad Request and SSL auto fallback behavior.

* update http

* update docs

* refactor: enhance SSL handling in SSLAutoFallbackHandler for better compatibility

* add multi tests

* fix patch and add rename fileds

* refactor: update provider field naming in configuration tests for consistency

* update doc link

* fix encoding

* fix

* 清理编码问题

* fix 编码问题

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
2025-07-17 18:54:09 +00:00
d9b0b825d1 feat(config): 支持当行注释 Add JSON comment support with # and // styles for configuration files (#515)
* Add JSON comment support with # and // styles

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

* Fix Python 2.7 compatibility and remove trailing whitespace

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

* Fix lint issues and simplify comment removal logic

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>
2025-07-13 02:58:38 +00:00
CopilotandNewFuture 3bb6241c5b refact(cache): Convert cache storage from pickle to JSON format (#512)
* Initial plan

* Convert cache storage from pickle to JSON format

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

* Address review feedback: use specific json imports and compact format

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

* Make cache file loading safer with try-catch around file opening

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

* Remove nested try-catch in cache load method as suggested

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

* Fix linting issues: remove whitespace from blank lines in test_cache.py

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

* Add comprehensive tests for Cache.new static method

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

* Fix Windows compatibility in cache test by using tempfile.mktemp() instead of hardcoded Unix path

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>
2025-07-12 08:11:15 +00:00
New Future 485e6a3e26 Refact(config): 统一配置 (#506)
* Add unit tests for configuration loading and JSON handling

- Introduced comprehensive unit tests for the ddns.config.__init__ module, covering various scenarios for the load_config function, including configuration merging, error handling, and CLI integration.
- Created a new test suite for the JSON configuration module, validating loading, saving, and edge cases for JSON files.
- Removed outdated SSL configuration tests that are no longer relevant to the current implementation.

* feat(provider): add endpoint parameter to SimpleProvider and update user agent format
feat(cli): add endpoint argument to load_config
test(tests): add tests for endpoint handling and user agent formatting

* feat(doc): add comprehensive configuration documentation for DDNS system

* feat: Update environment variable handling and documentation

- Changed default values for DDNS_INDEX4 and DDNS_INDEX6 from "default" to ["default"] in env.md and json.md.
- Enhanced documentation for index4 and index6 to clarify handling of special prefixes (regex, cmd, shell) and their impact on splitting.
- Updated schema to reflect new default values and added support for custom API endpoints and SSL settings.
- Improved test coverage for environment variable handling, including special cases for proxy and SSL settings.
- Refactored tests to ensure proper handling of environment variables and their precedence over defaults.
- Minor adjustments to test cases for consistency and clarity.

* fix config and tests

* fix error

* fix tests

* fix tests

* fix

* Add comprehensive unit tests for configuration file loading

- Introduced a new test suite for the configuration file loading module, covering JSON and AST parsing, fallback logic, error handling, and various edge cases.
- Replaced references to `load_json_config` with `load_file_config` in existing tests to unify configuration loading methods.
- Removed the outdated `test_config_json.py` file as its functionality is now covered in the new test suite.

* Fix test_load_config_priority_order mock parameter names for clarity

* Add main entry point for test execution in configuration tests

* Enhance Config class to flatten single-element lists and improve configuration loading tests

* fix tests

* update tests

* fix: 修复类型注释以支持 None 类型并更新测试用例描述

* fix lint

* fix py2.7

* feat: 添加对51dns和aliesa的支持,并更新SSL参数处理

* Refactor unit tests for configuration modules

- Updated test descriptions to specify the ddns.config.env and ddns.config.file modules.
- Removed redundant comments and improved clarity in test cases.
- Consolidated test cases for loading configurations from various sources, ensuring better readability and maintainability.
- Enhanced edge case handling and validation in load_config tests.
- Improved assertions and mock setups for better accuracy in testing configuration loading behavior.

* fix unicode_literals

* fix lint and tests

* fix tests

* fix py2 tests

* fix tests and update doc

* fix py2.7 test

* fix py2 patch

* 更新配置文件加载器,修复编码问题

* fix encoding for py2

* 更新 get_ip 函数参数,修改文档以支持阿里云ESA和No-IP自定义端点,添加多个DNS服务示例

* Refactor documentation for DNS providers:
- Updated DNSpod documentation by removing redundant configuration examples and enhancing the complete configuration example.
- Added English and Chinese documentation for HE.net (Hurricane Electric) with detailed configuration steps and troubleshooting tips.
- Introduced English and Chinese documentation for Huawei Cloud DNS, including access key authentication and endpoint configuration.
- Enhanced No-IP documentation by clarifying authentication methods and providing comprehensive configuration examples.
- Improved Tencent Cloud DNS documentation with additional endpoint options and detailed permission requirements.

* Add documentation for new DNS providers and update existing provider guides

- Introduced Debug Provider documentation in both English and Chinese.
- Added DNS.COM configuration guide in English and Chinese, including authentication methods and troubleshooting.
- Updated DNSPod documentation to include separate guides for DNSPod China and DNSPod Global, with detailed configuration examples.
- Revised HE.net documentation to streamline configuration examples and optional parameters.
- Enhanced Huawei Cloud DNS documentation with clearer endpoint selection and optional parameters.
- Updated No-IP documentation to clarify authentication methods and response codes.

* Fix stdout and stderr encoding in test setup for compatibility with non-UTF-8 systems

* Update environment variable documentation to remove dot-to-underscore conversion

* Refactor configuration loading and error handling in ddns.config module

- Removed logging in favor of direct stderr/stdout output for error messages.
- Simplified the configuration generation logic in load_config.
- Enhanced error handling for missing configuration files and invalid formats.
- Updated unit tests to reflect changes in output handling and error scenarios.

* update config document

* fix lint

* 更新 Python 配置文档,添加 GitHub Copilot 使用指南和配置生成逻辑,优化配置加载流程

* Refactor Config class to replace dict() method with md5() for generating hash of configurations; update tests to reflect changes in default values and utility methods.

* Enhance environment variable handling in load_config function; prioritize DDNS_PROXY over standard proxies, and improve test coverage for proxy configurations and environment variable management.

* 添加缓存模块及其测试用例,支持文件缓存功能;新增调试和回调配置文件,更新构建工作流以测试不同配置

* rename

* 优化测试用例以确保在空配置情况下正确退出;使用临时目录避免干扰

* fix env test
2025-07-12 11:04:25 +08:00