diff --git a/package/ctcgfw/luci-app-appfilter/luasrc/controller/appfilter.lua b/package/ctcgfw/luci-app-appfilter/luasrc/controller/appfilter.lua index d767df95e3..7521218c67 100644 --- a/package/ctcgfw/luci-app-appfilter/luasrc/controller/appfilter.lua +++ b/package/ctcgfw/luci-app-appfilter/luasrc/controller/appfilter.lua @@ -24,10 +24,8 @@ function get_hostname_by_mac(dst_mac) break end local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)") - print(ln) if dst_mac == mac then - print("match mac", mac, "hostname=", name); - fd:close() + fd:close() return name end end diff --git a/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua b/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua index 72750815a9..fc5d250a98 100644 --- a/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua +++ b/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua @@ -1,16 +1,3 @@ ---[[ -LuCI - Lua Configuration Interface - -Copyright 2008 Steven Barth - -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$ -]]-- local ds = require "luci.dispatcher" @@ -81,6 +68,57 @@ if class_fd then end class_fd:close() end + + +s=m:section(TypedSection,"user",translate("Select users")) +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" + +function get_hostname_by_mac(dst_mac) + leasefile="/tmp/dhcp.leases" + local fd = io.open(leasefile, "r") + if not fd then return end + while true do + local ln = fd:read("*l") + if not ln then + break + end + local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)") + print(ln) + if dst_mac == mac then + fd:close() + return name + end + end + fd:close() + return nil +end + +users.widget="checkbox" +--users.widget="select" +users.size=1 + +local fd = io.open("/proc/net/arp", "r") +if not fd then return end +while true do + local line = fd:read("*l") + if not line then + break + end + if not line:match("Ip*") then + local ip, hw_type, flags, mac, mask, device = line:match("(%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+)") + if device:match("lan") then + local hostname=get_hostname_by_mac(mac) + if not hostname then + users:value(mac, mac); + else + users:value(mac, hostname); + end + end + end +end + m:section(SimpleSection).template = "admin_network/user_status" diff --git a/package/ctcgfw/luci-app-appfilter/po/zh-cn/oaf.po b/package/ctcgfw/luci-app-appfilter/po/zh-cn/oaf.po index b133f7402b..3717faa1e4 100644 --- a/package/ctcgfw/luci-app-appfilter/po/zh-cn/oaf.po +++ b/package/ctcgfw/luci-app-appfilter/po/zh-cn/oaf.po @@ -41,8 +41,13 @@ msgstr "基本设置" msgid "App Filter Rules" msgstr "应用过滤规则" +msgid "Select at least one user, otherwise it will take effect for all users" +msgstr "至少选择一个用户,否则对所有用户生效" + +msgid "Select users" +msgstr "选择用户" + msgid "Enable App Filter" msgstr "开启应用过滤" - diff --git a/package/ctcgfw/luci-app-appfilter/root/etc/uci-defaults/92_add_user_section b/package/ctcgfw/luci-app-appfilter/root/etc/uci-defaults/92_add_user_section new file mode 100755 index 0000000000..a584078254 --- /dev/null +++ b/package/ctcgfw/luci-app-appfilter/root/etc/uci-defaults/92_add_user_section @@ -0,0 +1,7 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + set appfilter.user=user + commit appfilter +EOF +exit 0 diff --git a/package/ctcgfw/oaf/Makefile b/package/ctcgfw/oaf/Makefile index 33dffcfd13..1f7874c62f 100644 --- a/package/ctcgfw/oaf/Makefile +++ b/package/ctcgfw/oaf/Makefile @@ -3,12 +3,12 @@ include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=oaf PKG_VERSION:=3.0 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE_URL:=https://github.com/destan19/OpenAppFilter.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_DATE:=2020-05-26 -PKG_SOURCE_VERSION:=bba08ecedaf97bd4bbb991e32b89eb81ad017da6 +PKG_SOURCE_DATE:=2020-06-15 +PKG_SOURCE_VERSION:=08f07db43d7dd424cb763f50ed7437d35449af7c include $(INCLUDE_DIR)/package.mk diff --git a/package/ctcgfw/open-app-filter/files/appfilter.sh b/package/ctcgfw/open-app-filter/files/appfilter.sh index e600aacb93..b096c9f104 100755 --- a/package/ctcgfw/open-app-filter/files/appfilter.sh +++ b/package/ctcgfw/open-app-filter/files/appfilter.sh @@ -64,6 +64,25 @@ load_rule() config_apply "$json_str" json_cleanup } - +load_mac_list() +{ + json_init + config_load appfilter + json_add_int "op" 4 + json_add_object "data" + json_add_array "mac_list" + config_get appid_list "user" "users" + echo "appid list=$appid_list" + for appid in $appid_list: + do + echo "appid=$appid" + json_add_string "" $appid + done + json_str=`json_dump` + config_apply "$json_str" + echo "json str=$json_str" + json_cleanup +} clean_rule load_rule +load_mac_list