Skip to content

Comments

Upgrade Django DNS Server to Python 3 with full Twisted DNS support#13

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-9
Draft

Upgrade Django DNS Server to Python 3 with full Twisted DNS support#13
Copilot wants to merge 4 commits intomasterfrom
copilot/fix-9

Conversation

Copy link

Copilot AI commented Aug 31, 2025

This PR successfully upgrades the Django DNS Server from Python 2.7 to Python 3, addressing the core issue that Twisted's DNS functionality is now fully supported in Python 3.

Key Changes

Python 3 Migration: Updated all Python files to be compatible with Python 3.8+ (tested on Python 3.12), including fixing string/bytes handling in DNS queries and updating import statements.

Django Modernization: Upgraded from Django 1.9 to 5.2.5 with comprehensive compatibility fixes:

  • Updated URL patterns from django.conf.urls.url to django.urls.re_path
  • Fixed middleware configuration (MIDDLEWARE_CLASSESMIDDLEWARE)
  • Updated authentication checks (is_authenticated()is_authenticated)
  • Fixed ipware library usage (get_ipget_client_ip)

DNS Functionality: Fixed critical DNS resolution issues where query names (bytes) weren't properly converted to strings for database lookups. The Twisted DNS server now works perfectly on Python 3.

Docker & Deployment: Updated Dockerfile to use python:3-slim base image and created Dockerfile.alpine for memory-efficient Alpine Linux deployments as requested in the issue comments.

Testing: All 11 existing tests pass, confirming that DNS resolution, REST API endpoints, and web interface functionality are preserved.

Verification

The upgrade maintains full backward compatibility while enabling modern Python features:

# DNS resolution now works on Python 3
from dns.networking import Resolver
resolver = Resolver()
result = resolver.query(dns.Query(name='example.com'))
# Returns proper DNS response with IP address

The server can now run on Python 3.8+ with modern Django, providing better performance, security, and long-term maintainability.

Fixes #9.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits August 31, 2025 11:57
Co-authored-by: garncarz <7193375+garncarz@users.noreply.github.com>
Co-authored-by: garncarz <7193375+garncarz@users.noreply.github.com>
Co-authored-by: garncarz <7193375+garncarz@users.noreply.github.com>
Copilot AI changed the title [WIP] Python 3 Upgrade Django DNS Server to Python 3 with full Twisted DNS support Aug 31, 2025
Copilot AI requested a review from garncarz August 31, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python 3

2 participants