<%# 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%>
<%:Hostname%>
<%:IPv4%>
<%:MAC%>
<%:Manufacturer%>
<%:Model%>
<%:Class%>
<% for i,v in ipairs(devdump) do if v.DeviceProfileUuid ~= "" then %>
<%=v.Hostname%>
<%=v.Ipv4Address%>
<%=devicevalues[v.DeviceProfileUuid].Manufacturer%>
<%=devicevalues[v.DeviceProfileUuid].Model%>
<%=devicevalues[v.DeviceProfileUuid].ThingClass%>
<% style=false end end %>

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