luci-base: migrate luci/getWirelessDevices to C plugin
authorJo-Philipp Wich <jo@mein.io>
Thu, 31 Oct 2019 13:42:03 +0000 (14:42 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 1 Nov 2019 11:03:33 +0000 (12:03 +0100)
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/network.js
modules/luci-base/root/usr/libexec/rpcd/luci
modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json

index ed14af4887647e0832d29d4a5c0ed7c215c2bdb7..eaa4b3bb9fdd9fb1db12778455e60fbcbe1ebba3 100644 (file)
@@ -51,7 +51,7 @@ var callLuciNetworkDevices = rpc.declare({
 });
 
 var callLuciWirelessDevices = rpc.declare({
-       object: 'luci',
+       object: 'luci-rpc',
        method: 'getWirelessDevices',
        expect: { '': {} }
 });
index 8a3e0b0c0fa725763f4a1805169891ff6ff1ea5b..da36270a1745331944b5d1bc4c0ba7b0c573525c 100755 (executable)
@@ -249,66 +249,6 @@ local methods = {
                end
        },
 
-       getWirelessDevices = {
-               call = function(args)
-                       local ubus = require "ubus".connect()
-                       if not ubus then
-                               return { error = "Unable to establish ubus connection" }
-                       end
-
-                       local status = ubus:call("network.wireless", "status", {})
-                       if type(status) == "table" then
-                               local radioname, radiodata
-                               for radioname, radiodata in pairs(status) do
-                                       if type(radiodata) == "table" then
-                                               radiodata.iwinfo = ubus:call("iwinfo", "info", { device = radioname }) or {}
-                                               radiodata.iwinfo.bitrate     = nil
-                                               radiodata.iwinfo.bssid       = nil
-                                               radiodata.iwinfo.encryption  = nil
-                                               radiodata.iwinfo.mode        = nil
-                                               radiodata.iwinfo.quality     = nil
-                                               radiodata.iwinfo.quality_max = nil
-                                               radiodata.iwinfo.ssid        = nil
-
-                                               local iwdata = nil
-
-                                               if type(radiodata.interfaces) == "table" then
-                                                       local _, interfacedata
-                                                       for _, interfacedata in ipairs(radiodata.interfaces) do
-                                                               if type(interfacedata) == "table" and
-                                                                  type(interfacedata.ifname) == "string"
-                                                               then
-                                                                       local iwinfo = ubus:call("iwinfo", "info", { device = interfacedata.ifname })
-
-                                                                       iwdata = iwdata or iwinfo
-                                                                       interfacedata.iwinfo = iwinfo or {}
-                                                               end
-                                                       end
-                                               end
-
-                                               radiodata.iwinfo = {}
-
-                                               local _, k, v
-                                               for k, v in pairs(iwdata or ubus:call("iwinfo", "info", { device = radioname }) or {}) do
-                                                       if k ~= "bitrate" and k ~= "bssid" and k ~= "encryption" and
-                                                          k ~= "mode" and k ~= "quality" and k ~= "quality_max" and
-                                                          k ~= "ssid"
-                                                       then
-                                                               if type(v) == "table" then
-                                                                       radiodata.iwinfo[k] = json.parse(json.stringify(v))
-                                                               else
-                                                                       radiodata.iwinfo[k] = v
-                                                               end
-                                                       end
-                                               end
-                                       end
-                               end
-                       end
-
-                       return status
-               end
-       },
-
        getConntrackHelpers = {
                call = function()
                        local ok, fd = pcall(io.open, "/usr/share/fw3/helpers.conf", "r")
index 6f08cd7df991d1b4a54346f42bf7fb9c08769822..912707a8446b03f67496fd5d7977bdc5c7f0353b 100644 (file)
@@ -41,8 +41,8 @@
                        "ubus": {
                                "file": [ "list", "read", "stat" ],
                                "iwinfo": [ "assoclist", "freqlist", "txpowerlist", "countrylist" ],
-                               "luci": [ "getDUIDHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getLEDs", "getNetworkDevices", "getUSBDevices", "getWirelessDevices", "getSwconfigFeatures", "getSwconfigPortState", "getBlockDevices", "getMountPoints" ],
-                               "luci-rpc": [ "getBoardJSON", "getDHCPLeases", "getHostHints" ],
+                               "luci": [ "getDUIDHints", "getIfaddrs", "getInitList", "getLocaltime", "getTimezones", "getLEDs", "getNetworkDevices", "getUSBDevices", "getSwconfigFeatures", "getSwconfigPortState", "getBlockDevices", "getMountPoints" ],
+                               "luci-rpc": [ "getBoardJSON", "getDHCPLeases", "getHostHints", "getWirelessDevices" ],
                                "network.device": [ "status" ],
                                "network.interface": [ "dump" ],
                                "network": [ "get_proto_handlers" ],