diff --git a/README.md b/README.md index 062de83..5388d05 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CodeQL](https://github.com/igorradovanov/dino-dns/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/igorradovanov/dino-dns/actions/workflows/github-code-scanning/codeql) + # Dino DNS 🦕 This Python program implements DNS server using the UDP protocol based RFC 1035 standard. The server listens for incoming connections, receives data, processes it, and sends a response back to the client based on the Zones and the type of records defined (A, MX or TXT). @@ -8,51 +10,6 @@ This Python program implements DNS server using the UDP protocol based RFC 1035 2. **DNS Response Building**: The script builds a DNS response that includes the transaction ID, flags, question count, and answer count. -## Code Snippets - -### DNS Query Processing - -```python -for byte in data: - if state == 1: - domain_string += chr(byte) - if x == expected_length: - domain_parts.append(domain_string) - domain_string = '' - state = 0 - if byte == 0: - domain_parts.append(domain_string) - break - else: - state = 1 - expected_length = byte -x += 1 -y += 1 - -question_type = data[y+1:y+3] - -return (domain_parts, question_type) -``` - -This methods is responsible for processing the DNS query. It loops through the bytes in the data, converting them to characters and appending them to the domain string. When the end of a domain part is reached, it is added to the list of domain parts. - -### DNS Response Building - -```python -transaction_id = data[0:2] -TID = '' -for by in transaction_id: - TID += hex(by)[2:] - -flags = get_flags(data[2:4]) - -QDCOUNT = b'\x00\x01' - -get_question_domain(data[12:]) -``` - -This method is responsible for building the DNS response. It extracts the transaction ID, flags, and question count from the data, and gets the question domain. - ## Docker Instructions This application can be run using Docker. Here are the steps to do so: @@ -77,3 +34,17 @@ docker run -p 53:53/udp dino-dns This command runs the dino-dns Docker image as a container and maps the container's port 53 to the host's port 53. Please note that you need to have Docker installed on your machine to execute these commands. + +## Testing with `dig` + +Once your DNS server is running, you can test it using the `dig` command. `dig` is a tool for querying DNS nameservers for information about host addresses, mail exchanges, nameservers, and related information. + +Here's an example of how to use `dig` to test your DNS server: + +```bash +dig @localhost -p 53 example.com +``` + +This command sends a DNS query to your server running on localhost at port 53 for the domain example.com. You should replace example.com with the domain you want to query. + +Please note that dig is typically installed on most Unix-based systems by default. If you're on Windows, you can use nslookup for similar functionality. \ No newline at end of file