13 Commits
Author SHA1 Message Date
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
f74438cb82 fix: add missing packages to pip distribution (config and scheduler) (#572)
* Initial plan

* chore: initial investigation - reproduce pip install issue

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

* fix(pyproject): add missing packages config and scheduler to pip distribution

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

* test(ci): add pip install verification tests to GitHub Actions

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

* refactor(ci): improve pip install test commands for better error handling

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

* refactor(ci): use find command for more robust file selection in pip tests

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

* revert(init): restore placeholder values for BUILD_VERSION and BUILD_DATE

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-10-21 16:08:54 +00: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
6c24557505 feat(cli): add task subcommand for automated scheduled task management (#541)
* Initial plan

* feat(cli): implement task subcommand with cross-platform scheduler support

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

* docs(cli): add task subcommand documentation

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

* fix(cli,task): address review feedback - move task handler to cli, remove defaults, improve fallback status checking

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

* refactor(task): convert TaskManager class to functions and handle task commands entirely in CLI

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

* fix(cli,tests): remove handle_task_command from exports and rename test file

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

* feat(task): add enable and disable commands for scheduled tasks

* add task tests

* refactor(task): simplify task command handling and update status retrieval

* update task

* test(task): update subcommand tests to assert exit codes and rename delete to uninstall

* Add unit tests for DDNS task subcommand functionality and enhance existing tests

- Introduced comprehensive unit tests for the DDNS task subcommand, covering help, status, install, enable, disable, delete, and argument handling.
- Added tests for file I/O operations in the ddns.util.fileio module, ensuring proper directory creation, file reading/writing, and error handling.
- Enhanced test coverage for task scheduling functions, including systemd and cron installations, with additional checks for argument handling.
- Updated existing tests to improve compatibility and reliability across different operating systems, particularly for path handling on Windows.
- Refactored task command building tests to ensure correct command generation with various argument types, including lists and boolean flags.

* refactor(task): improve command execution and path handling for DDNS tasks

* remove DEVNULL

* fix(task): ensure proper task interval handling and add sudo for task commands in test script

* add and fix tests

* fix lint

* refactor(cli): organize DDNS arguments into groups and improve task subcommand handling

* fix tests

* +x

* fix py2 and types

* rm sudo

* fix(tests): use sudo for task installation and uninstallation in test script

* update test command

* always force

* fix format

* docs: add task management parameters and usage examples to CLI documentation

* update log

* docs: update CLI task management instructions and examples

* fix py2

* fix task in python2

* fix lint

* refactor tasks

* update tests

* add schtasks-based task scheduler implementation and unit tests

* Enhance scheduler functionality and improve error handling

- Added a 60-second timeout to subprocess calls in BaseScheduler to prevent hanging.
- Improved error logging in BaseScheduler to capture command failures.
- Refactored CronScheduler to remove unnecessary variable initialization.
- Updated SystemdScheduler to handle PermissionError and provide user feedback for permission issues.
- Enhanced file I/O functions in fileio.py to return default values on exceptions.
- Improved unit tests for scheduler classes to ensure robust testing of functionality and error handling.
- Added lifecycle operation tests for SystemdScheduler to validate install, enable, disable, and uninstall processes.
- Ensured consistent status reporting across multiple calls in SystemdScheduler.
- Cleaned up test code for better readability and maintainability.

* fix lint

* Refactor scheduler command execution and enhance error handling in BaseScheduler and LaunchdScheduler tests

* fix tests

* Add unittest configuration to settings and improve SchtasksScheduler error handling

* Refactor code for improved readability and maintainability in various test files and the DnspodProvider class

* Refactor LaunchdScheduler tests for improved readability and error handling

* fix py2

* fix mac launchd test

* fix lint

* fix macos tests

* fix windows test

* patch readme

* update doc

* Update tests/test_scheduler_cron.py

Co-authored-by: Copilot <175728472+Copilot@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-08-07 17:58:43 +00:00
New FutureandCopilot f1a764d3c2 refact(provider): 巨大重构 (#484)
* abc

* update base

* update

* add doc

* dnspod class provider

* lint

* fix lint

* 类型检查

* add alidns

* cloudflare

* dnspod 国际版

* Update pyproject.toml

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

* update dnscom

* Update dnspod.py

* fix lint

* 提供兼容的encode 和 quote 方法

* huawei dns

* 名称兼容

* join domain

* static

* update base

* add callback

* update http

* fix and update hw

* merge

* refactor: reorganize imports and enhance logging in provider modules

* refactor: update method signatures to use None as default for extra parameters

* Apply suggestions from code review

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

* Update ddns/provider/__init__.py

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

* resolve comments

* update doc

* update doc

* using self logger

* update format

* Refactor config handling and update provider docs

Refactored argument parsing and config file logic in ddns/util/config.py for clarity and improved debug handling. Updated provider development documentation to clarify standard and non-standard DNS provider requirements and examples. Added 'print' as a valid DNS provider in the v4.0 schema and improved enum formatting for log options. Minor logging and message adjustments in ddns/__main__.py.

* Rename PrintProvider to DebugProvider and update references

Renamed PrintProvider to DebugProvider and updated all references in the codebase, including configuration defaults and schema. This change standardizes the provider naming and improves clarity by using 'debug' instead of 'print' for the default DNS provider.

* Add logger support to Cache and BaseProvider classes

Introduced logger injection for Cache and BaseProvider to improve logging consistency and flexibility. Updated main entry to pass logger instances, enhanced debug log formats, and fixed a documentation reference in provider.md.

* update callback

* fix lint

* Add and refine provider authentication validation

Introduces a _validate method to BaseProvider and its subclasses to ensure authentication credentials are properly set. Refactors CallbackProvider to simplify parameter replacement and validation. Adds stricter validation for CloudflareProvider, requiring a valid email for auth_id. Updates HTTP parameter handling in BaseProvider for improved query and body management.

* fix py2

* fix import

* fix dnspod and Improve logging and robustness in DDNS provider and utils

Enhanced logging throughout the DDNS provider base and main entrypoint for better traceability, including more informative log messages and additional warning/critical logs. Improved the robustness of domain splitting and zone ID resolution logic. Updated dnspod provider methods with doc links and fixed parameter handling. Refactored config to disable cache in debug mode, and standardized string quoting and regex usage in IP utility functions for consistency.

* Mask sensitive data in logs for URL and body

Introduced the _mask_sensitive_data method to obfuscate sensitive information such as authentication tokens in URLs and request bodies before logging. Updated logging statements to use this masking for improved security.

* Add unit tests for BaseProvider and update CI workflow

Introduces a test suite for BaseProvider in tests/test_base_provider.py and initializes the tests package. Updates the GitHub Actions workflow to run unit tests as part of the build process.

* Remove unused encoding parameter from _quote method

The _quote static method in BaseProvider no longer accepts the unused 'encoding' parameter, aligning its signature with actual usage and simplifying the code.

* Remove unused 'errors' parameter from _quote method

The _quote static method in BaseProvider no longer accepts the 'errors' parameter, as it was not used. The type annotation and call to quote have been updated accordingly.

* Refactor CallbackProvider and add unit tests

Refactored CallbackProvider to improve variable replacement and HTTP method handling in set_record. Added comprehensive unit tests for CallbackProvider covering initialization, variable replacement, HTTP request logic, and error handling. Minor cleanup in get_system_info_str to remove redundant comment.

* Rename and update provider test files, add DebugProvider tests

Renamed test_base_provider.py to test_provider_base.py and test_callback_provider.py to test_provider_callback.py for consistency. Updated imports and minor formatting in test_provider_callback.py. Added comprehensive unit and integration tests for DebugProvider in new test_provider_debug.py.

* he tests

* Refactor tests to use shared BaseProviderTestCase

Introduces a new test_base.py with BaseProviderTestCase to provide common setup and utilities for provider tests. Refactors test_provider_base.py, test_provider_callback.py, test_provider_debug.py, and test_provider_he.py to inherit from BaseProviderTestCase, reducing code duplication and improving maintainability.

* Improve test configuration and Python 2.7 compatibility

Added mock installation for Python 2.7 in CI and as an optional dependency. Enhanced pyproject.toml with unified unittest and pytest configuration, coverage, and flake8 settings. Added a comprehensive tests/README.md for running and writing tests. Refactored test_provider_base.py to use _TestProvider for clarity and consistency.

* fix py2 pip

* fix pip2

* install pip

* tmp dir

* Use PY env variable for Python 2.7 setup in CI

Replaces hardcoded 'python2' with the PY environment variable in the build workflow for Python 2.7. This improves flexibility and consistency in the CI setup.

* Add stub DNS record methods to DebugProvider and HeProvider

Introduces _query_zone_id, _create_record, _update_record, and _query_record methods to DebugProvider and HeProvider. DebugProvider raises NotImplementedError for create/update, while HeProvider returns False for these methods. This prepares both providers for a unified interface and future extension.

* fix debug

* fix tests

* fix typos

* fix id check

* callback 兼容python2

* add SimpleProvider

* fix

* fix lint

* remove duplicate code

* fix lint

* fix tests

* query with condition

* fix test for py2

* fix debug tests

* run ut in more system

* add unit tests for SimpleProvider and update README

* Refactor dnspod provider and add comprehensive tests

Refactored the DnspodProvider to improve record querying logic, parameter handling, and logging. Expanded the provider development guide with detailed instructions and best practices for both SimpleProvider and BaseProvider. Added a full-featured test suite for DnspodProvider, including unit and integration tests, and updated test documentation for improved clarity and usage instructions.

* fix type

* format

* Add unit tests for AlidnsProvider and CloudflareProvider

Added comprehensive unit and integration tests for AlidnsProvider and CloudflareProvider in tests/test_provider_alidns.py and tests/test_provider_cloudflare.py. Also updated type hints in set_record methods in ddns/provider/_base.py for better type accuracy.

* Add and update provider tests; fix datetime usage

Added comprehensive unit and integration tests for DnscomProvider and HuaweiDNSProvider. Updated test authorship to GitHub Copilot. Improved test structure and naming for SimpleProvider. Fixed datetime usage in alidns.py and huaweidns.py to use timezone-aware UTC. Cleaned up and clarified test README instructions.

* Use datetime.utcnow() for UTC timestamps

Replaced usage of datetime.now(timezone.utc) with datetime.utcnow() in AlidnsProvider and HuaweiDNSProvider to avoid deprecation warnings and ensure compatibility. Updated related tests to mock datetime.utcnow() instead of datetime.now().

* Add unit tests for DnspodComProvider

Introduces unit and integration tests for the DnspodComProvider class, verifying class constants, initialization, inheritance, API endpoint differences, and default line settings.

* feat: Add TencentCloudProvider and implement related unit tests

- Introduced TencentCloudProvider for Tencent Cloud DNSPod API integration.
- Updated existing provider classes to utilize datetime.utcnow() for consistent UTC timestamp handling.
- Refactored unit tests for AlidnsProvider, CallbackProvider, DnscomProvider, and HuaweiDNSProvider to use the new now() method for timestamp generation.
- Added comprehensive unit tests for TencentCloudProvider covering initialization, validation, signature generation, record querying, creation, and updating.
- Ensured compatibility with existing functionality while enhancing test coverage and reliability.

* fix tests

* always use the time

* fix TencentCloudProvider

* fix lint

* Add new feature to process user input

Introduced a function to handle and validate user input, improving the robustness of the input processing workflow.

* Update unit tests for various DNS providers

* Refactor test imports to use base_test.py for consistency across provider tests

* Enhance CallbackProvider and HTTP utilities

- Updated CallbackProvider to include User-Agent header in requests.
- Improved handling of GET and POST methods based on the presence of auth_token.
- Added a new HTTP utilities module for better HTTP request handling, including SSL verification and redirect following.
- Implemented comprehensive unit tests for the new HTTP utilities, covering various scenarios including SSL handling, redirects, and error responses.
- Added real integration tests for CallbackProvider using httpbin.org to validate actual HTTP interactions.
- Enhanced test coverage for SimpleProvider, including verification of sensitive data masking and initialization options.

* Refactor provider constants and response handling

- Changed class constants from CamelCase (ContentType, DecodeResponse) to snake_case (content_type, decode_response) for consistency across providers.
- Updated the default value of `verify_ssl` to "auto" in SimpleProvider.
- Adjusted the initialization of providers to accept `verify_ssl` as a parameter.
- Modified the handling of headers in HTTP requests to ensure `accept` and `content-type` are set correctly.
- Updated tests to reflect changes in constant naming and initialization parameters.
- Enhanced error handling in HTTP requests to provide more informative messages.

* Refactor unit tests to use MagicMock for improved clarity and consistency

* Enhance TencentCloudProvider with improved zone ID querying and response handling in unit tests

* Refactor HTTP callback handling and enhance error logging

- Improved error handling in CallbackProvider to log exceptions and empty responses.
- Introduced HttpResponse class to encapsulate HTTP response details, including status, reason, headers, and body.
- Updated send_http_request to return HttpResponse objects instead of raw response strings.
- Enhanced tests for CallbackProvider and send_http_request to validate logging and response handling.
- Added unit tests for HttpResponse and decoding response bodies with various character sets.

* Enhance TencentCloudProvider with improved header handling and signature generation in unit tests

* Enhance error handling and logging in DnspodProvider and TencentCloudProvider unit tests

* Enhance Python 2/3 compatibility in test_util_http.py with utility functions for string encoding and decoding

* fix py2 and time

* fix tests

* disable push build

* Apply suggestions from code review

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

* Update tests/test_provider_cloudflare.py

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

* update doc

* Refactor TencentCloudProvider methods to use consistent parameter naming for subdomains; update documentation for DNSPod provider authentication methods; enhance error handling in tests to return False instead of raising exceptions for non-existent records; improve masking of sensitive data in URLs; add tests for URL-encoded sensitive data handling.

* Add Callback Provider documentation and enhance DNSPod and Tencent Cloud guides

- Introduced a comprehensive documentation for the Callback Provider, detailing configuration, request methods, variable replacements, usage scenarios, and troubleshooting tips.
- Updated DNSPod documentation to include a link to Tencent Cloud DNSPod for better user guidance.
- Added a new Tencent Cloud DNS configuration guide in both English and Chinese, outlining authentication methods, configuration examples, optional parameters, and troubleshooting steps.
- Enhanced test cases for AlidnsProvider to validate signature generation and request handling, ensuring proper HTTP interactions and error handling.
- Improved error message validation in DNSPod tests to ensure clarity in authentication failure messages.

* Enhance documentation and validation for DNS providers; add Callback Provider configuration guide and improve error handling messages for Cloudflare, DNS.COM, HE.net, and HuaweiDNS providers.

* Update tests/test_provider_callback.py

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

* Update tests/test_provider_dnscom.py

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

* Update tests/test_provider_debug.py

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

* Update tests/test_provider_he.py

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

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-01 19:08:11 +08:00
New Future ecee2bf644 Setup.cfg for py2 (#483) 2025-06-18 16:53:10 +00:00
New FutureandCopilot 860e601be5 fix(pypi): patch.py version (#482)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-18 21:33:13 +08:00
New Future f84f56c943 build-system 2025-06-16 23:47:44 +08:00
New Future 7d5d716016 test build-system 2025-06-16 23:43:42 +08:00
New Future a5cfb36cfe update deps 2025-06-16 23:22:06 +08:00
New Future 364b6fb2f8 update initial version 2025-06-16 20:56:29 +08:00
New Future 12d6a0fc0a no-local-version 2025-06-16 18:52:50 +08:00
New FutureandCopilot baf1fdc30c refact(py): Refactor structure (#481)
* 目录结构重构
* update config
* rename dns to provider
* patch version info
* remove version replace
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* add ENV GITHUB_REF_NAME to docker build
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-16 01:41:34 +08:00