From 9772a479b6df712a30c0ac1e9104293fb407a7a6 Mon Sep 17 00:00:00 2001 From: William Colmenares Date: Thu, 6 Jun 2019 10:19:43 -0400 Subject: [PATCH] use urllib instead of requests --- ungleich_dns.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ungleich_dns.py b/ungleich_dns.py index 86b9dbe..85eb6bd 100644 --- a/ungleich_dns.py +++ b/ungleich_dns.py @@ -1,5 +1,7 @@ -import requests + +import urllib.request import argparse +import json class ungleichDNS(object): def __init__(self, parser, parents): @@ -20,14 +22,21 @@ class ungleichDNS(object): def _handle_dns(self, args): """Reverse dns endpoint.""" - r = requests.post( - 'https://dns.service.ungleich.ch', - json={ + url = 'https://dns.service.ungleich.ch' + req = urllib.request.Request( + url=url, + method='POST', + headers={ + "Content-Type": "application/json" + }, + data=json.dumps({ 'username': args.user, 'token': args.token, 'ipaddress': args.set_reverse, 'name': args.name, 'email': args.email, 'realm': args.realm - }) - print(r.text) + }).encode('utf-8') + ) + response = urllib.request.urlopen(req).read() + print(json.loads(response))