7 Commits
Author SHA1 Message Date
3c8578e9f4 feat(mcp): add Streamable HTTP transport (#736)
* feat(mcp): add Streamable HTTP transport

Add a modern MCP 2026-07-28 HTTP endpoint for standalone and Web modes, with shared listener configuration, authentication, schema, tests, and bilingual documentation.

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

* fix(tests): support Python 2 HTTP assertions

Normalize response header names and call handler methods through their underlying functions so the HTTP tests behave consistently on Python 2.7 and Python 3.

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

* fix(mcp): harden HTTP request handling

Validate mirrored request IDs, align Config Studio listener checks, bound socket reads, and accept the binary wrapper's documented SIGINT exit status.

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

* fix(mcp): align HTTP negotiation validation

Reject unavailable Accept media types by quality and keep schema host validation consistent with runtime listener checks.

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

* fix(tests): validate host schema behavior

Assert accepted and rejected host samples instead of comparing Unicode escape representations that differ on Python 2.7.

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

* fix(tests): avoid cross-engine schema regex

Keep the schema pattern contract without executing its ECMA-262 Unicode escape through Python 2's incompatible regex engine.

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

* fix(mcp): validate HTTP request boundaries

Reject empty tokens and malformed JSON-RPC request shapes, and keep Config Studio bracket validation aligned with runtime listener handling.

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

* fix(mcp): tighten HTTP input validation

Reject legacy notifications, nested host brackets, and document the required JSON content type so validation remains consistent across runtime, schema, and Config Studio.

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

* fix(mcp): validate Origin before method errors

Apply the existing Origin policy to non-POST MCP requests and return CORS headers for configured allowed origins.

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

* docs(mcp): clarify proxy Origin allowlist

Explain that browser clients behind TLS termination must allowlist the public HTTPS origin even when the public page appears same-origin.

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

* docs(mcp): add standalone server guide

Move MCP client setup, transports, tools, security, and protocol limits into dedicated Chinese and English pages with matching navigation and index links.

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

* fix(mcp): reject duplicate routing headers

Reject repeated MCP protocol, method, and name headers before body consistency checks across Python 2 and Python 3.

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

* fix(mcp): validate named request headers

Validate Mcp-Name for tools/call, prompts/get, and resources/read before dispatching unsupported methods.

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

---------

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-23 21:36:26 +08:00
d14594f14d feat(web): add local management dashboard (#718)
* feat(web): add local management dashboard

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

* fix(web): address review and Python 2 compatibility

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

* chore: remove design session artifacts

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

* fix(web): harden packaged resources and HTTP semantics

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

* test(web): support Python 2 handler mocks

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

* fix(web): detect all external schedulers

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

---------

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-11 18:23:17 +00:00
e58daa0a80 feat(docs): add configuration studio (#712)
* feat(docs): add configuration studio

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

* fix(config): address PR review feedback

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

* fix(docker): avoid 32-bit Nuitka compression OOM

Disable onefile compression only for 32-bit BuildKit targets, where zstd can exhaust the process address space.

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

* revert: restore compressed Linux binaries

The builder image has been rebuilt with the previous working toolchain.

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

* docs: remove English configuration studio

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

* chore: remove product design artifact

Restore the English configuration studio that was removed by mistake.

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

* fix(docs): protect credentials in address sources

Treat URL userinfo in IPv4 and IPv6 detection sources as sensitive so previews, copies, downloads, and duplicated providers exclude it by default.

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

* fix(docs): preserve explicit empty tokens

Keep runtime-significant empty token fields in credential-free exports while continuing to omit non-empty secrets.

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

* fix(docs): export entered credentials

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

* docs(config): clarify special source splitting

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

---------

Co-authored-by: NewFuture <6290356+NewFuture@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2026-08-08 11:09:51 +08:00
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
f7a92b3903 chore(lint): replace flake8 and black with ruff for unified linting and formatting (#544)
* Initial plan

* feat: replace flake8 and black with ruff for unified linting and formatting

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

* refactor: use astral-sh/ruff-action@v3 for cleaner CI workflow

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

* run format

* use fmt skip

* fix cloudflare

* fix cron

* fix cron

* fix fileio tests

* fix fileio tests

* fix cron

---------

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-08-09 11:29:35 +08:00
c2cad12380 refactor(http.proxy): add "SYSTEM" and fix "DIRECT" proxy, implement proxy list support with automatic fallback (#537)
* feat(http): implement proxy list support with fallback mechanism

- Add proxies parameter to request() function for proxy list support
- Maintain backward compatibility with single proxy parameter
- Implement proxy fallback logic that tries each proxy in order
- Update provider base classes to use proxy lists directly
- Add comprehensive tests for proxy list functionality
- Support None in proxy list to represent direct connection

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

* fix(http): handle empty proxy list edge case and remove duplicate function definition

- Fix empty proxy list to default to direct connection
- Remove duplicate function definition in request()
- Add test case for empty proxy list scenario

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

* fix(tests): correct provider proxy list test mocking

- Fix provider test mocking to use HttpResponse objects
- All proxy list tests now pass correctly
- Provider integration tests verify proxy list functionality

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

* fix(lint): resolve flake8 issues - remove whitespace and fix indentation

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

* refactor(http): remove proxy parameter and implement ProxiesHandler

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

* refactor(http): implement ProxiesHandler based on ProxyHandler with proxy_open override

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

* refactor(http): remove proxy wrapper class and string compatibility per feedback

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

* refactor(http): implement ProxiesHandler with proxy_open override as requested

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

* refactor(http): update endpoint URLs to use HTTP instead of HTTPS for testing

* feat: Add support for proxy settings in configuration

- Introduced a new "proxy" property in the schema to allow HTTP proxy settings in various formats.
- Updated tests to validate the handling of proxy settings, including special values and array formats.
- Enhanced environment variable loading to support proxy configurations, ensuring precedence rules are respected.
- Added tests for multi-provider configurations with independent proxy settings and global proxy overrides.

---------

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-20 18:51:40 +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