views.py: prevent backtrace with unregistered client

Add check to skip unregistered clients in get_server_data_from_scopes
to prevent KeyError exception.
master
Alejandro Sirgo Rica 2024-10-10 11:48:29 +02:00
parent 75cd6d9883
commit bcffdff135
1 changed files with 3 additions and 0 deletions

View File

@ -608,6 +608,9 @@ def get_server_data_from_scopes(scopes, clients):
ip_to_name = {ip: c['name'] for c in parse_scopes_from_tree(scopes, 'computer') for ip in c['ip']}
for client in clients['clients']:
if not client['addr'] in ip_to_name:
continue
client['name'] = ip_to_name[client['addr']]
server_id = client['server'].id
if server_id not in servers_data: