diff --git a/packages/ns-api/files/ns.dns b/packages/ns-api/files/ns.dns index 66dc5d5d6..50b873146 100755 --- a/packages/ns-api/files/ns.dns +++ b/packages/ns-api/files/ns.dns @@ -37,11 +37,11 @@ def add_record(args): def is_wildcard(u, ip, name): try: - cur = u.get('dhcp', get_server(u), 'address', list=True) + cur = list(u.get('dhcp', get_server(u), 'address', list=True)) except: return False - for addr in cur[0].split(","): + for addr in cur: if f'/{name}/{ip}' == addr: return True return False @@ -50,28 +50,26 @@ def remove_wildcard(u, ip, name): server = get_server(u) new = [] try: - cur = u.get('dhcp', server, 'address', list=True) + cur = list(u.get('dhcp', server, 'address', list=True)) except: return - for addr in cur[0].split(","): + for addr in cur: if f'/{name}/{ip}' == addr: continue new.append(addr) - u.set('dhcp', server, 'address', ",".join(new)) + u.set('dhcp', server, 'address', new) u.save('dhcp') def add_wildcard(u, ip, name): remove_wildcard(u, ip, name) server = get_server(u) - address_list = [] try: - for addr in u.get("dhcp", server, "address", default=[], list=True): - address_list.append(addr) + addr = list(u.get('dhcp', server, 'address', list=True)) except: - pass + addr = [] - address_list.append(f'/{name}/{ip}') - u.set('dhcp', server, 'address', ",".join(address_list)) + addr.append(f'/{name}/{ip}') + u.set('dhcp', server, 'address', addr) u.save('dhcp') def edit_record(args):