summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-upnp
diff options
context:
space:
mode:
Diffstat (limited to 'applications/luci-app-upnp')
-rw-r--r--applications/luci-app-upnp/luasrc/controller/upnp.lua15
-rw-r--r--applications/luci-app-upnp/luasrc/view/upnp_status.htm4
2 files changed, 17 insertions, 2 deletions
diff --git a/applications/luci-app-upnp/luasrc/controller/upnp.lua b/applications/luci-app-upnp/luasrc/controller/upnp.lua
index c60b7c4969..e485708f0e 100644
--- a/applications/luci-app-upnp/luasrc/controller/upnp.lua
+++ b/applications/luci-app-upnp/luasrc/controller/upnp.lua
@@ -19,8 +19,12 @@ function index()
end
function act_status()
+ local uci = luci.model.uci.cursor()
+ local lease_file = uci:get("upnpd", "config", "upnp_lease_file")
+
local ipt = io.popen("iptables --line-numbers -t nat -xnvL MINIUPNPD 2>/dev/null")
if ipt then
+ local upnpf = lease_file and io.open(lease_file, "r")
local fwd = { }
while true do
local ln = ipt:read("*l")
@@ -29,23 +33,32 @@ function act_status()
elseif ln:match("^%d+") then
local num, proto, extport, intaddr, intport =
ln:match("^(%d+).-([a-z]+).-dpt:(%d+) to:(%S-):(%d+)")
+ local descr = ""
if num and proto and extport and intaddr and intport then
num = tonumber(num)
extport = tonumber(extport)
intport = tonumber(intport)
+
+ if upnpf then
+ local uln = upnpf:read("*l")
+ 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
fwd[#fwd+1] = {
num = num,
proto = proto:upper(),
extport = extport,
intaddr = intaddr,
- intport = intport
+ intport = intport,
+ descr = descr
}
end
end
end
+ if upnpf then upnpf:close() end
ipt:close()
luci.http.prepare_content("application/json")
diff --git a/applications/luci-app-upnp/luasrc/view/upnp_status.htm b/applications/luci-app-upnp/luasrc/view/upnp_status.htm
index e358dcded3..89fdb5e218 100644
--- a/applications/luci-app-upnp/luasrc/view/upnp_status.htm
+++ b/applications/luci-app-upnp/luasrc/view/upnp_status.htm
@@ -29,9 +29,10 @@
tr.insertCell(-1).innerHTML = st[i].extport;
tr.insertCell(-1).innerHTML = st[i].intaddr;
tr.insertCell(-1).innerHTML = st[i].intport;
+ tr.insertCell(-1).innerHTML = st[i].descr;
tr.insertCell(-1).innerHTML = String.format(
- '<input class="cbi-button cbi-input-remove" type="button" value="<%:Delete Redirect%>" onclick="upnp_delete_fwd(%d)" />',
+ '<input class="cbi-button cbi-input-remove" type="button" value="<%:Delete%>" onclick="upnp_delete_fwd(%d)" />',
st[i].num
);
}
@@ -58,6 +59,7 @@
<th class="cbi-section-table-cell"><%:External Port%></th>
<th class="cbi-section-table-cell"><%:Client Address%></th>
<th class="cbi-section-table-cell"><%:Client Port%></th>
+ <th class="cbi-section-table-cell"><%:Description%></th>
<th class="cbi-section-table-cell">&#160;</th>
</tr>
<tr class="cbi-section-table-row">