luci-app-upnp: add hostname info 1933/head
authorAnsuel Smith <ansuelsmth@gmail.com>
Sun, 17 Jun 2018 17:31:43 +0000 (19:31 +0200)
committerAnsuel Smith <ansuelsmth@gmail.com>
Tue, 3 Jul 2018 15:46:39 +0000 (17:46 +0200)
This adds the hostname info in the index page of luci.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
applications/luci-app-upnp/luasrc/controller/upnp.lua
applications/luci-app-upnp/luasrc/view/upnp_status.htm

index 95a0ef4862a7cd1157e028fd89062da9e575ef65..c4762434c5003e6aa1ac6e34bb0b82f125712bdc 100644 (file)
@@ -21,6 +21,8 @@ end
 function act_status()
        local uci = luci.model.uci.cursor()
        local lease_file = uci:get("upnpd", "config", "upnp_lease_file")
+       
+       local ipv4_hints = luci.sys.net.ipv4_hints()
 
        local ipt = io.popen("iptables --line-numbers -t nat -xnvL MINIUPNPD 2>/dev/null")
        if ipt then
@@ -45,12 +47,22 @@ function act_status()
                                                if uln then descr = uln:match(string.format("^%s:%d:%s:%d:%%d*:(.*)$", proto:upper(), extport, intaddr, intport)) end
                                                if not descr then descr = "" end
                                        end
+               
+                                       local host_hint, _, e
+                                       
+                                       for _,e in pairs(ipv4_hints) do
+                                               if e[1] == intaddr then
+                                                       host_hint = e[2]
+                                                       break
+                                               end
+                                       end
 
                                        fwd[#fwd+1] = {
                                                num     = num,
                                                proto   = proto:upper(),
                                                extport = extport,
                                                intaddr = intaddr,
+                                               host_hint = host_hint,
                                                intport = intport,
                                                descr = descr
                                        }
index ee385b24a8a7eaa17be3cd1eaf74f503bae2e2c7..53018e8a2ff1b82b4fb7c5b8c2e37df6d64b7af0 100644 (file)
@@ -23,6 +23,7 @@
                                                st[i].proto,
                                                st[i].extport,
                                                st[i].intaddr,
+                                               st[i].host_hint || "<%:Unknown%>",
                                                st[i].intport,
                                                st[i].descr,
                                                E('<input class="cbi-button cbi-button-remove" type="button" value="<%:Delete%>" onclick="upnp_delete_fwd(%d)" />'.format(st[i].num))
@@ -41,6 +42,7 @@
                        <div class="th"><%:Protocol%></div>
                        <div class="th"><%:External Port%></div>
                        <div class="th"><%:Client Address%></div>
+                       <div class="th"><%:Host%></div>
                        <div class="th"><%:Client Port%></div>
                        <div class="th"><%:Description%></div>
                        <div class="th cbi-section-actions">&#160;</div>