Change _process_ip_update to always return a set of three values
This commit is contained in:
@@ -286,11 +286,8 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
# Determine IPs to update
|
# Determine IPs to update
|
||||||
result = self._process_ip_update(hostname, params, endpoint, client_ip)
|
result = self._process_ip_update(hostname, params, endpoint, client_ip)
|
||||||
if result:
|
if result:
|
||||||
code, status, *kwargs = result
|
code, status, kwargs = result
|
||||||
if kwargs:
|
self.respond(code, status, **kwargs)
|
||||||
self.respond(code, status, **kwargs[0])
|
|
||||||
else:
|
|
||||||
self.respond(code, status)
|
|
||||||
|
|
||||||
def _handle_bad_request(self, client_ip, code, status):
|
def _handle_bad_request(self, client_ip, code, status):
|
||||||
"""Handle bad request and record in rate limiter."""
|
"""Handle bad request and record in rate limiter."""
|
||||||
@@ -315,7 +312,7 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
else:
|
else:
|
||||||
ipv6 = myip
|
ipv6 = myip
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return (400, STATUS_BADIP)
|
return (400, STATUS_BADIP, {})
|
||||||
|
|
||||||
# Process myip6 parameter
|
# Process myip6 parameter
|
||||||
if myip6:
|
if myip6:
|
||||||
@@ -324,9 +321,9 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
if rtype == "AAAA":
|
if rtype == "AAAA":
|
||||||
ipv6 = myip6
|
ipv6 = myip6
|
||||||
else:
|
else:
|
||||||
return (400, STATUS_BADIP)
|
return (400, STATUS_BADIP, {})
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return (400, STATUS_BADIP)
|
return (400, STATUS_BADIP, {})
|
||||||
|
|
||||||
# Auto-detect from client IP if no params
|
# Auto-detect from client IP if no params
|
||||||
if ipv4 is None and ipv6 is None:
|
if ipv4 is None and ipv6 is None:
|
||||||
@@ -337,7 +334,7 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
else:
|
else:
|
||||||
ipv6 = ip
|
ipv6 = ip
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return (400, STATUS_BADIP)
|
return (400, STATUS_BADIP, {})
|
||||||
|
|
||||||
now = utc_now()
|
now = utc_now()
|
||||||
|
|
||||||
@@ -362,7 +359,7 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
f"DNS update failed: client={client_ip} hostname={hostname.hostname} "
|
f"DNS update failed: client={client_ip} hostname={hostname.hostname} "
|
||||||
f"zone={hostname.zone} ipv4={ipv4} error={e}"
|
f"zone={hostname.zone} ipv4={ipv4} error={e}"
|
||||||
)
|
)
|
||||||
return (500, STATUS_DNSERR)
|
return (500, STATUS_DNSERR, {})
|
||||||
|
|
||||||
if ipv6:
|
if ipv6:
|
||||||
hostname.last_ipv6_update = now
|
hostname.last_ipv6_update = now
|
||||||
@@ -383,7 +380,7 @@ class DDNSRequestHandler(BaseHTTPRequestHandler):
|
|||||||
f"DNS update failed: client={client_ip} hostname={hostname.hostname} "
|
f"DNS update failed: client={client_ip} hostname={hostname.hostname} "
|
||||||
f"zone={hostname.zone} ipv6={ipv6} error={e}"
|
f"zone={hostname.zone} ipv6={ipv6} error={e}"
|
||||||
)
|
)
|
||||||
return (500, STATUS_DNSERR)
|
return (500, STATUS_DNSERR, {})
|
||||||
|
|
||||||
# Update database
|
# Update database
|
||||||
hostname.save()
|
hostname.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user