diff --git a/luci-app-oaf/Makefile b/luci-app-oaf/Makefile
index 764ec74..bebf5f9 100755
--- a/luci-app-oaf/Makefile
+++ b/luci-app-oaf/Makefile
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
LUCI_TITLE:=Open App Filter Module
LUCI_PKGARCH:=all
-LUCI_DEPENDS:=+kmod-oaf +appfilter
+LUCI_DEPENDS:=+appfilter
PKG_NAME:=luci-app-oaf
PKG_VERSION:=5.0
PKG_RELEASE:=1
diff --git a/luci-app-oaf/luasrc/controller/appfilter.lua b/luci-app-oaf/luasrc/controller/appfilter.lua
index 383682f..284d39a 100755
--- a/luci-app-oaf/luasrc/controller/appfilter.lua
+++ b/luci-app-oaf/luasrc/controller/appfilter.lua
@@ -8,10 +8,26 @@ function index()
end
local page
- page = entry({"admin", "network", "appfilter"}, arcombine(cbi("appfilter/appfilter"), cbi("appfilter/dev_status", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true})), _("App Filter"), 100)
+ entry({"admin", "services", "appfilter"},
+ alias("admin", "services", "appfilter", "user_list"),
+ _("应用过滤"), 20).dependent = true
- page.leaf = true
- page.subindex = true
+ entry({"admin", "services", "appfilter", "user_list"},
+ arcombine(cbi("appfilter/user_list",{hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),
+ cbi("appfilter/dev_status", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true})),
+ _("用户列表"), 21).leaf=true
+
+ entry({"admin", "services", "appfilter", "base_setting"},
+ cbi("appfilter/base_setting"), _("应用过滤规则"), 22).leaf=true
+
+ entry({"admin", "services", "appfilter", "user_setting"},
+ cbi("appfilter/user_setting"), _("生效用户"), 23).leaf=true
+
+ entry({"admin", "services", "appfilter", "time_setting"},
+ cbi("appfilter/time_setting"), _("生效时间"), 24).leaf=true
+
+ entry({"admin", "services", "appfilter", "feature"},
+ cbi("appfilter/feature", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), _("特征库升级"), 25).leaf=true
page = entry({"admin", "network", "user_status"}, call("user_status"), nil)
page.leaf = true
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua
deleted file mode 100755
index 2af91ef..0000000
--- a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua
+++ /dev/null
@@ -1,228 +0,0 @@
-
-local ds = require "luci.dispatcher"
-local nxo = require "nixio"
-local nfs = require "nixio.fs"
-local ipc = require "luci.ip"
-local sys = require "luci.sys"
-local utl = require "luci.util"
-local dsp = require "luci.dispatcher"
-local uci = require "luci.model.uci"
-local lng = require "luci.i18n"
-local jsc = require "luci.jsonc"
-local http = luci.http
-local SYS = require "luci.sys"
-local m, s
-
-m = Map("appfilter",
- translate("App Filter"),
- translate(""))
-
-s = m:section(TypedSection, "global", translate("Basic Settings"))
-s:option(Flag, "enable", translate("Enable App Filter"),translate(""))
-s.anonymous = true
-
-local rule_count=0
-local version=""
-if nixio.fs.access("/tmp/feature.cfg") then
- rule_count=tonumber(SYS.exec("cat /tmp/feature.cfg | wc -l"))
- version=SYS.exec("cat /tmp/feature.cfg |grep \"#version\" | awk '{print $2}'")
-end
-
-
-local display_str="当前版本: "..version.."
特征码个数: "..rule_count.."
下载地址:https://destan19.github.io"
-s = m:section(TypedSection, "feature", translate("Update feature"), display_str )
-
-fu = s:option(FileUpload, "")
-fu.template = "cbi/oaf_upload"
-s.anonymous = true
-
-um = s:option(DummyValue, "rule_data")
-
-s=m:section(TypedSection,"time",translate("Time Setting")) s.anonymous = true
-hv = s:option(Value, "start_time", translate("Start Time")) hv.default="00:00"
-hv.optional=false
-hv = s:option(Value, "end_time", translate("End Time")) hv.default="23:59"
-hv.optional=false days = s:option(MultiValue, "days", "", translate(""))
-days.widget="checkbox" days.size=10
-days:value("0", translate("Sun"));
-days:value("1", translate("Mon"));
-days:value("2", translate("Tue"));
-days:value("3", translate("Wed"));
-days:value("4", translate("Thur"));
-days:value("5", translate("Fri"));
-days:value("6", translate("Sat"));
-
-s = m:section(TypedSection, "appfilter", translate("App Filter Rules"))
-s.anonymous = true
-s.addremove = false
-
-local class_fd = io.popen("find /tmp/appfilter/ -type f -name '*.class'")
-if class_fd then
- while true do
- local apps
- local class
- local path = class_fd:read("*l")
- if not path then
- break
- end
-
- class = path:match("([^/]+)%.class$")
- s:tab(class, translate(class))
- apps = s:taboption(class, MultiValue, class.."apps", translate(""))
- apps.rmempty=true
- apps.widget="checkbox"
- apps.size=10
-
- local fd = io.open(path)
- if fd then
- local line
- while true do
- local cmd
- local cmd_fd
- line = fd:read("*l")
- if not line then break end
- if string.len(line) < 5 then break end
- if not string.find(line,"#") then
- cmd = "echo "..line.."|awk '{print $1}'"
- cmd_fd = io.popen(cmd)
- id = cmd_fd:read("*l");
- cmd_fd:close()
-
- cmd = "echo "..line.."|awk '{print $2}'"
- cmd_fd = io.popen(cmd)
- name = cmd_fd:read("*l")
-
- cmd_fd:close()
- if not id then break end
- if not name then break end
- apps:value(id, name)
- end
- end
- fd:close()
- end
- end
- class_fd:close()
-end
-
-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
-
-function get_cmd_result(command)
- local fd
- local result
- fd = io.popen(command);
- if not fd then return "" end
- result = fd:read("*l");
- fd:close()
- return result
-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"
---users.widget="select"
-users.size=6
-
-local fd = io.open("/tmp/dev_list", "r")
-if not fd then return m end
-while true do
- local line = fd:read("*l")
- if not line then
- break
- end
- if not string.match(line, "^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
-
- if not hostname or hostname == "*" then
- users:value(mac, mac);
- else
- users:value(mac, hostname.."("..mac..")");
- end
- end
- end
-end
-fd:close()
-
-local config_users=m.uci:get_all("appfilter.user.users")
-if config_users~=nil and config_users~=false then
- local r=utl.split(config_users, "%s+", nil, true)
- local max = table.getn(r)
- for i=1,max,1 do
- users:value(r[i], r[i]);
- end
-end
-m:section(SimpleSection).template = "admin_network/user_status"
-local dir, fd
-dir = "/tmp/upload/"
-nixio.fs.mkdir(dir)
-http.setfilehandler(
- function(meta, chunk, eof)
- if not fd then
- if not meta then return end
- if meta and chunk then fd = nixio.open(dir .. meta.file, "w") end
- if not fd then
- return
- end
- end
- if chunk and fd then
- fd:write(chunk)
- end
- if eof and fd then
- fd:close()
- local fd2 = io.open("/tmp/upload/"..meta.file)
- local line=fd2:read("*l");
- fd2:close()
- local ret=string.match(line, "#version")
- local lang=m.uci:get_all("luci.main.lang")
- local feature_file=""
- if "" == lang or "auto" == lang then
- feature_file="/etc/appfilter/feature.cfg"
- else
- feature_file="/etc/appfilter/feature_"..lang..".cfg"
- end
- if ret ~= nil then
- local cmd="cp /tmp/upload/"..meta.file.." "..feature_file;
- os.execute(cmd);
- os.execute("chmod 666 "..feature_file);
- os.execute("rm /tmp/appfilter -fr");
- luci.sys.exec("/etc/init.d/appfilter restart &");
- um.value = translate("Update the feature file successfully, please refresh the page")
- else
- um.value = translate("Failed to update feature file, format error")
- end
- os.execute("rm /tmp/upload/* -fr");
- end
-
- end
-)
-
-if luci.http.formvalue("upload") then
- local f = luci.http.formvalue("ulfile")
- if #f <= 0 then
- --um.value = translate("No specify upload file.")
- end
-elseif luci.http.formvalue("download") then
- Download()
-end
-return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua
new file mode 100755
index 0000000..f88ecba
--- /dev/null
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua
@@ -0,0 +1,85 @@
+local ds = require "luci.dispatcher"
+local nxo = require "nixio"
+local nfs = require "nixio.fs"
+local ipc = require "luci.ip"
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local dsp = require "luci.dispatcher"
+local uci = require "luci.model.uci"
+local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
+local http = luci.http
+local SYS = require "luci.sys"
+local m, s
+
+m = Map("appfilter", translate("App Filter"), translate(
+ "目前不支持旁路模式,请先关闭所有加速(acc)、广告过滤、多拨等可能冲突的模块"))
+
+s = m:section(TypedSection, "global", translate("Basic Settings"))
+s:option(Flag, "enable", translate("Enable App Filter"), translate(""))
+s.anonymous = true
+
+local rule_count = 0
+local version = ""
+
+s = m:section(TypedSection, "appfilter", translate("App Filter Rules"))
+s.anonymous = true
+s.addremove = false
+
+local class_fd = io.popen("find /tmp/appfilter/ -type f -name '*.class'")
+if class_fd then
+ while true do
+ local apps
+ local class
+ local path = class_fd:read("*l")
+ if not path then
+ break
+ end
+
+ class = path:match("([^/]+)%.class$")
+ s:tab(class, translate(class))
+ apps = s:taboption(class, MultiValue, class .. "apps", translate(""))
+ apps.rmempty = true
+ apps.widget = "checkbox"
+ apps.size = 10
+
+ local fd = io.open(path)
+ if fd then
+ local line
+ while true do
+ local cmd
+ local cmd_fd
+ line = fd:read("*l")
+ if not line then
+ break
+ end
+ if string.len(line) < 5 then
+ break
+ end
+ if not string.find(line, "#") then
+ cmd = "echo " .. line .. "|awk '{print $1}'"
+ cmd_fd = io.popen(cmd)
+ id = cmd_fd:read("*l");
+ cmd_fd:close()
+
+ cmd = "echo " .. line .. "|awk '{print $2}'"
+ cmd_fd = io.popen(cmd)
+ name = cmd_fd:read("*l")
+
+ cmd_fd:close()
+ if not id then
+ break
+ end
+ if not name then
+ break
+ end
+ apps:value(id, name)
+ end
+ end
+ fd:close()
+ end
+ end
+ class_fd:close()
+end
+
+return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua
index 09133b0..90d6402 100755
--- a/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua
@@ -1,4 +1,3 @@
-
local ds = require "luci.dispatcher"
local nxo = require "nixio"
local nfs = require "nixio.fs"
@@ -12,13 +11,11 @@ local jsc = require "luci.jsonc"
local m, s
arg[1] = arg[1] or ""
-m = Map("appfilter",
- translate("Data Statistics").."("..arg[1]..")",
- translate(""))
-
+m = Map("appfilter", translate("Data Statistics") .. "(" .. arg[1] .. ")", translate(""))
+
local v
-v=m:section(SimpleSection)
-v.template="admin_network/dev_status"
-v.mac=arg[1]
-m.redirect = luci.dispatcher.build_url("admin", "network", "appfilter")
+v = m:section(SimpleSection)
+v.template = "admin_network/dev_status"
+v.mac = arg[1]
+m.redirect = luci.dispatcher.build_url("admin", "services", "appfilter")
return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua
new file mode 100755
index 0000000..11e744f
--- /dev/null
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua
@@ -0,0 +1,91 @@
+local ds = require "luci.dispatcher"
+local nxo = require "nixio"
+local nfs = require "nixio.fs"
+local ipc = require "luci.ip"
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local dsp = require "luci.dispatcher"
+local uci = require "luci.model.uci"
+local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
+local http = luci.http
+local SYS = require "luci.sys"
+local m, s
+
+m = Map("appfilter", translate(""),
+ translate("特征库用于描述app特征,app过滤效果和个数依赖特征库"))
+
+local rule_count = 0
+local version = ""
+if nixio.fs.access("/tmp/feature.cfg") then
+ rule_count = tonumber(SYS.exec("cat /tmp/feature.cfg | wc -l"))
+ version = SYS.exec("cat /tmp/feature.cfg |grep \"#version\" | awk '{print $2}'")
+end
+
+local display_str = "当前版本: " .. version .. "
特征码个数: " ..
+ rule_count ..
+ "
下载地址:https://destan19.github.io"
+s = m:section(TypedSection, "feature", translate("Update feature"), display_str)
+
+fu = s:option(FileUpload, "")
+fu.template = "cbi/oaf_upload"
+s.anonymous = true
+
+um = s:option(DummyValue, "rule_data")
+um.template = "cbi/oaf_dvalue"
+
+local dir, fd
+dir = "/tmp/upload/"
+nixio.fs.mkdir(dir)
+http.setfilehandler(function(meta, chunk, eof)
+ if not fd then
+ if not meta then
+ return
+ end
+ if meta and chunk then
+ fd = nixio.open(dir .. meta.file, "w")
+ end
+ if not fd then
+ return
+ end
+ end
+ if chunk and fd then
+ fd:write(chunk)
+ end
+ if eof and fd then
+ fd:close()
+ local fd2 = io.open("/tmp/upload/" .. meta.file)
+ local line = fd2:read("*l");
+ fd2:close()
+ local ret = string.match(line, "#version")
+ local lang = m.uci:get_all("luci.main.lang")
+ local feature_file = ""
+ if "" == lang or "auto" == lang then
+ feature_file = "/etc/appfilter/feature.cfg"
+ else
+ feature_file = "/etc/appfilter/feature_" .. lang .. ".cfg"
+ end
+ if ret ~= nil then
+ local cmd = "cp /tmp/upload/" .. meta.file .. " " .. feature_file;
+ os.execute(cmd);
+ os.execute("chmod 666 " .. feature_file);
+ os.execute("rm /tmp/appfilter -fr");
+ luci.sys.exec("/etc/init.d/appfilter restart &");
+ um.value = translate("Update the feature file successfully, please refresh the page")
+ else
+ um.value = translate("Failed to update feature file, format error")
+ end
+ os.execute("rm /tmp/upload/* -fr");
+ end
+
+end)
+
+if luci.http.formvalue("upload") then
+ local f = luci.http.formvalue("ulfile")
+ if #f <= 0 then
+ -- um.value = translate("No specify upload file.")
+ end
+elseif luci.http.formvalue("download") then
+ Download()
+end
+return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua
new file mode 100755
index 0000000..7a10ee7
--- /dev/null
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua
@@ -0,0 +1,36 @@
+local ds = require "luci.dispatcher"
+local nxo = require "nixio"
+local nfs = require "nixio.fs"
+local ipc = require "luci.ip"
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local dsp = require "luci.dispatcher"
+local uci = require "luci.model.uci"
+local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
+local http = luci.http
+local SYS = require "luci.sys"
+local m, s
+
+m = Map("appfilter", translate(""), translate(""))
+
+s = m:section(TypedSection, "time", translate("Time Setting"))
+s.anonymous = true
+hv = s:option(Value, "start_time", translate("Start Time"))
+hv.default = "00:00"
+hv.optional = false
+hv = s:option(Value, "end_time", translate("End Time"))
+hv.default = "23:59"
+hv.optional = false
+days = s:option(MultiValue, "days", "", translate(""))
+days.widget = "checkbox"
+days.size = 10
+days:value("0", translate("Sun"));
+days:value("1", translate("Mon"));
+days:value("2", translate("Tue"));
+days:value("3", translate("Wed"));
+days:value("4", translate("Thur"));
+days:value("5", translate("Fri"));
+days:value("6", translate("Sat"));
+
+return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/user_list.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/user_list.lua
new file mode 100755
index 0000000..6a0366b
--- /dev/null
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/user_list.lua
@@ -0,0 +1,19 @@
+local ds = require "luci.dispatcher"
+local nxo = require "nixio"
+local nfs = require "nixio.fs"
+local ipc = require "luci.ip"
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local dsp = require "luci.dispatcher"
+local uci = require "luci.model.uci"
+local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
+local http = luci.http
+local SYS = require "luci.sys"
+local m, s
+
+m = Map("appfilter", translate(""), translate(""))
+
+m:section(SimpleSection).template = "admin_network/user_status"
+
+return m
diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/user_setting.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/user_setting.lua
new file mode 100755
index 0000000..f8a4aab
--- /dev/null
+++ b/luci-app-oaf/luasrc/model/cbi/appfilter/user_setting.lua
@@ -0,0 +1,91 @@
+local ds = require "luci.dispatcher"
+local nxo = require "nixio"
+local nfs = require "nixio.fs"
+local ipc = require "luci.ip"
+local sys = require "luci.sys"
+local utl = require "luci.util"
+local dsp = require "luci.dispatcher"
+local uci = require "luci.model.uci"
+local lng = require "luci.i18n"
+local jsc = require "luci.jsonc"
+local http = luci.http
+local SYS = require "luci.sys"
+local m, s
+
+m = Map("appfilter", translate("App Filter"), translate(""))
+
+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
+
+function get_cmd_result(command)
+ local fd
+ local result
+ fd = io.popen(command);
+ if not fd then
+ return ""
+ end
+ result = fd:read("*l");
+ fd:close()
+ return result
+end
+
+s = m:section(TypedSection, "user", translate("Select users"))
+s.anonymous = true
+users = s:option(MultiValue, "users", "", translate(
+ "It takes effect for all users by default, and only takes effect for the selected users when checked"))
+users.widget = "checkbox"
+-- users.widget="select"
+users.size = 1
+
+local fd = io.open("/tmp/dev_list", "r")
+if not fd then
+ return m
+end
+while true do
+ local line = fd:read("*l")
+ if not line then
+ break
+ end
+ if not string.match(line, "^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
+ if not hostname or hostname == "*" then
+ users:value(mac, mac);
+ else
+ users:value(mac, hostname .. "(" .. mac .. ")");
+ end
+ end
+ end
+end
+fd:close()
+
+local config_users = m.uci:get_all("appfilter.user.users")
+if config_users ~= nil and config_users ~= false then
+ local r = utl.split(config_users, "%s+", nil, true)
+ local max = table.getn(r)
+ for i = 1, max, 1 do
+ users:value(r[i], r[i]);
+ end
+end
+return m
diff --git a/luci-app-oaf/luasrc/view/admin_network/dev_status.htm b/luci-app-oaf/luasrc/view/admin_network/dev_status.htm
index 0835c10..0bb46ad 100755
--- a/luci-app-oaf/luasrc/view/admin_network/dev_status.htm
+++ b/luci-app-oaf/luasrc/view/admin_network/dev_status.htm
@@ -1,50 +1,52 @@
@@ -52,320 +54,329 @@ table.imagetable td {
<%:App Name%> | -<%:Hostname%> | -<%:Mac%> | -<%:Start Time%> | -<%:Visit Time%> | -<%:Filter Status%> | -||
---|---|---|---|---|---|---|---|
<%:Collecting data...%> |
-
+ <%:App Name%> + | ++ <%:Hostname%> + | ++ <%:Mac%> + | ++ <%:Start Time%> + | ++ <%:Visit Time%> + | ++ <%:Filter Status%> + | +||
---|---|---|---|---|---|---|---|
+ <%:Collecting data...%> + |
+
<%:Id%> | -<%:Hostname%> | -<%:Mac%> | -<%:Ip%> | -<%:Common App(TOP5)%> | -<%:Online Status%> | -||
---|---|---|---|---|---|---|---|
<%:Collecting data...%> |
-
+ <%:Id%> + | ++ <%:Hostname%> + | ++ <%:Mac%> + | ++ <%:Ip%> + | ++ <%:Common App(TOP5)%> + | ++ <%:Online Status%> + | +||
---|---|---|---|---|---|---|---|
+ <%:Collecting data...%> + |
+