From 3b23203ce95c48a08b417a303ee8c6dc47f6eb60 Mon Sep 17 00:00:00 2001 From: Steven Hessing Date: Thu, 21 Sep 2017 22:08:43 -0700 Subject: luci-app-noddos: Noddos, device-aware cloud-powered firewall (new package) Signed-off-by: Steven Hessing --- .../luci-app-noddos/htdocs/cgi-bin/clientdetails | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100755 applications/luci-app-noddos/htdocs/cgi-bin/clientdetails (limited to 'applications/luci-app-noddos/htdocs/cgi-bin/clientdetails') diff --git a/applications/luci-app-noddos/htdocs/cgi-bin/clientdetails b/applications/luci-app-noddos/htdocs/cgi-bin/clientdetails new file mode 100755 index 0000000000..6ff4ce59f2 --- /dev/null +++ b/applications/luci-app-noddos/htdocs/cgi-bin/clientdetails @@ -0,0 +1,91 @@ +#!/usr/bin/lua + +-- clientdetails.lua : Provides details about client devices discovered by Noddos +-- Copyright (C) 2017 Steven Hessing (steven.hessing@gmail.com) +-- This is free software, licensed under the GNU General Public License v3. + +require "nixio.fs" + +print ("Content-type: Text/html\n") +local info = os.getenv("QUERY_STRING") + +local params = {} +local echo = {} + +function print_row(key) + print ("") + print (key) + print ("") + print (device[key]) + print ("") +end + +for name, value in string.gmatch(info .. '&', '(.-)%=(.-)%&') do + value = string.gsub(value , '%+', ' ') + value = string.gsub(value , '%%(%x%x)', function(dpc) + return string.char(tonumber(dpc,16)) + end ) + params[name] = value + + value = string.gsub(value, "%&", "&") + value = string.gsub(value, "%<", "<") + value = string.gsub(value, '%"', """) + echo[name] = value +end + +device = {} +profile = {} + +if nixio.fs.access("/var/lib/noddos/DeviceDump.json") then + io.input("/var/lib/noddos/DeviceDump.json") + local t = io.read("*all") + local json = require "luci.jsonc" + local devdump = json.parse(t) + for i, v in ipairs(devdump) do + if v.MacAddress == params["mac"] then + device = v + end + end + io.input("/var/lib/noddos/DeviceProfiles.json") + t = io.read("*all") + local temp = json.parse(t) + for i, v in ipairs(temp) do + if device.DeviceProfileUuid == v.DeviceProfileUuid then + profile = v + end + end +end +pagetop = [[ + + + Client Details by Noddos + + + + + + + + + +

Client Details

+]] +print (pagetop) + +if params["mac"] ~= nil then + print ("") + for i, key in ipairs{"MacAddress", "Ipv4Address", "Ipv6Address", "DeviceProfileUuid", "DhcpHostname", "DhcpVendor", "SsdpFriendlyName", "SsdpLocation", "SsdpManufacturer", "SsdpModelName", "SsdpModelUrl", "SsdpSerialNumber", "SsdpServer","SsdpUserAgent", "MdnsDeviceUrl", "MdnsHw", "MdnsManufacturer", "MdnsModelName", "MdnsOs", "WsDiscoveryTypes", "WsDiscoveryXaddrs", "DnsQueries"} do + print_row(key) + end + print ("
") +else + print ("no mac address specified") +end + +pagebase = [[

+Client Details by +Noddos + +]] + +print (pagebase) -- cgit v1.2.3