This is a Python-based Dynamic DNS (DDNS) client that automatically updates DNS records to match the current IP address. It supports multiple DNS providers, IPv4/IPv6, and various configuration methods. Please follow these guidelines when contributing:
.github/instructions/python.instructions.mdFormat and lint code using ruff before each commit:
ruff check --fix --unsafe-fixes .
ruff format .
python -m unittest discover tests or python -m pytest tests/ruff check --fix --unsafe-fixes .ruff format .Follow the steps below to add a new DNS provider:
ddns/: Main application code
provider/: DNS provider implementations (DNSPod, AliDNS, CloudFlare, etc.)config/: Configuration management (loading, parsing, validation)util/: Utility functions (HTTP client, configuration management, IP detection)tests/: Unit tests using unittest frameworkdoc/: Documentation and user guides
providers/: Provider-specific configuration guidesdev/: Developer documentationschema/: JSON configuration schemasdocker/: Docker-related files and scriptstests/ directory using test_*.py namingfrom base_test import BaseProviderTestCase, unittest, patch, MagicMockfrom __init__ import unittest, patch, MagicMock to ensure compatibility with both unittest and pytestfrom base_test import BaseProviderTestCase, patch, MagicMock
from ddns.provider.example import ExampleProvider
class TestExampleProvider(BaseProviderTestCase):
def setUp(self):
super(TestExampleProvider, self).setUp()
self.provider = ExampleProvider(self.id, self.token)
@patch.object(ExampleProvider, "_http")
def test_set_record_success(self, mock_http):
mock_http.return_value = {"success": True}
result = self.provider.set_record("test.com", "1.2.3.4")
self.assertTrue(result)
# Run all tests (recommended)
python -m unittest discover tests -v
# Run specific provider
python -m unittest tests.test_provider_example -v
See existing tests in tests/ directory for detailed examples.