use urllib instead of requests
This commit is contained in:
parent
8c02790666
commit
9772a479b6
1 changed files with 15 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
||||||
import requests
|
|
||||||
|
import urllib.request
|
||||||
import argparse
|
import argparse
|
||||||
|
import json
|
||||||
|
|
||||||
class ungleichDNS(object):
|
class ungleichDNS(object):
|
||||||
def __init__(self, parser, parents):
|
def __init__(self, parser, parents):
|
||||||
|
@ -20,14 +22,21 @@ class ungleichDNS(object):
|
||||||
|
|
||||||
def _handle_dns(self, args):
|
def _handle_dns(self, args):
|
||||||
"""Reverse dns endpoint."""
|
"""Reverse dns endpoint."""
|
||||||
r = requests.post(
|
url = 'https://dns.service.ungleich.ch'
|
||||||
'https://dns.service.ungleich.ch',
|
req = urllib.request.Request(
|
||||||
json={
|
url=url,
|
||||||
|
method='POST',
|
||||||
|
headers={
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
data=json.dumps({
|
||||||
'username': args.user,
|
'username': args.user,
|
||||||
'token': args.token,
|
'token': args.token,
|
||||||
'ipaddress': args.set_reverse,
|
'ipaddress': args.set_reverse,
|
||||||
'name': args.name,
|
'name': args.name,
|
||||||
'email': args.email,
|
'email': args.email,
|
||||||
'realm': args.realm
|
'realm': args.realm
|
||||||
})
|
}).encode('utf-8')
|
||||||
print(r.text)
|
)
|
||||||
|
response = urllib.request.urlopen(req).read()
|
||||||
|
print(json.loads(response))
|
||||||
|
|
Loading…
Reference in a new issue