Skip to content

Commit 35826b0

Browse files
committed
init: implementation of Dns over TLS server in python
0 parents  commit 35826b0

File tree

15 files changed

+2202
-0
lines changed

15 files changed

+2202
-0
lines changed

.github/workflows/ci-cd.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v3
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: |
29+
uv sync
30+
uv add --dev pytest pytest-cov pytest-asyncio
31+
32+
- name: Test with pytest
33+
run: |
34+
uv run python -m pytest tests/ -v --cov=tldns --cov-report=xml
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v4
38+
with:
39+
file: ./coverage.xml
40+
flags: unittests
41+
name: codecov-umbrella
42+
fail_ci_if_error: false

.gitignore

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
.Python
7+
build/
8+
develop-eggs/
9+
dist/
10+
downloads/
11+
eggs/
12+
.eggs/
13+
lib/
14+
lib64/
15+
parts/
16+
sdist/
17+
var/
18+
wheels/
19+
*.egg-info/
20+
.installed.cfg
21+
*.egg
22+
MANIFEST
23+
24+
# Virtual environments
25+
.env
26+
.venv
27+
env/
28+
venv/
29+
ENV/
30+
env.bak/
31+
venv.bak/
32+
33+
# Testing
34+
.coverage
35+
.pytest_cache/
36+
htmlcov/
37+
.tox/
38+
.nox/
39+
coverage.xml
40+
*.cover
41+
.hypothesis/
42+
43+
# IDE
44+
.vscode/
45+
.idea/
46+
*.swp
47+
*.swo
48+
*~
49+
50+
# OS
51+
.DS_Store
52+
.DS_Store?
53+
._*
54+
.Spotlight-V100
55+
.Trashes
56+
ehthumbs.db
57+
Thumbs.db
58+
59+
# SSL certificates (for development)
60+
*.crt
61+
*.key
62+
*.pem
63+
64+
# Logs
65+
*.log
66+
67+
# Cache
68+
.cache/
69+
.mypy_cache/
70+
.dmypy.json
71+
dmypy.json

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

CHANGELOG.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
- Initial release preparation
12+
13+
## [0.1.0] - 2024-09-25
14+
15+
### Added
16+
- DNS over TLS server implementation
17+
- Command-line interface with Python Fire
18+
- Configurable upstream DNS servers (default: 8.8.8.8)
19+
- SSL/TLS encryption support
20+
- Multi-threaded client handling
21+
- Comprehensive logging with configurable levels
22+
- Type hints throughout codebase
23+
- Comprehensive test suite with 96% coverage
24+
- Performance and load testing
25+
- Cross-platform support (Linux, Windows, macOS)
26+
- Installable Python package with hatchling
27+
- GitHub Actions CI/CD workflows
28+
- Automated releases and PyPI publishing
29+
30+
### Features
31+
- RFC 7858 DNS over TLS compliance
32+
- Configurable bind address and port
33+
- Custom SSL certificate support
34+
- Error handling with SERVFAIL responses
35+
- Connection lifecycle logging
36+
- Query tracking and statistics
37+
38+
### Testing
39+
- Unit tests for all major components
40+
- Protocol compliance tests
41+
- Performance and concurrency tests
42+
- Mock-based testing for network components
43+
- Coverage reporting with pytest-cov
44+
45+
### Documentation
46+
- Comprehensive README with usage examples
47+
- API documentation with docstrings
48+
- GitHub Actions workflow documentation
49+
- Installation and development guides

CONTRIBUTING.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Contributing to tldns
2+
3+
Thank you for your interest in contributing to tldns! This document provides guidelines for contributing to the project.
4+
5+
## Development Setup
6+
7+
1. **Clone the repository**:
8+
```bash
9+
git clone https://github.com/yourusername/tldns.git
10+
cd tldns
11+
```
12+
13+
2. **Install uv** (if not already installed):
14+
```bash
15+
curl -LsSf https://astral.sh/uv/install.sh | sh
16+
```
17+
18+
3. **Set up development environment**:
19+
```bash
20+
uv sync
21+
uv pip install -e ".[test]"
22+
```
23+
24+
4. **Generate test certificates**:
25+
```bash
26+
./generate_cert.sh
27+
```
28+
29+
## Development Workflow
30+
31+
### Running Tests
32+
33+
```bash
34+
# Run all tests
35+
uv run python -m pytest
36+
37+
# Run with coverage
38+
uv run python -m pytest --cov=tldns
39+
40+
# Run specific test categories
41+
uv run python -m pytest -m unit
42+
uv run python -m pytest -m integration
43+
uv run python -m pytest -m "not slow"
44+
45+
# Run tests in verbose mode
46+
uv run python -m pytest -v
47+
48+
# Add test dependencies if needed
49+
uv add --dev pytest pytest-cov pytest-asyncio
50+
```
51+
52+
### Code Quality
53+
54+
```bash
55+
# Format code (if using ruff)
56+
uv add --dev ruff
57+
uv run ruff format .
58+
59+
# Lint code (if using ruff)
60+
uv run ruff check .
61+
62+
# Type checking (if using mypy)
63+
uv add --dev mypy
64+
uv run mypy tldns/
65+
```
66+
67+
### Building the Package
68+
69+
```bash
70+
# Build source and wheel distributions
71+
uv build
72+
73+
# Check the built package
74+
uv add --dev twine
75+
uv run python -m twine check dist/*
76+
```
77+
78+
### Testing the CLI
79+
80+
```bash
81+
# Test CLI functionality
82+
uv run tldns --help
83+
uv run tldns start --help
84+
85+
# Test with custom parameters
86+
uv run tldns --port 8853 --log_level DEBUG start
87+
```
88+
89+
## Contributing Guidelines
90+
91+
### Code Style
92+
93+
- Follow PEP 8 style guidelines
94+
- Use type hints for all function parameters and return values
95+
- Write descriptive docstrings for classes and functions
96+
- Keep functions focused and single-purpose
97+
- Use meaningful variable and function names
98+
99+
### Testing
100+
101+
- Write tests for all new functionality
102+
- Maintain or improve test coverage (currently 96%)
103+
- Include both unit tests and integration tests
104+
- Test error conditions and edge cases
105+
- Use descriptive test names that explain what is being tested
106+
107+
### Documentation
108+
109+
- Update README.md for user-facing changes
110+
- Update CHANGELOG.md following Keep a Changelog format
111+
- Add docstrings to new classes and functions
112+
- Update type hints when modifying function signatures
113+
114+
### Commit Messages
115+
116+
Use clear, descriptive commit messages:
117+
118+
```
119+
feat: add support for custom DNS record types
120+
fix: handle SSL handshake failures gracefully
121+
docs: update installation instructions
122+
test: add performance tests for concurrent clients
123+
```
124+
125+
### Pull Request Process
126+
127+
1. **Fork the repository** and create a feature branch:
128+
```bash
129+
git checkout -b feature/your-feature-name
130+
```
131+
132+
2. **Make your changes** following the guidelines above
133+
134+
3. **Run tests** to ensure everything works:
135+
```bash
136+
uv run python -m pytest
137+
```
138+
139+
4. **Update documentation** as needed
140+
141+
5. **Commit your changes** with descriptive messages
142+
143+
6. **Push to your fork** and create a pull request
144+
145+
7. **Ensure CI passes** - all GitHub Actions workflows must pass
146+
147+
### Pull Request Checklist
148+
149+
- [ ] Tests pass locally and in CI
150+
- [ ] Code follows project style guidelines
151+
- [ ] Documentation is updated (if applicable)
152+
- [ ] CHANGELOG.md is updated (for significant changes)
153+
- [ ] Type hints are included for new code
154+
- [ ] Test coverage is maintained or improved
155+
156+
## Reporting Issues
157+
158+
When reporting issues, please include:
159+
160+
- Python version and operating system
161+
- Steps to reproduce the issue
162+
- Expected vs actual behavior
163+
- Relevant log output (with `--log_level DEBUG`)
164+
- Configuration details (host, port, certificates, etc.)
165+
166+
## Feature Requests
167+
168+
For feature requests, please:
169+
170+
- Check existing issues to avoid duplicates
171+
- Describe the use case and motivation
172+
- Provide examples of how the feature would be used
173+
- Consider implementation complexity and maintenance burden
174+
175+
## Release Process
176+
177+
Releases are automated through GitHub Actions:
178+
179+
1. Update version in `pyproject.toml`
180+
2. Update `CHANGELOG.md` with release notes
181+
3. Commit changes and push to main
182+
4. Create and push a version tag:
183+
```bash
184+
git tag v0.1.1
185+
git push origin v0.1.1
186+
```
187+
5. GitHub Actions will automatically:
188+
- Run tests
189+
- Build packages
190+
- Create GitHub release
191+
- Publish to PyPI
192+
193+
## Getting Help
194+
195+
- Check the README.md for usage instructions
196+
- Look at existing tests for examples
197+
- Review the GitHub Actions workflows for CI/CD details
198+
- Open an issue for questions or problems
199+
200+
Thank you for contributing to tldns!

0 commit comments

Comments
 (0)