diff --git a/dyndns.py b/dyndns.py index 4573d8af5e35ef56eab342e18e5196f81d8fdbb4..bab9a8b2111bfdccb1f4790cfffff7a390fdd8d3 100644 --- a/dyndns.py +++ b/dyndns.py @@ -45,9 +45,9 @@ async def sendRequest(session, url, urlparams): print(f"Could not reach {url}: {e}") return (url, 600) -async def sendAllRequests(urls, urlparams): +async def sendAllRequests(hosts, endpoint, urlparams): async with aiohttp.ClientSession() as session: - requests = [sendRequest(session, url, urlparams) for url in urls] + requests = [sendRequest(session, host + endpoint, urlparams) for host in hosts] return await asyncio.gather(*requests) def dyndnsRegister(**kwargs): @@ -66,7 +66,7 @@ def dyndnsRegister(**kwargs): return rqtools.redirect(rqtools.url_for('service', servicename='dyndns')) tokenseed = str(random.randint(1, 2**32)) + str(random.randint(1, 2**32)) domain = request.form['domainname'] - registrationStatuses = asyncio.run(sendAllRequests(config.get('DYNDNS_SERVER_URLS'), {'domain': domain, 'tokenseed': tokenseed})) + registrationStatuses = asyncio.run(sendAllRequests(config.get('DYNDNS_SERVER_URLS'), '/register', {'domain': domain, 'tokenseed': tokenseed})) allFail = True allSuccess = True for s in registrationStatuses: @@ -101,7 +101,7 @@ def dyndnsUpdate(**kwargs): x = db.db['dyndns-records'].find_one({'token': request.args['token']}) if x['ip'] == ip: return {'message': 'Already set.'}, 200 - updateStatuses = asyncio.run(sendAllRequests(config.get('DYNDNS_SERVER_URLS'), {'token': request.args['token'], 'ip': ip})) + updateStatuses = asyncio.run(sendAllRequests(config.get('DYNDNS_SERVER_URLS'), '/update', {'token': request.args['token'], 'ip': ip})) allFail = True allSuccess = True for s in updateStatuses: