项目作者: treussart

项目描述 :
Server DNS Over HTTPS Proxy for Django
高级语言: Python
项目地址: git://github.com/treussart/django-doh.git
创建时间: 2019-10-07T05:10:09Z
项目社区:https://github.com/treussart/django-doh

开源协议:BSD 3-Clause "New" or "Revised" License

下载


Django-doh

Django-doh is a simple Django app to serve a DOH (DNS Over HTTPS) Proxy. It resolves DNS query on HTTP.

Quick start

  1. Install via pip:
    1. pip install django-doh
  2. Add 'doh_server' to your INSTALLED_APPS setting like this:
    1. INSTALLED_APPS = [
    2. ...
    3. 'doh_server',
    4. ]
  3. Include the doh_server URLconf in your project urls.py like this:
    1. path('dns-query', include('doh_server.urls')),
  4. Add the conf in your settings like this:
    1. DOH_SERVER = {
    2. "RESOLVER": "internal",
    3. # "RESOLVER": "8.8.8.8",
    4. "AUTHORITY": "",
    5. "LOGGER_LEVEL": "DEBUG",
    6. }
    To use the local resolver on the server where you run Django, use "internal".

Implementation

RFC 8484

Json implementation

Use with Firefox

in about:config edit:

  1. network.trr.mode;3
  2. network.trr.uri;https://127.0.0.1/dns-query

For the URI, add your URI for your reverse proxy serving Django.

You can use Nginx as reverse proxy :

  1. events {
  2. }
  3. http {
  4. server {
  5. listen 443 ssl http2 default_server;
  6. location /dns-query {
  7. proxy_set_header Host $host;
  8. proxy_pass http://127.0.0.1:8000/dns-query;
  9. }
  10. ssl_certificate /etc/nginx/cert.pem;
  11. ssl_certificate_key /etc/nginx/key.pem;
  12. }
  13. }

Test suite

Run using tox.

  1. tox --parallel

Benchmark

Macbook Pro 2019
Processor 2,4 GHz Intel Core i5
Memory 8 GB 2133 MHz LPDDR3

Server Django and a reverse proxy Nginx in a Docker container.

apib -c 100 -d 60 @benchmark_get_url.txt

  1. HTTP/1.1
  2. Duration: 60.032 seconds
  3. Attempted requests: 7911
  4. Successful requests: 7911
  5. Non-200 results: 0
  6. Connections opened: 104
  7. Socket errors: 0
  8. Throughput: 131.780 requests/second
  9. Average latency: 734.647 milliseconds
  10. Minimum latency: 27.760 milliseconds
  11. Maximum latency: 9819.022 milliseconds
  12. Latency std. dev: 710.929 milliseconds
  13. 50% latency: 606.548 milliseconds
  14. 90% latency: 1360.734 milliseconds
  15. 98% latency: 2845.927 milliseconds
  16. 99% latency: 3612.085 milliseconds
  17. Client CPU average: 0%
  18. Client CPU max: 0%
  19. Client memory usage: 0%
  20. Total bytes sent: 1.15 megabytes
  21. Total bytes received: 2.44 megabytes
  22. Send bandwidth: 0.15 megabits / second
  23. Receive bandwidth: 0.33 megabits / second