From fd6fef639b0ea1abbf853df06ed227a515a2b048 Mon Sep 17 00:00:00 2001 From: Derry Date: Wed, 24 Mar 2021 08:32:31 -0700 Subject: [PATCH] Fix the problem that the page cannot be displayed due to too many clients --- luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua | 6 ++++-- open-app-filter/src/appfilter_user.c | 8 +++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua index 036e5c6..990dd84 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua @@ -158,7 +158,7 @@ s.anonymous = true users = s:option(MultiValue, "users", "", translate("Select at least one user, otherwise it will take effect for all users")) users.widget="checkbox" --users.widget="select" -users.size=1 +users.size=6 local fd = io.open("/tmp/dev_list", "r") if not fd then return m end @@ -170,8 +170,9 @@ while true do if not line:match("Id*") then local ip=get_cmd_result(string.format("echo '%s' | awk '{print $3}'", line)) local mac=get_cmd_result(string.format("echo '%s' | awk '{print $2}'", line)) + local hostname=get_cmd_result(string.format("echo '%s' | awk '{print $4}'", line)) if mac ~= nil then - local hostname=get_hostname_by_mac(mac) + if not hostname or hostname == "*" then users:value(mac, mac); else @@ -180,6 +181,7 @@ while true do end end end +fd:close() local config_users=m.uci:get_all("appfilter.user.users") if config_users~=nil then diff --git a/open-app-filter/src/appfilter_user.c b/open-app-filter/src/appfilter_user.c index 50e3bc7..451efcb 100755 --- a/open-app-filter/src/appfilter_user.c +++ b/open-app-filter/src/appfilter_user.c @@ -156,8 +156,9 @@ void update_dev_hostname(void){ dev_node_t *node = find_dev_node(mac_buf); if (!node) continue; - if (strlen(hostname_buf) > 0) + if (strlen(hostname_buf) > 0){ strncpy(node->hostname, hostname_buf, sizeof(node->hostname)); + } } fclose(fp); } @@ -219,6 +220,8 @@ void dump_dev_list(void){ dev_node_t *node = dev_hash_table[i]; while(node){ if (node->online != 0){ + if (strlen(node->hostname) == 0) + strcpy(node->hostname, "*"); fprintf(fp, "%-4d %-20s %-20s %-32s %-8d\n", i + 1, node->mac, node->ip, node->hostname, node->online); count++; @@ -233,7 +236,10 @@ void dump_dev_list(void){ for (i = 0;i < MAX_DEV_NODE_HASH_SIZE; i++){ dev_node_t *node = dev_hash_table[i]; while(node){ + if (node->online == 0){ + if (strlen(node->hostname) == 0) + strcpy(node->hostname, "*"); fprintf(fp, "%-4d %-20s %-20s %-32s %-8d\n", i + 1, node->mac, node->ip, node->hostname, node->online); }