Commit 8e925c37 authored by Robin Obůrka's avatar Robin Obůrka

Get list of available MAC addresses from cache - not from DB

This is much quicker
parent 7d1c7f1a
......@@ -34,48 +34,18 @@ o = s:option(ListValue, "make_lookup_dns", translate("Make lookup of reverse DNS
o:value(1, translate('Enable'));
o:value(0, translate('Disable'));
--[[
Get data for static names secton
]]
local db = { };
local db_path, make_lookup_mac, _ = majordomo_get_configuration();
local handle = io.popen("/bin/ls '" .. db_path .. "/" .. MONTHLY_PREFIX .. "'*", "r");
for file in handle:lines() do
read_file(db, file);
end
handle:close();
--[[
Do not duplicate addresses
]]
local uniq = {};
for k, _ in pairs(db) do
if not uniq[k] then
uniq[k] = true;
end
end
--[[
Prepare MAC cache
]]
local macdb = nil;
if make_lookup_mac then
macdb = get_inst_macdb();
macdb:deserialize();
end
local macdb = get_inst_macdb();
macdb:deserialize();
s = m:section(TypedSection, "static_name", translate("Custom device names"), translate("Here you can add your own names for the devices displayed in the list."));
s.addremove = true;
s.anonymous = true;
o = s:option(Value, "mac", translate("MAC address"));
for k, _ in pairs(uniq) do
local desc = k;
if macdb then
mac = macdb:lookup(k);
if mac then
desc = k .. " (" .. mac .. ")";
end
end
for k, v in pairs(macdb:items()) do
local desc = k .. " (" .. v .. ")";
o:value(k, desc);
end
o = s:option(Value, "name", translate("Device name"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment