From c851fdb165ae48c93e70a5b00ae99df46d27949c Mon Sep 17 00:00:00 2001 From: Filip Znachor Date: Sun, 25 Jul 2021 22:43:31 +0000 Subject: [PATCH] Update dyndns.lua --- DynDNS/dyndns.lua | 84 ++--------------------------------------------- 1 file changed, 2 insertions(+), 82 deletions(-) diff --git a/DynDNS/dyndns.lua b/DynDNS/dyndns.lua index c4ffc6f..cc85ccf 100644 --- a/DynDNS/dyndns.lua +++ b/DynDNS/dyndns.lua @@ -6,7 +6,7 @@ local dhcp_leases_file = "/tmp/dhcp.leases" local lookup_ip_neigh = true local non_fqdn = true -local network_domain = "chata.lan" +local network_domain = ".lan" local output_file = "/tmp/dyndns" @@ -66,86 +66,6 @@ function count(T) return count end -function print_table(node) - local cache, stack, output = {},{},{} - local depth = 1 - local output_str = "{\n" - - while true do - local size = 0 - for k,v in pairs(node) do - size = size + 1 - end - - local cur_index = 1 - for k,v in pairs(node) do - if (cache[node] == nil) or (cur_index >= cache[node]) then - - if (string.find(output_str,"}",output_str:len())) then - output_str = output_str .. ",\n" - elseif not (string.find(output_str,"\n",output_str:len())) then - output_str = output_str .. "\n" - end - - -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings - table.insert(output,output_str) - output_str = "" - - local key - if (type(k) == "number" or type(k) == "boolean") then - key = "["..tostring(k).."]" - else - key = "['"..tostring(k).."']" - end - - if (type(v) == "number" or type(v) == "boolean") then - output_str = output_str .. string.rep('\t',depth) .. key .. " = "..tostring(v) - elseif (type(v) == "table") then - output_str = output_str .. string.rep('\t',depth) .. key .. " = {\n" - table.insert(stack,node) - table.insert(stack,v) - cache[node] = cur_index+1 - break - else - output_str = output_str .. string.rep('\t',depth) .. key .. " = '"..tostring(v).."'" - end - - if (cur_index == size) then - output_str = output_str .. "\n" .. string.rep('\t',depth-1) .. "}" - else - output_str = output_str .. "," - end - else - -- close the table - if (cur_index == size) then - output_str = output_str .. "\n" .. string.rep('\t',depth-1) .. "}" - end - end - - cur_index = cur_index + 1 - end - - if (size == 0) then - output_str = output_str .. "\n" .. string.rep('\t',depth-1) .. "}" - end - - if (#stack > 0) then - node = stack[#stack] - stack[#stack] = nil - depth = cache[node] == nil and depth + 1 or depth - 1 - else - break - end - end - - -- This is necessary for working with HUGE tables otherwise we run out of memory using concat on huge strings - table.insert(output,output_str) - output_str = table.concat(output) - - print(output_str) -end - - array = {} @@ -209,4 +129,4 @@ file = io.open(output_file, "w") file:write(config) file:close() -os.execute(reload_command) \ No newline at end of file +os.execute(reload_command)