rename methods dealing with client/server "fault" to more general "result"
This commit is contained in:
parent
100a2fc13c
commit
1802b91f68
@ -212,12 +212,12 @@ class NicUpdateView(View):
|
||||
result = 'nohost' # or 'badauth'?
|
||||
logger.warning("rejecting to update wrong host %s (given in query string) "
|
||||
"[instead of %s (given in basic auth)]" % (hostname, username))
|
||||
host.register_client_fault()
|
||||
host.register_client_result(fault=True)
|
||||
return Response(result)
|
||||
agent = request.META.get('HTTP_USER_AGENT', 'unknown')
|
||||
if agent in settings.BAD_AGENTS:
|
||||
logger.warning('%s - received update from bad user agent' % (hostname, ))
|
||||
host.register_client_fault()
|
||||
host.register_client_result(fault=True)
|
||||
return Response('badagent')
|
||||
ipaddr = request.GET.get('myip')
|
||||
if not ipaddr: # None or ''
|
||||
@ -352,13 +352,13 @@ def _update(host, ipaddr, secure=False, logger=None):
|
||||
return Response('good %s' % ipaddr)
|
||||
except SameIpError:
|
||||
logger.warning('%s - received no-change update, ip: %s tls: %r' % (fqdn, ipaddr, secure))
|
||||
host.register_client_fault()
|
||||
host.register_client_result(fault=True)
|
||||
return Response('nochg %s' % ipaddr)
|
||||
except (DnsUpdateError, NameServerNotAvailable) as e:
|
||||
msg = str(e)
|
||||
logger.error('%s - received update that resulted in a dns error [%s], ip: %s tls: %r' % (
|
||||
fqdn, msg, ipaddr, secure))
|
||||
host.register_server_fault()
|
||||
host.register_server_result(fault=True)
|
||||
return Response('dnserr')
|
||||
|
||||
|
||||
@ -402,5 +402,5 @@ def _delete(host, ipaddr, secure=False, logger=None):
|
||||
msg = str(e)
|
||||
logger.error('%s - received delete for record %s that resulted in a dns error [%s], tls: %r' % (
|
||||
fqdn, rdtype, msg, secure))
|
||||
host.register_server_fault()
|
||||
host.register_server_result(fault=True)
|
||||
return Response('dnserr')
|
||||
|
@ -224,12 +224,14 @@ class Host(models.Model):
|
||||
self.tls_update_ipv6 = secure
|
||||
self.save()
|
||||
|
||||
def register_client_fault(self, increment=1):
|
||||
self.client_faults += increment
|
||||
def register_client_result(self, fault=False):
|
||||
if fault:
|
||||
self.client_faults += 1
|
||||
self.save()
|
||||
|
||||
def register_server_fault(self, increment=1):
|
||||
self.server_faults += increment
|
||||
def register_server_result(self, fault=False):
|
||||
if fault:
|
||||
self.server_faults += 1
|
||||
self.save()
|
||||
|
||||
def generate_secret(self, secret=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user