<%# Copyright (C) 2017 Steven Hessing This is free software, licensed under the GNU General Public License v3. /usr/lib/lua/luci/view/clients.htm -%> <%- require "nixio.fs" require "os" local last_modified = "" local style = true local v local devdump if nixio.fs.access("/var/lib/noddos/DeviceDump.json") then last_modified = os.date("%c", nixio.fs.stat("/var/lib/noddos/DeviceDump.json")['mtime']) io.input("/var/lib/noddos/DeviceDump.json") t = io.read("*all") devdump = luci.jsonc.parse(t) io.input("/var/lib/noddos/DeviceProfiles.json") t = io.read("*all") temp = luci.jsonc.parse(t) devicevalues = {} for i, v in ipairs(temp) do devicevalues[v.DeviceProfileUuid] = v end end -%> <%+header%>

<%:Clients%>

<%:The following clients have been discovered on the network. The last discovery was completed at %><%=last_modified%>
<%:Recognized Clients%>
<% for i,v in ipairs(devdump) do if v.DeviceProfileUuid ~= "" then %> <% style=false end end %>
<%:Hostname%> <%:IPv4%> <%:MAC%> <%:Manufacturer%> <%:Model%> <%:Class%>
<%=v.Hostname%> <%=v.Ipv4Address%> <%=v.MacAddress%> <%=devicevalues[v.DeviceProfileUuid].Manufacturer%> <%=devicevalues[v.DeviceProfileUuid].Model%> <%=devicevalues[v.DeviceProfileUuid].ThingClass%>

<%:Unrecognized Clients%>
<% for i,v in ipairs(devdump) do if v.DeviceProfileUuid == "" then %> <% style=false end end %>
<%:Hostname%> <%:IPv4%> <%:MAC%> <%:Manufacturer%> <%:Model%> <%:DhcpVendor%> <%:DhcpHostname%>
<%=v.Hostname%> <%=v.Ipv4Address%> <%=v.MacAddress%> <%=v.SsdpManufacturer%> <%=v.SsdpModelName%> <%=v.DhcpVendor1%> <%=v.DhcpHostname%>
<%+footer%>