Commit 096f2e7d authored by Yury's avatar Yury

fix dispatcher init

parent 206b4ab0
Pipeline #70 passed with stages
in 8 minutes and 47 seconds
from .connect import Connection
from .protocol import *
from .protocol import Protocol
......@@ -6,16 +6,17 @@ import base64
class Protocol:
def __init__(self, connector):
self.connector = connector
self.app = web.Application(loop=self.connector.dispatcher.loop)
self.app = web.Application(loop=self.connector.loop)
self.app.add_routes([web.get(f'/{connector.prefix}', self.handle)])
# self.ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
# self.ssl_context.load_cert_chain(connector.cert_path, connector.key_path)
async def handle(self, request):
dispatcher = self.connector.dispatcher_cls(loop=self.connector.loop)
if request.method == 'GET':
query = request.rel_url.query['dns']
decoded_query = base64.b64decode(query + '=' * (4 - len(query) % 4))
result = await self.connector.dispatcher.handle(decoded_query)
result = await dispatcher.handle(decoded_query)
return web.Response(text=base64.b64encode(result).decode('ascii'))
elif request.method == 'POST':
pass
......
......@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name='neptune_dnsoverhttps_protocol', # How you named your package folder (MyLib)
packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']), # Chose the same as "name"
version='2019.09.15.2221', # Start with a small number and increase it with every change you make
version='2019.09.16.0907', # Start with a small number and increase it with every change you make
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
long_description='''# Neptune DNS-over-HTTPS protocol
This is a DNS over HTTPS protocol module for Neptune DNS server
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment