-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Miguel Cuartin
authored and
Miguel Cuartin
committed
Feb 16, 2021
1 parent
14118e4
commit f8b542b
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import logging as l | ||
import socket | ||
|
||
from pyfiglet import Figlet | ||
|
||
import dns.flags | ||
import dns.message | ||
import dns.rdataclass | ||
import dns.rdatatype | ||
import dns.name | ||
import dns.query | ||
|
||
from typing import cast | ||
|
||
# General config | ||
l.basicConfig(level=l.INFO) | ||
f = Figlet(font='slant') | ||
|
||
l.info(f.renderText('dnproxy')) | ||
|
||
# General Parameters | ||
HOST = '127.0.0.1' | ||
PORT = 53 | ||
UPSTREAM_IP = '1.1.1.1' | ||
TLS_HOSTNAME = 'cloudflare-dns.com' | ||
|
||
|
||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: | ||
s.bind((HOST, PORT)) | ||
l.info(f"Listening on {HOST}:{PORT}") | ||
|
||
while True: | ||
(wire, host) = s.recvfrom(1024) | ||
q = dns.message.from_wire(wire) | ||
l.info(f'Question {q.id}:{q.question}') | ||
|
||
try: | ||
r = dns.query.tls(q, UPSTREAM_IP, server_hostname=TLS_HOSTNAME) | ||
l.info(f'Response {r.id}:{r.answer}') | ||
|
||
except KeyError: | ||
l.error("error") | ||
|
||
wire = r.to_wire() | ||
s.sendto(wire, host) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
certifi==2020.12.5 | ||
cffi==1.14.5 | ||
chardet==4.0.0 | ||
cryptography==3.4.5 | ||
dnspython==2.1.0 | ||
idna==2.10 | ||
pycparser==2.20 | ||
pyfiglet==0.8.post1 | ||
requests==2.25.1 | ||
requests-toolbelt==0.9.1 | ||
urllib3==1.26.3 |