Commit fca772f1 authored by Yury's avatar Yury

CI tags, server_connector neptune compatibility

parent e57f8413
Pipeline #106 passed with stages
in 10 minutes and 51 seconds
......@@ -4,6 +4,8 @@ stages:
tests:
stage: unittests
tags:
- alpine
script:
- apk update
- apk add --update --no-cache --virtual .build-deps alpine-sdk python3-dev musl-dev postgresql-dev libffi-dev
......@@ -13,6 +15,8 @@ tests:
pypi_build:
stage: build
tags:
- alpine
script:
- apk update
- apk add --update --no-cache --virtual .build-deps alpine-sdk python3-dev musl-dev postgresql-dev libffi-dev
......
......@@ -3,7 +3,8 @@ from .protocol import Protocol
class Connection:
def __init__(self, dispatcher_cls, loop, cert_path, key_path, prefix='dns-request', host='0.0.0.0', port=443, with_ssl=True):
def __init__(self, dispatcher_cls, server_connector, loop, cert_path, key_path, prefix='dns-request', host='0.0.0.0', port=443, with_ssl=True):
self.server_connector = server_connector
self.dispatcher_cls = dispatcher_cls
self.loop = loop
self.cert_path = cert_path
......
......@@ -3,6 +3,7 @@ import ssl
import base64
import json
class Protocol:
def __init__(self, connector):
self.connector = connector
......@@ -14,17 +15,20 @@ class Protocol:
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 dispatcher.handle(decoded_query)
return web.Response(text=base64.b64encode(result).decode('ascii'))
elif request.method == 'POST':
data = await request.json(loads=json.loads)
query = data['dns']
decoded_query = base64.b64decode(query + '=' * (4 - len(query) % 4))
result = await dispatcher.handle(decoded_query)
return web.Response(text=base64.b64encode(result).decode('ascii'))
try:
if request.method == 'GET':
query = request.rel_url.query['dns']
decoded_query = base64.b64decode(query + '=' * (4 - len(query) % 4))
result = await dispatcher.handle(decoded_query)
return web.Response(text=base64.b64encode(result).decode('ascii'))
elif request.method == 'POST':
data = await request.json(loads=json.loads)
query = data['dns']
decoded_query = base64.b64decode(query + '=' * (4 - len(query) % 4))
result = await dispatcher.handle(decoded_query)
return web.Response(text=base64.b64encode(result).decode('ascii'))
except KeyError:
return web.Response(text='Error')
return web.Response(text='')
async def start(self):
......
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