luci-app-mtk: show hostname and ip address in stainfo

This commit is contained in:
hanwckf 2022-11-22 02:06:29 +08:00
parent 71364d55be
commit 29268199a0
2 changed files with 16 additions and 7 deletions

View File

@ -12,6 +12,7 @@ module("luci.controller.mtkwifi", package.seeall)
local ioctl_help = require "ioctl_helper" local ioctl_help = require "ioctl_helper"
local http = require("luci.http") local http = require("luci.http")
local mtkwifi = require("mtkwifi") local mtkwifi = require("mtkwifi")
local sys = require "luci.sys"
local logDisable = 0 local logDisable = 0
function debug_write(...) function debug_write(...)
@ -980,7 +981,12 @@ function sta_info(ifname)
local count = 0 local count = 0
for _ in pairs(stalist) do count = count + 1 end for _ in pairs(stalist) do count = count + 1 end
local hosts = sys.net.host_hints()
for i=0, count - 1 do for i=0, count - 1 do
stalist[i].ipv4 = hosts[stalist[i].MacAddr].ipv4 or ""
stalist[i].ipv6 = hosts[stalist[i].MacAddr].ipv6 or ""
stalist[i].hostname = hosts[stalist[i].MacAddr].name or "-"
table.insert(output, stalist[i]) table.insert(output, stalist[i])
end end
http.write_json(output) http.write_json(output)

View File

@ -209,7 +209,7 @@ local chipname
<th class="cbi-section-table-cell"><%:Interface%></th> <th class="cbi-section-table-cell"><%:Interface%></th>
<th class="cbi-section-table-cell">SSID</th> <th class="cbi-section-table-cell">SSID</th>
<th class="cbi-section-table-cell"><%:MAC-Address%></th> <th class="cbi-section-table-cell"><%:MAC-Address%></th>
<!--th class="cbi-section-table-cell"><%:IPv4-Address%></th--> <th class="cbi-section-table-cell"><%:Hostname%></th>
<th class="cbi-section-table-cell"><%:Signal%> (dBm)</th> <th class="cbi-section-table-cell"><%:Signal%> (dBm)</th>
<th class="cbi-section-table-cell"><%:TX Rate%></th> <th class="cbi-section-table-cell"><%:TX Rate%></th>
<th class="cbi-section-table-cell"><%:RX Rate%></th> <th class="cbi-section-table-cell"><%:RX Rate%></th>
@ -236,7 +236,7 @@ local chipname
function insert_stalist_table(ifname, ssid, sta_list) function insert_stalist_table(ifname, ssid, sta_list)
{ {
var i, tr_row, td_cell; var i, tr_row, td_cell;
var rssi_str; var rssi_str, host_str;
var tableid = document.getElementById('iw-assoclist'); var tableid = document.getElementById('iw-assoclist');
for (i = 0; sta_list[i] ; i++){ for (i = 0; sta_list[i] ; i++){
@ -253,11 +253,14 @@ local chipname
td_cell = tr_row.insertCell(-1); td_cell = tr_row.insertCell(-1);
td_cell.innerHTML = sta_list[i].MacAddr; td_cell.innerHTML = sta_list[i].MacAddr;
// FIXME: TODO host_str = sta_list[i].hostname
/* if (sta_list[i].ipv4 != "")
host_str = host_str + ", " + sta_list[i].ipv4
if (sta_list[i].ipv6 != "")
host_str = host_str + "<br>" + sta_list[i].ipv6
td_cell = tr_row.insertCell(-1); td_cell = tr_row.insertCell(-1);
td_cell.innerHTML = "IPv4 addr"; td_cell.innerHTML = host_str;
*/
rssi_str = sta_list[i].AvgRssi0 + ", " + sta_list[i].AvgRssi1; rssi_str = sta_list[i].AvgRssi0 + ", " + sta_list[i].AvgRssi1;
if (sta_list[i].AvgRssi2 != "-127") if (sta_list[i].AvgRssi2 != "-127")
rssi_str = rssi_str + ", " + sta_list[i].AvgRssi2; rssi_str = rssi_str + ", " + sta_list[i].AvgRssi2;
@ -380,7 +383,7 @@ local chipname
insert_stalist_table(stabuf[i].ifname, stabuf[i].ssid, stabuf[i].sta); insert_stalist_table(stabuf[i].ifname, stabuf[i].ssid, stabuf[i].sta);
} }
} }
setTimeout(printstainfo, 1500); setTimeout(printstainfo, 2000);
} }
function apcliInfoTimerHandler(vifNameList,idx,remSec) function apcliInfoTimerHandler(vifNameList,idx,remSec)