diff options
author | Wang805447391 <805447391@qq.com> | 2018-11-12 15:03:31 +0800 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2018-11-15 08:28:45 +0100 |
commit | 09ac96ede9f15119ee08c34ba05f885aeaa8e449 (patch) | |
tree | 1a7164224606a86654bcbbb75dd925b5d43077a1 /modules/luci-base/luasrc/view | |
parent | 8aeb78d1c1893e1bcf0e3a8f8a2c17fa6ffbb6d2 (diff) |
luci-base: support disconnecting (deauthenticating) wireless clients
Add a button to each row in the wireless assoclist table to allow
disconnecting clients using the ubus del_client method if the underlying
radio interface supports it.
Ref: https://github.com/openwrt/luci/pull/2271
Submitted-by: Wang805447391 <805447391@qq.com>
[move deauth function to luci-base next to the existing assoclist function,
require post security, fix parameter check condition, hide button if not
supported by the radio, disable button after call, squash commits, fix
whitespace, reword subject, add commit message]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/luasrc/view')
-rw-r--r-- | modules/luci-base/luasrc/view/wifi_assoclist.htm | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/modules/luci-base/luasrc/view/wifi_assoclist.htm b/modules/luci-base/luasrc/view/wifi_assoclist.htm index 700d998ad8..b7147bfb71 100644 --- a/modules/luci-base/luasrc/view/wifi_assoclist.htm +++ b/modules/luci-base/luasrc/view/wifi_assoclist.htm @@ -1,4 +1,21 @@ +<% + local supports_deauth = {} + + local _, v + for _, v in ipairs(luci.util.ubus()) do + local iface = v:match("^hostapd%.(.+)$") + if iface then + local funcs = luci.util.ubus(v) + if type(funcs) == "table" and funcs.del_client then + supports_deauth[iface] = true + end + end + end +%> + <script type="text/javascript">//<![CDATA[ + var supports_deauth = <%= luci.http.write_json(supports_deauth) %>; + function wifirate(bss, rx) { var p = rx ? 'rx_' : 'tx_', s = '%.1f <%:Mbit/s%>, %d<%:MHz%>' @@ -17,6 +34,16 @@ return s; } + function handleDeauth(ev) { + (new XHR()).post('<%=url('admin/wireless_deauth')%>', { + token: '<%=token%>', + iface: ev.target.getAttribute('data-iface'), + bssid: ev.target.getAttribute('data-bssid') + }, function() { + ev.target.disabled = true; + }); + } + XHR.poll(5, '<%=url('admin/wireless_assoclist')%>', null, function(x, st) { @@ -58,7 +85,15 @@ E('span', wifirate(bss, true)), E('br'), E('span', wifirate(bss, false)) - ]) + ]), + supports_deauth[bss.ifname] ? E('input', { + type: 'button', + class: 'cbi-button cbi-button-remove', + value: '<%:Disconnect%>', + 'data-bssid': bss.bssid, + 'data-iface': bss.ifname, + click: handleDeauth + }) : '-' ]); }); @@ -75,6 +110,9 @@ <div class="th nowrap"><%:Host%></div> <div class="th nowrap"><%:Signal%> / <%:Noise%></div> <div class="th nowrap"><%:RX Rate%> / <%:TX Rate%></div> + <% if next(supports_deauth) then %> + <div class="th right"><%:Disconnect%></div> + <% end %> </div> <div class="tr placeholder"> <div class="td"><em><%:Collecting data...%></em></div> |