applications/luci-upnp: also purge entry from lease file when deleting leases, remove...
authorJo-Philipp Wich <jow@openwrt.org>
Sun, 13 Jan 2013 18:33:27 +0000 (18:33 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sun, 13 Jan 2013 18:33:27 +0000 (18:33 +0000)
applications/luci-upnp/luasrc/controller/upnp.lua
applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua [deleted file]

index 7acd029..83fa941 100644 (file)
@@ -10,7 +10,6 @@ You may obtain a copy of the License at
 
        http://www.apache.org/licenses/LICENSE-2.0
 
-$Id$
 ]]--
 
 module("luci.controller.upnp", package.seeall)
@@ -25,9 +24,6 @@ function index()
        page = entry({"admin", "services", "upnp"}, cbi("upnp/upnp"), _("UPNP"))
        page.dependent = true
 
-       page = entry({"mini", "network", "upnp"}, cbi("upnp/upnpmini", {autoapply=true}), _("UPNP"))
-       page.dependent = true
-
        entry({"admin", "services", "upnp", "status"}, call("act_status")).leaf = true
        entry({"admin", "services", "upnp", "delete"}, call("act_delete")).leaf = true
 end
@@ -67,11 +63,20 @@ function act_status()
        end
 end
 
-function act_delete(idx)
-       idx = tonumber(idx)
+function act_delete(num)
+       local idx = tonumber(num)
+       local uci = luci.model.uci.cursor()
+
        if idx and idx > 0 then
                luci.sys.call("iptables -t filter -D MINIUPNPD %d 2>/dev/null" % idx)
                luci.sys.call("iptables -t nat -D MINIUPNPD %d 2>/dev/null" % idx)
+
+               local lease_file = uci:get("upnpd", "config", "upnp_lease_file")
+               if lease_file and nixio.fs.access(lease_file) then
+                       luci.sys.call("sed -i -e '%dd' %q" %{ idx, lease_file })
+               end
+
+               luci.http.status(200, "OK")
                return
        end
 
diff --git a/applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua b/applications/luci-upnp/luasrc/model/cbi/upnp/upnpmini.lua
deleted file mode 100644 (file)
index 3f1ba30..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-m = Map("upnpd", translate("Universal Plug & Play"), translate("UPNP allows clients in the local network to automatically configure the router."))
-
-s = m:section(NamedSection, "config", "upnpd", "")
-s.addremove = false
-
-e = s:option(Flag, "enabled", translate("enable"))
-e.rmempty = false
-
-s:option(Value, "download", translate("Downlink"), "kByte/s").rmempty = true
-s:option(Value, "upload", translate("Uplink"), "kByte/s").rmempty = true
-
-return m