From 31f72a7bf23e30f6f3e0964d3d1d428e87fce949 Mon Sep 17 00:00:00 2001 From: Hu Shuai Date: Wed, 4 Aug 2021 10:16:10 +0800 Subject: [PATCH 01/16] fix a issue on 21.02 --- .../luasrc/model/cbi/appfilter/appfilter.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua index 33da977..fc982b3 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua @@ -184,12 +184,12 @@ end fd:close() local config_users=m.uci:get_all("appfilter.user.users") -if config_users~=nil 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 +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 From a0b0c561ae31f569a5dda8bad97ab542ec8b5dd0 Mon Sep 17 00:00:00 2001 From: Derry Date: Fri, 20 Aug 2021 15:30:50 +0800 Subject: [PATCH 02/16] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 8fb4cc0..fa7ec86 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ https://destan19.github.io/ OpenAppFilter基于数据流深度识别技术,可以实现游戏、视频、直播等app过滤和审计。 +### 演示视频 + +![](https://gitee.com/destan19/picture/raw/master/picgo/douyin-qrcode.jpg) ## 编译说明 1. 下载OpenWrt源码,并完成编译 @@ -23,6 +26,10 @@ cd - 1. 应用过滤与加速模块、广告过滤、mwan等涉及到nf_conntrack mark的模块有冲突,需要关闭冲突模块才能生效。 2. 应用过滤包含了内核模块,内核版本号和宏配置都会影响插件安装,建议直接编译进固件。 3. 如果你的固件集成了应用过滤插件,并进行二次发布,请备注应用过滤仓库地址,谢谢! +4. 旁路模式不生效,需要将路由器做主路由,保证通过应用过滤设备进行nat转发。 + +## 固件发布 +关注OpenWrt微信公众号 ## 技术交流QQ群 (2000人) 943396288 From ddd7f1633be7b08e9836a0056d486b97a392e2f1 Mon Sep 17 00:00:00 2001 From: Derry Date: Mon, 30 Aug 2021 11:37:26 +0800 Subject: [PATCH 03/16] Update README.md --- README.md | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index fa7ec86..299cc20 100755 --- a/README.md +++ b/README.md @@ -1,36 +1,6 @@ +你要的项目在这里! -### 插件和特征库发布地址 +仅仅提供了一个私有版本定制,也注明了是作者本人,有时候我在想开源的目的是啥? +是为了引来喷子吗? -https://destan19.github.io/ -### OpenAppFilter功能简介 - -OpenAppFilter基于数据流深度识别技术,可以实现游戏、视频、直播等app过滤和审计。 - -### 演示视频 - -![](https://gitee.com/destan19/picture/raw/master/picgo/douyin-qrcode.jpg) - -## 编译说明 -1. 下载OpenWrt源码,并完成编译 -> git clone https://github.com/coolsnowwolf/lede.git -> 或 https://github.com/openwrt/openwrt.git (18.06) -2. 下载应用过滤源码放到OpenWrt的package 目录 -> cd package -git clone https://github.com/destan19/OpenAppFilter.git -cd - -3. make menuconfig, 在luci app中选上luci oaf app模块并保存 -4. make V=s 编译出带应用过滤功能的OpenWrt固件 -也可以将源码路径加入到feeds配置中 - -## 使用说明 -1. 应用过滤与加速模块、广告过滤、mwan等涉及到nf_conntrack mark的模块有冲突,需要关闭冲突模块才能生效。 -2. 应用过滤包含了内核模块,内核版本号和宏配置都会影响插件安装,建议直接编译进固件。 -3. 如果你的固件集成了应用过滤插件,并进行二次发布,请备注应用过滤仓库地址,谢谢! -4. 旁路模式不生效,需要将路由器做主路由,保证通过应用过滤设备进行nat转发。 - -## 固件发布 -关注OpenWrt微信公众号 - -## 技术交流QQ群 (2000人) -943396288 -点击链接加入群聊【OpenWrt交流群(OAF)】:https://jq.qq.com/?_wv=1027&k=YQaeDqTY +![](https://gitee.com/destan19/picture/raw/master/picgo/IMG_2325.PNG.JPG) From efabd13dd7cd8b3b53fcb49da7b6a8af9ab0e5eb Mon Sep 17 00:00:00 2001 From: Derry Date: Tue, 31 Aug 2021 09:55:48 +0800 Subject: [PATCH 04/16] Update README.md --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 299cc20..cddbdad 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,18 @@ -你要的项目在这里! -仅仅提供了一个私有版本定制,也注明了是作者本人,有时候我在想开源的目的是啥? -是为了引来喷子吗? +应用过滤是一款基于OpenWrt的家长管理插件,支持游戏、视频、聊天、下载等app过滤 +### 如何编译应用过滤固件 +1. 准备OpenWrt源码,并编译成功 + 推荐源码仓库: + https://github.com/coolsnowwolf/lede.git + 如果用官方源码,不要用master分支,因为luci版本不兼容,推荐18.06版本。 +2. clone应用过滤源码到OpenWrt源码package目录 +git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter +3. make menuconfig 开启应用过滤插件宏 + 在OpenWrt源码目录执行make menuconfig,进入luci app菜单选择luci-app-oaf保存 +4. 编译生成固件 + make V=s +### 使用说明 +1. 将应用过滤设备做主路由 +2. 关闭软硬加速、广告过滤、QOS、多WAN等涉及到nf_conn mark的模块 +3. 开启应用过滤并选择需要过滤的app即可生效 -![](https://gitee.com/destan19/picture/raw/master/picgo/IMG_2325.PNG.JPG) From 1f32d64accd36792235adc6e528e9cca688de654 Mon Sep 17 00:00:00 2001 From: Derry Date: Tue, 31 Aug 2021 09:56:37 +0800 Subject: [PATCH 05/16] Update README.md --- README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index cddbdad..2f9ad94 100755 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -应用过滤是一款基于OpenWrt的家长管理插件,支持游戏、视频、聊天、下载等app过滤 +应用过滤是一款基于OpenWrt的家长管理插件,支持游戏、视频、聊天、下载等app过滤 ### 如何编译应用过滤固件 -1. 准备OpenWrt源码,并编译成功 - 推荐源码仓库: - https://github.com/coolsnowwolf/lede.git - 如果用官方源码,不要用master分支,因为luci版本不兼容,推荐18.06版本。 -2. clone应用过滤源码到OpenWrt源码package目录 -git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter -3. make menuconfig 开启应用过滤插件宏 - 在OpenWrt源码目录执行make menuconfig,进入luci app菜单选择luci-app-oaf保存 -4. 编译生成固件 - make V=s +1. 准备OpenWrt源码,并编译成功 + 推荐源码仓库: + https://github.com/coolsnowwolf/lede.git + 如果用官方源码,不要用master分支,因为luci版本不兼容,推荐18.06版本。 +2. clone应用过滤源码到OpenWrt源码package目录 +git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter +3. make menuconfig 开启应用过滤插件宏 + 在OpenWrt源码目录执行make menuconfig,进入luci app菜单选择luci-app-oaf保存 +4. 编译生成固件 + make V=s ### 使用说明 -1. 将应用过滤设备做主路由 -2. 关闭软硬加速、广告过滤、QOS、多WAN等涉及到nf_conn mark的模块 -3. 开启应用过滤并选择需要过滤的app即可生效 +1. 将应用过滤设备做主路由 +2. 关闭软硬加速、广告过滤、QOS、多WAN等涉及到nf_conn mark的模块 +3. 开启应用过滤并选择需要过滤的app即可生效 From d073dd9c0ed563f5f55c18625325925057f681ca Mon Sep 17 00:00:00 2001 From: Derry Date: Tue, 31 Aug 2021 09:59:54 +0800 Subject: [PATCH 06/16] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2f9ad94..7721fb0 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,23 @@ +App filtering is a parent management plug-in based on OpenWrt, which supports app filtering for games, videos, chats, downloads, etc. +### How to compile application filtering firmware +1. Prepare OpenWrt source code and compile successfully + Recommended source code repository: + https://github.com/coolsnowwolf/lede.git + If you use the official source code, do not use the master branch, because the luci version is not compatible, version 18.06 is recommended. +2. Clone the application filtering source code to the OpenWrt source code package directory +git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter +3. make menuconfig to open the application filter plug-in macro + Execute make menuconfig in the OpenWrt source code directory, enter the luci app menu and select luci-app-oaf to save +4. Compile and generate firmware + make V=s +### Instructions for use +1. Make the application filtering device the main route +2. Turn off software and hardware acceleration, advertising filtering, QOS, multi-WAN and other modules related to nf_conn mark +3. Turn on application filtering and select the app that needs to be filtered to take effect + + + 应用过滤是一款基于OpenWrt的家长管理插件,支持游戏、视频、聊天、下载等app过滤 ### 如何编译应用过滤固件 1. 准备OpenWrt源码,并编译成功 From 04b701357c271a1bf97afa5dbfbfd02f4861aa25 Mon Sep 17 00:00:00 2001 From: derry Date: Tue, 31 Aug 2021 20:26:17 +0800 Subject: [PATCH 07/16] 1.Support i18n 2.add English feature file,support filtering youtube,facebook,etc. --- luci-app-oaf/luasrc/controller/appfilter.lua | 7 +- .../luasrc/model/cbi/appfilter/appfilter.lua | 73 ++++----- .../luasrc/model/cbi/appfilter/dev_status.lua | 2 +- .../luasrc/view/admin_network/dev_status.htm | 50 +++--- .../luasrc/view/admin_network/user_status.htm | 20 +-- luci-app-oaf/luasrc/view/cbi/oaf_upload.htm | 2 +- luci-app-oaf/po/zh-cn/oaf.po | 149 +++++++++++++++--- oaf/src/app_filter.h | 4 +- open-app-filter/Makefile | 4 +- open-app-filter/files/app_class_en.txt | 8 + open-app-filter/files/appfilter.config | 1 + open-app-filter/files/appfilter.init | 24 ++- open-app-filter/files/appfilter.lua | 0 open-app-filter/files/feature_en.cfg | 51 ++++++ open-app-filter/files/oaf_rule | 10 +- open-app-filter/src/appfilter_config.c | 4 +- 16 files changed, 288 insertions(+), 121 deletions(-) create mode 100755 open-app-filter/files/app_class_en.txt mode change 100644 => 100755 open-app-filter/files/appfilter.lua create mode 100755 open-app-filter/files/feature_en.cfg diff --git a/luci-app-oaf/luasrc/controller/appfilter.lua b/luci-app-oaf/luasrc/controller/appfilter.lua index 93daabb..383682f 100755 --- a/luci-app-oaf/luasrc/controller/appfilter.lua +++ b/luci-app-oaf/luasrc/controller/appfilter.lua @@ -8,14 +8,11 @@ function index() end local page - --hide save button - page = entry({"admin", "network", "appfilter"}, arcombine(cbi("appfilter/appfilter"), cbi("appfilter/dev_status", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true})), _("appfilter"), 100) + page = entry({"admin", "network", "appfilter"}, arcombine(cbi("appfilter/appfilter"), cbi("appfilter/dev_status", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true})), _("App Filter"), 100) page.leaf = true page.subindex = true - --page.dependent = true - page = entry({"admin", "network", "user_status"}, call("user_status"), nil) page.leaf = true @@ -114,8 +111,6 @@ function user_status() hostname=get_hostname_by_mac(user_array[i].mac), appid=visit_array[j].appid, appname=get_app_name_by_id(visit_array[j].appid), - --total_num=visit_array[j].total_num, - --drop_num=visit_array[j].drop_num, total_num=0, drop_num=0, latest_action=visit_array[j].latest_action, diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua index fc982b3..470decf 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/appfilter.lua @@ -14,56 +14,43 @@ local SYS = require "luci.sys" local m, s m = Map("appfilter", - translate("appfilter"), + translate("App Filter"), translate("")) s = m:section(TypedSection, "global", translate("Basic Settings")) s:option(Flag, "enable", translate("Enable App Filter"),translate("")) -um = s:option(DummyValue, "") -um.template="cbi/oaf_dvalue" -local fullcone=SYS.exec("uci get firewall.@defaults[0].fullcone"); -local bbr=SYS.exec("uci get flowoffload.@flow[0].bbr"); -local flow_offloading=SYS.exec("uci get flowoffload.@flow[0].flow_offloading"); -if string.match(fullcone, "1") or string.match(bbr, "1") or string.match(flow_offloading, "1") then - um.value="运行环境检测失败,请先关闭ACC加速模块!" -end s.anonymous = true local rule_count=0 local version="" -if nixio.fs.access("/etc/appfilter/feature.cfg") then - rule_count=tonumber(SYS.exec("cat /etc/appfilter/feature.cfg | wc -l")) - version=SYS.exec("cat /etc/appfilter/feature.cfg |grep \"#version\" | awk '{print $2}'") +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("特征库更新"), display_str ) + + +local display_str=""..translate("Current Version")..": "..version.."
"..translate("App Feature Num")..": "..rule_count +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" -s=m:section(TypedSection,"time",translate("时间控制")) s.anonymous = true -hv = s:option(Value, "start_time", translate("开始时间")) hv.default="00:00" +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("结束时间")) hv.default="23:59" +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", "周日"); -days:value("1", "周一"); -days:value("2", "周二"); -days:value("3", "周三"); -days:value("4", "周四"); -days:value("5", "周五"); -days:value("6", "周六"); - ---um.value =rule_count .. " " .. translate("Records").. " "..version - - - - +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 @@ -80,13 +67,9 @@ if class_fd then end class = path:match("([^/]+)%.class$") - -- add a tab s:tab(class, translate(class)) - -- multi value option apps = s:taboption(class, MultiValue, class.."apps", translate("")) apps.rmempty=true - --apps.delimiter=";" - -- select apps.widget="checkbox" apps.size=10 @@ -121,9 +104,6 @@ if class_fd then class_fd:close() end - - - function get_hostname_by_mac(dst_mac) leasefile="/tmp/dhcp.leases" local fd = io.open(leasefile, "r") @@ -143,6 +123,7 @@ function get_hostname_by_mac(dst_mac) fd:close() return nil end + function get_cmd_result(command) local fd local result @@ -213,14 +194,22 @@ http.setfilehandler( 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.." /etc/appfilter/feature.cfg"; + 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("更新成功,请刷新页面!") + um.value = translate("Update the feature file successfully, please refresh the page") else - um.value = translate("更新失败,格式错误!") + um.value = translate("Failed to update feature file, format error") end os.execute("rm /tmp/upload/* -fr"); end @@ -236,6 +225,4 @@ if luci.http.formvalue("upload") then elseif luci.http.formvalue("download") then Download() 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 55d3440..09133b0 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/dev_status.lua @@ -13,7 +13,7 @@ local jsc = require "luci.jsonc" local m, s arg[1] = arg[1] or "" m = Map("appfilter", - translate("上网统计("..arg[1]..")"), + translate("Data Statistics").."("..arg[1]..")", translate("")) local v 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 89a8448..58cf16e 100755 --- a/luci-app-oaf/luasrc/view/admin_network/dev_status.htm +++ b/luci-app-oaf/luasrc/view/admin_network/dev_status.htm @@ -51,11 +51,11 @@ table.imagetable td { var total_time_str; if (hour > 0) - total_time_str=hour + "小时" + min + "分" + total_time_str=hour + "<%:h%>" + min + "<%:m%>" else{ if (min == 0 && seconds2 != 0) min = 1; - total_time_str=min + "分" + total_time_str=min + "<%:m%>" } return total_time_str; } @@ -82,7 +82,7 @@ table.imagetable td { option = { title: [ { - text: 'APP时间统计', + text: "<%:App Time Statistics%>", textStyle: { fontSize: 16, color: "black" @@ -110,8 +110,8 @@ table.imagetable td { var total_time = get_display_time(parms.data.value); var str= parms.seriesName+"
"+ parms.marker+""+parms.data.legendname+"
"+ - "时间:"+ total_time+"
"+ - "占比:"+ parms.percent+"%"; + "<%:Visit Time%>: "+ total_time+"
"+ + "<%:Percentage%>: "+ parms.percent+"%"; return str ; } }, @@ -128,11 +128,11 @@ table.imagetable td { }, series: [ { - name: "访问时间", + name: "<%:Visit Time%>", type:'pie', center: ['35%', '50%'], radius: ['40%', '65%'], - clockwise: false, //饼图的扇区是否是顺时针排布 + clockwise: false, avoidLabelOverlap: false, label: { normal: { @@ -164,8 +164,6 @@ table.imagetable td { var m2R2Data=new Array() var total_time=0 for(var i = 0; i < data.length; i++){ - console.log("begin display222."); - var dev_obj = data[i]; if (dev_obj.visit_time == 0) continue; @@ -186,7 +184,7 @@ table.imagetable td { option = { title: [ { - text: 'APP分类时间统计', + text: "<%:App classification time statistics%>", textStyle: { fontSize: 16, color: "black" @@ -213,9 +211,8 @@ table.imagetable td { formatter:function (parms){ var total_time = get_display_time(parms.data.value); var str= parms.seriesName+"
"+ - parms.marker+""+parms.data.legendname+"
"+ - "时间:"+ total_time +"
"+ - "占比:"+ parms.percent+"%"; + parms.marker+""+parms.data.legendname+"
"+"<%:Visit Time%>: "+ total_time +"
" + + "<%:Percentage%>: "+ parms.percent+"%"; return str ; } }, @@ -232,11 +229,11 @@ table.imagetable td { }, series: [ { - name:'访问时间', + name:"<%:Visit Time%>", type:'pie', center: ['35%', '50%'], radius: ['40%', '65%'], - clockwise: false, //饼图的扇区是否是顺时针排布 + clockwise: false, avoidLabelOverlap: false, label: { normal: { @@ -289,12 +286,12 @@ table.imagetable td { { var action_status="" if(st[i].latest_action == 1) - action_status="已过滤" + action_status="<%:Filtered%>" else - action_status="未过滤" + action_status="<%:Unfiltered%>" var hostname="" if(st[i].hostname == "" || st[i].hostname == "*"){ - hostname="?"; + hostname="--"; } else{ hostname=st[i].hostname; @@ -313,11 +310,11 @@ table.imagetable td { total_time_str="-" else { if (hour > 0) - total_time_str=hour + "小时" + min + "分" + total_time_str=hour + "<%:h%>" + min + "<%:m%>" else{ if (min == 0) min = 1; - total_time_str=min + "分" + total_time_str=min + "<%:m%>" } } @@ -331,6 +328,7 @@ table.imagetable td { //]]> +
@@ -338,12 +336,12 @@ table.imagetable td {
- - - - - - + + + + + + diff --git a/luci-app-oaf/luasrc/view/admin_network/user_status.htm b/luci-app-oaf/luasrc/view/admin_network/user_status.htm index 0f5b99e..1fb1ebd 100755 --- a/luci-app-oaf/luasrc/view/admin_network/user_status.htm +++ b/luci-app-oaf/luasrc/view/admin_network/user_status.htm @@ -42,7 +42,7 @@ table.imagetable td { { var hostname="" if(devlist[i].hostname == "" || devlist[i].hostname == "*"){ - hostname="?"; + hostname="--"; } else{ hostname=devlist[i].hostname; @@ -65,9 +65,9 @@ table.imagetable td { } tr.insertCell(-1).innerHTML = app_list_str; if (devlist[i].online == 1) - tr.insertCell(-1).innerHTML = "在线"; + tr.insertCell(-1).innerHTML = "<%:Online%>"; else - tr.insertCell(-1).innerHTML = "离线"; + tr.insertCell(-1).innerHTML = "<%:Offline%>"; } } } @@ -77,15 +77,15 @@ table.imagetable td {
- <%:终端列表%> + <%:Client List%>
<%:App%><%:主机名%><%:mac地址%><%:开始时间%><%:访问时长%><%:过滤状态%><%:App Name%><%:Hostname%><%:Mac%><%:Start Time%><%:Visit Time%><%:Filter Status%>

<%:Collecting data...%>
- - - - - - + + + + + + diff --git a/luci-app-oaf/luasrc/view/cbi/oaf_upload.htm b/luci-app-oaf/luasrc/view/cbi/oaf_upload.htm index 0fe8150..aadf01d 100755 --- a/luci-app-oaf/luasrc/view/cbi/oaf_upload.htm +++ b/luci-app-oaf/luasrc/view/cbi/oaf_upload.htm @@ -1,5 +1,5 @@ <%+cbi/valueheader%> - + <%+cbi/valuefooter%> diff --git a/luci-app-oaf/po/zh-cn/oaf.po b/luci-app-oaf/po/zh-cn/oaf.po index 3717faa..33b824d 100755 --- a/luci-app-oaf/po/zh-cn/oaf.po +++ b/luci-app-oaf/po/zh-cn/oaf.po @@ -5,31 +5,34 @@ msgstr "常用网站" msgid "appfilter" msgstr "应用过滤" +msgid "App Filter" +msgstr "应用过滤" + msgid "game" msgstr "游戏" -msgid "web" +msgid "web" msgstr "网页" - -msgid "video" -msgstr "视频" - -msgid "chat" -msgstr "聊天" - -msgid "download" -msgstr "下载" - -msgid "p2p" -msgstr "p2p" - -msgid "music" -msgstr "音乐" - -msgid "shopping" -msgstr "购物" - -msgid "working" + +msgid "video" +msgstr "视频" + +msgid "chat" +msgstr "聊天" + +msgid "download" +msgstr "下载" + +msgid "p2p" +msgstr "p2p" + +msgid "music" +msgstr "音乐" + +msgid "shopping" +msgstr "购物" + +msgid "working" msgstr "办公" msgid "employee" @@ -47,6 +50,110 @@ msgstr "至少选择一个用户,否则对所有用户生效" msgid "Select users" msgstr "选择用户" +msgid "Id" +msgstr "编号" + +msgid "Hostname" +msgstr "主机名" + +msgid "Common App(TOP5)" +msgstr "常用APP(TOP5)" + +msgid "Online Status" +msgstr "在线状态" + +msgid "Client List" +msgstr "终端列表" + +msgid "Online" +msgstr "在线" + +msgid "Offline" +msgstr "离线" + +msgid "App Time Statistics" +msgstr "App 时间统计" + +msgid "Filter Status" +msgstr "过滤状态" + +msgid "Data Statistics" +msgstr "数据统计" + + + +msgid "Current Version" +msgstr "当前版本" + +msgid "App Feature Num" +msgstr "特征码个数" + +msgid "Update feature" +msgstr "特征库更新" + +msgid "Time Setting" +msgstr "时间控制" + +msgid "Sun" +msgstr "周日" + +msgid "Mon" +msgstr "周一" + +msgid "Tue" +msgstr "周二" + +msgid "Wed" +msgstr "周三" + +msgid "Thur" +msgstr "周四" + +msgid "Fri" +msgstr "周五" + +msgid "Sat" +msgstr "周六" + +msgid "Update the feature file successfully, please refresh the page" +msgstr "更新特征库成功,请刷新页面!" + +msgid "Failed to update feature file, format error" +msgstr "更新特征库失败,格式错误!" + +msgid "Select feature file:" +msgstr "选择本地特征库文件:" + +msgid "Start Time" +msgstr "开始时间" + +msgid "End Time" +msgstr "结束时间" + +msgid "App Name" +msgstr "App名称" + +msgid "Visit Time" +msgstr "访问时间" + +msgid "App classification time statistics" +msgstr "App分类时间统计" + +msgid "Percentage" +msgstr "占比" + +msgid "Filtered" +msgstr "已过滤" + +msgid "Unfiltered" +msgstr "未过滤" + +msgid "h" +msgstr "小时" + +msgid "m" +msgstr "分" + msgid "Enable App Filter" msgstr "开启应用过滤" diff --git a/oaf/src/app_filter.h b/oaf/src/app_filter.h index e5c15de..4312c01 100755 --- a/oaf/src/app_filter.h +++ b/oaf/src/app_filter.h @@ -2,7 +2,7 @@ #define APP_FILTER_H #define AF_VERSION "5.0.1" -#define AF_FEATURE_CONFIG_FILE "/etc/appfilter/feature.cfg" +#define AF_FEATURE_CONFIG_FILE "/tmp/feature.cfg" #define MAX_PARSE_PKT_NUM 16 #define MIN_HTTP_DATA_LEN 16 @@ -92,7 +92,7 @@ typedef struct https_proto{ }https_proto_t; typedef struct flow_info{ - struct nf_conn *ct; // Ӹָ + struct nf_conn *ct; // ���Ӹ���ָ�� u_int32_t src; u_int32_t dst; int l4_protocol; diff --git a/open-app-filter/Makefile b/open-app-filter/Makefile index a52d9d0..9d574be 100755 --- a/open-app-filter/Makefile +++ b/open-app-filter/Makefile @@ -46,8 +46,8 @@ define Package/appfilter/install $(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/appfilter $(INSTALL_DIR) $(1)/etc/config - $(CP) ./files/feature.cfg $(1)/etc/appfilter/ - $(CP) ./files/app_class.txt $(1)/etc/appfilter/ + $(CP) ./files/*.cfg $(1)/etc/appfilter/ + $(CP) ./files/*.txt $(1)/etc/appfilter/ $(INSTALL_BIN) ./files/appfilter.init $(1)/etc/init.d/appfilter $(INSTALL_BIN) ./files/oaf_rule $(1)/usr/bin $(INSTALL_BIN) ./files/gen_class.sh $(1)/usr/bin diff --git a/open-app-filter/files/app_class_en.txt b/open-app-filter/files/app_class_en.txt new file mode 100755 index 0000000..0b89f4e --- /dev/null +++ b/open-app-filter/files/app_class_en.txt @@ -0,0 +1,8 @@ +1 chat +2 game +3 video +4 shopping +5 music +6 recruitment +7 download +8 website \ No newline at end of file diff --git a/open-app-filter/files/appfilter.config b/open-app-filter/files/appfilter.config index 8253a74..636c069 100755 --- a/open-app-filter/files/appfilter.config +++ b/open-app-filter/files/appfilter.config @@ -8,3 +8,4 @@ config time 'time' option end_time '23:59' option days '0 1 2 3 4 5 6' option start_time '00:00' +config user user \ No newline at end of file diff --git a/open-app-filter/files/appfilter.init b/open-app-filter/files/appfilter.init index b4e97a3..0624a37 100755 --- a/open-app-filter/files/appfilter.init +++ b/open-app-filter/files/appfilter.init @@ -5,7 +5,8 @@ START=96 USE_PROCD=1 OAFD_BIN="/usr/bin/oafd" - +FEATURE_FILE="/tmp/feature.cfg" +CLASS_FILE="/tmp/app_class.txt" service_triggers() { procd_add_reload_trigger "appfilter" @@ -17,7 +18,26 @@ stop_service(){ } start_service(){ - gen_class.sh /etc/appfilter/feature.cfg + lang=`uci get luci.main.lang` + test -f $FEATURE_FILE && rm $FEATURE_FILE + test -f $CLASS_FILE && rm $CLASS_FILE + if [ x"" == x"$lang" -o x"auto" == x"$lang" ];then + ln -s /etc/appfilter/feature.cfg $FEATURE_FILE + ln -s /etc/appfilter/app_class.txt $CLASS_FILE + else + if [ -f "/etc/appfilter/feature_$lang.cfg" ];then + ln -s /etc/appfilter/feature_$lang.cfg $FEATURE_FILE + else + ln -s /etc/appfilter/feature.cfg $FEATURE_FILE + fi + + if [ -f "/etc/appfilter/app_class_$lang.txt" ];then + ln -s /etc/appfilter/app_class_$lang.txt $CLASS_FILE + else + ln -s /etc/appfilter/app_class.txt $CLASS_FILE + fi + fi + gen_class.sh /tmp/feature.cfg insmod oaf /usr/bin/oaf_rule reload procd_open_instance diff --git a/open-app-filter/files/appfilter.lua b/open-app-filter/files/appfilter.lua old mode 100644 new mode 100755 diff --git a/open-app-filter/files/feature_en.cfg b/open-app-filter/files/feature_en.cfg new file mode 100755 index 0000000..ba4adf0 --- /dev/null +++ b/open-app-filter/files/feature_en.cfg @@ -0,0 +1,51 @@ +#version v21.9.1 +#id name:[proto;sport;dport;host url;request;dict] +#class chat +1001 Facebook:[tcp;;;facebook.com;;] +1002 Whatsapp:[tcp;;;whatsapp;;] +1003 Twitter:[tcp;;;twitter.com;;] +1004 Instagram:[tcp;;;instagram.com;;] +1005 VK:[tcp;;;vk.com;;] +1006 Line:[tcp;;;line;;] + +#class video +3001 YouTube:[tcp;;;youtube;;] +3002 NetFlix:[tcp;;;netflix;;] +3003 Vimeo:[tcp;;;vimeo;;] +3004 DailyMotion:[tcp;;;dailymotion;;] +3005 Hulu:[tcp;;;hulu;;] +3006 Vube:[tcp;;;vube;;] +3007 Twitch:[tcp;;;twitch;;] +3008 LiveLeak:[tcp;;;itemfix;;] +3009 LiveLeak:[tcp;;;itemfix;;] +3010 Xvideos:[tcp;;;xvideos.com;;] +3011 Pornhub:[tcp;;;pornhub.com;;] + +#class shopping +4001 Amazon:[tcp;;;amazon.com;;] +4002 eBay:[tcp;;;ebay.com;;] +4003 Etsy:[tcp;;;etsy.com;;] +4004 Wish:[tcp;;;wish.com;;] +4005 Alibaba:[tcp;;;alibaba;;] +4006 Aliexpress:[tcp;;;aliexpress.com;;] +4007 Walmart:[tcp;;;walmart.com;;] +4008 Sears:[tcp;;;sears.com;;] +4009 Kohls:[tcp;;;kohls.com;;] +4010 Costco:[tcp;;;costco.com;;] +4011 Asos:[tcp;;;asos.com;;] +4012 Cuyana:[tcp;;;cuyana.com;;] + +#class download +7001 Google Play:[tcp;;;play.google.com;;] +7002 AppStore:[tcp;;80;iosapps.itunes.apple.com;;] + +#class website +8001 Google:[tcp;;;www.google.com;;] +8002 Wiki:[tcp;;;www.wikipedia.com;;] +8003 Yahoo:[tcp;;;www.yahoo.com;;] +8004 Apple:[tcp;;;www.apple.com;;] +8010 Reddit:[tcp;;;www.reddit.com;;] +8011 Outlook:[tcp;;;www.outlook.live.com;;] +8012 Naver:[tcp;;;www.naver.com;;] +8013 Fandom:[tcp;;;www.fandom.com;;] +8015 Globo:[tcp;;;www.globo.com;;] \ No newline at end of file diff --git a/open-app-filter/files/oaf_rule b/open-app-filter/files/oaf_rule index a9ac5ea..4756e68 100755 --- a/open-app-filter/files/oaf_rule +++ b/open-app-filter/files/oaf_rule @@ -59,12 +59,12 @@ load_mac_list() 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: + config_get mac_list "user" "users" + echo "mac list=$mac_list" + for mac in $mac_list: do - echo "appid=$appid" - json_add_string "" $appid + echo "mac=$mac" + json_add_string "" $mac done json_str=`json_dump` config_apply "$json_str" diff --git a/open-app-filter/src/appfilter_config.c b/open-app-filter/src/appfilter_config.c index 8b16104..e0edade 100755 --- a/open-app-filter/src/appfilter_config.c +++ b/open-app-filter/src/appfilter_config.c @@ -76,7 +76,7 @@ void init_app_name_table(void) int count = 0; char line_buf[2048] = {0}; - FILE *fp = fopen("/etc/appfilter/feature.cfg", "r"); + FILE *fp = fopen("/tmp/feature.cfg", "r"); if (!fp) { printf("open file failed\n"); @@ -110,7 +110,7 @@ void init_app_class_name_table(void) char line_buf[2048] = {0}; int class_id; char class_name[64] = {0}; - FILE *fp = fopen("/etc/appfilter/app_class.txt", "r"); + FILE *fp = fopen("/tmp/app_class.txt", "r"); if (!fp) { printf("open file failed\n"); From 4c6a73a1632ba1b8bbbde13576f58c629906b253 Mon Sep 17 00:00:00 2001 From: Derry Date: Thu, 16 Sep 2021 14:21:51 +0800 Subject: [PATCH 08/16] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7721fb0..465717b 100755 --- a/README.md +++ b/README.md @@ -35,3 +35,6 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter 2. 关闭软硬加速、广告过滤、QOS、多WAN等涉及到nf_conn mark的模块 3. 开启应用过滤并选择需要过滤的app即可生效 +### OpenWrt应用过滤交流群 +群号: 943396288 +点击链接加入群聊【OpenWrt交流群(OAF)】:https://jq.qq.com/?_wv=1027&k=TqQ6VvtV From 951e6d1527df8614f7adcbb296145bf0037eb8e2 Mon Sep 17 00:00:00 2001 From: Derry Date: Fri, 8 Oct 2021 15:09:44 +0800 Subject: [PATCH 09/16] Update README.md --- README.md | 47 ++++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 465717b..50d63df 100755 --- a/README.md +++ b/README.md @@ -1,22 +1,4 @@ -App filtering is a parent management plug-in based on OpenWrt, which supports app filtering for games, videos, chats, downloads, etc. -### How to compile application filtering firmware -1. Prepare OpenWrt source code and compile successfully - Recommended source code repository: - https://github.com/coolsnowwolf/lede.git - If you use the official source code, do not use the master branch, because the luci version is not compatible, version 18.06 is recommended. -2. Clone the application filtering source code to the OpenWrt source code package directory -git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter -3. make menuconfig to open the application filter plug-in macro - Execute make menuconfig in the OpenWrt source code directory, enter the luci app menu and select luci-app-oaf to save -4. Compile and generate firmware - make V=s -### Instructions for use -1. Make the application filtering device the main route -2. Turn off software and hardware acceleration, advertising filtering, QOS, multi-WAN and other modules related to nf_conn mark -3. Turn on application filtering and select the app that needs to be filtered to take effect - - 应用过滤是一款基于OpenWrt的家长管理插件,支持游戏、视频、聊天、下载等app过滤 ### 如何编译应用过滤固件 @@ -35,6 +17,33 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter 2. 关闭软硬加速、广告过滤、QOS、多WAN等涉及到nf_conn mark的模块 3. 开启应用过滤并选择需要过滤的app即可生效 +### 如何自定义特征码 +https://zhuanlan.zhihu.com/p/419053529 + +### 演示视频 +https://www.bilibili.com/video/BV11z4y1z7tQ/ +抖音:Linux开发者-Derry + ### OpenWrt应用过滤交流群 群号: 943396288 -点击链接加入群聊【OpenWrt交流群(OAF)】:https://jq.qq.com/?_wv=1027&k=TqQ6VvtV +点击链接加入群聊【OpenWrt交流群(OAF)】: +https://jq.qq.com/?_wv=1027&k=TqQ6VvtV + + +App filtering is a parent management plug-in based on OpenWrt, which supports app filtering for games, videos, chats, downloads, etc. +### How to compile application filtering firmware +1. Prepare OpenWrt source code and compile successfully + Recommended source code repository: + https://github.com/coolsnowwolf/lede.git + If you use the official source code, do not use the master branch, because the luci version is not compatible, version 18.06 is recommended. +2. Clone the application filtering source code to the OpenWrt source code package directory +git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter +3. make menuconfig to open the application filter plug-in macro + Execute make menuconfig in the OpenWrt source code directory, enter the luci app menu and select luci-app-oaf to save +4. Compile and generate firmware + make V=s +### Instructions for use +1. Make the application filtering device the main route +2. Turn off software and hardware acceleration, advertising filtering, QOS, multi-WAN and other modules related to nf_conn mark +3. Turn on application filtering and select the app that needs to be filtered to take effect + From c5149e08a8355d6047e8b59ea4ad7c114c7fd286 Mon Sep 17 00:00:00 2001 From: Derry Date: Fri, 8 Oct 2021 15:10:28 +0800 Subject: [PATCH 10/16] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 50d63df..e690305 100755 --- a/README.md +++ b/README.md @@ -21,15 +21,16 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter https://zhuanlan.zhihu.com/p/419053529 ### 演示视频 -https://www.bilibili.com/video/BV11z4y1z7tQ/ -抖音:Linux开发者-Derry +https://www.bilibili.com/video/BV11z4y1z7tQ/ +抖音:Linux开发者-Derry ### OpenWrt应用过滤交流群 群号: 943396288 -点击链接加入群聊【OpenWrt交流群(OAF)】: +点击链接加入群聊【OpenWrt交流群(OAF)】: https://jq.qq.com/?_wv=1027&k=TqQ6VvtV + App filtering is a parent management plug-in based on OpenWrt, which supports app filtering for games, videos, chats, downloads, etc. ### How to compile application filtering firmware 1. Prepare OpenWrt source code and compile successfully From ca6cda41918e893f8a52e85b55502836a483a21d Mon Sep 17 00:00:00 2001 From: derry Date: Fri, 8 Oct 2021 16:30:03 +0800 Subject: [PATCH 11/16] Fix some bug --- open-app-filter/files/oaf_rule | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/open-app-filter/files/oaf_rule b/open-app-filter/files/oaf_rule index 4756e68..74872f5 100755 --- a/open-app-filter/files/oaf_rule +++ b/open-app-filter/files/oaf_rule @@ -37,7 +37,6 @@ load_rule() do class_name=`echo "$file" | awk -F/ '{print $4}'| awk -F. '{print $1}'` config_get appid_list "appfilter" "${class_name}apps" - echo "appid_list=$appid_list" if ! test -z "$appid_list";then for appid in $appid_list: @@ -59,24 +58,24 @@ load_mac_list() json_add_int "op" 4 json_add_object "data" json_add_array "mac_list" - config_get mac_list "user" "users" - echo "mac list=$mac_list" - for mac in $mac_list: - do - echo "mac=$mac" - json_add_string "" $mac - done + config_get mac_list "user" "users" + echo "mac list=$mac_list" + if [ x"$mac_list" != x"" ];then + for mac in $mac_list: + do + json_add_string "" $mac + done + fi json_str=`json_dump` config_apply "$json_str" - echo "json str=$json_str" json_cleanup } reload_rule(){ - config_load appfilter - clean_rule - load_rule - load_mac_list + config_load appfilter + clean_rule + load_rule + load_mac_list } From da556e35ae2ffdf3cfaee2df42fbed47ecbc6127 Mon Sep 17 00:00:00 2001 From: Derry Date: Fri, 8 Oct 2021 16:34:52 +0800 Subject: [PATCH 12/16] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e690305..a20f1dc 100755 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter ### 如何自定义特征码 https://zhuanlan.zhihu.com/p/419053529 +### 固件和特征库下载地址 +https://destan19.github.io +如果访问不了,可以切换4G网络或者运营商,部分网络屏蔽了github.io + ### 演示视频 https://www.bilibili.com/video/BV11z4y1z7tQ/ 抖音:Linux开发者-Derry From 82a7cac6ebdcedaf069b623293ce8d61f51a778d Mon Sep 17 00:00:00 2001 From: Derry Date: Fri, 8 Oct 2021 16:35:11 +0800 Subject: [PATCH 13/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a20f1dc..2b64b1a 100755 --- a/README.md +++ b/README.md @@ -21,8 +21,8 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter https://zhuanlan.zhihu.com/p/419053529 ### 固件和特征库下载地址 -https://destan19.github.io -如果访问不了,可以切换4G网络或者运营商,部分网络屏蔽了github.io +https://destan19.github.io +如果访问不了,可以切换4G网络或者运营商,部分网络屏蔽了github.io ### 演示视频 https://www.bilibili.com/video/BV11z4y1z7tQ/ From 89dea47c50950862c39f061a101f1635865793ed Mon Sep 17 00:00:00 2001 From: Derry Date: Sun, 10 Oct 2021 12:43:16 +0800 Subject: [PATCH 14/16] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b64b1a..97f3c79 100755 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ https://zhuanlan.zhihu.com/p/419053529 https://destan19.github.io 如果访问不了,可以切换4G网络或者运营商,部分网络屏蔽了github.io -### 演示视频 -https://www.bilibili.com/video/BV11z4y1z7tQ/ +### 演示视频 +https://www.bilibili.com/video/BV1ZL41137aT/ 抖音:Linux开发者-Derry ### OpenWrt应用过滤交流群 From ab59a94c4a71ad79d0320c9ad04c171972231e0d Mon Sep 17 00:00:00 2001 From: Derry Date: Tue, 9 Nov 2021 17:36:24 +0800 Subject: [PATCH 15/16] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 97f3c79..093e82a 100755 --- a/README.md +++ b/README.md @@ -18,15 +18,15 @@ git clone https://github.com/destan19/OpenAppFilter.git package/OpenAppFilter 3. 开启应用过滤并选择需要过滤的app即可生效 ### 如何自定义特征码 -https://zhuanlan.zhihu.com/p/419053529 +https://zhuanlan.zhihu.com/p/419053529 ### 固件和特征库下载地址 -https://destan19.github.io +https://destan19.github.io 如果访问不了,可以切换4G网络或者运营商,部分网络屏蔽了github.io ### 演示视频 https://www.bilibili.com/video/BV1ZL41137aT/ -抖音:Linux开发者-Derry + ### OpenWrt应用过滤交流群 群号: 943396288 From f03aab2927f6c21d983b430648fb51ee91afedab Mon Sep 17 00:00:00 2001 From: Derry Date: Tue, 9 Nov 2021 17:37:57 +0800 Subject: [PATCH 16/16] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 093e82a..fba1bba 100755 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ https://destan19.github.io ### 演示视频 https://www.bilibili.com/video/BV1ZL41137aT/ +### 6.0以上版本ipk安装 +1. 通过以下源码编译固件 +https://github.com/destan19/openfros +2. 在release中下载ipk文件直接安装 ### OpenWrt应用过滤交流群 群号: 943396288
<%:编号%><%:主机名%><%:mac地址%><%:ip地址%><%:常用APP(TOP5)%><%:在线状态%><%:Id%><%:Hostname%><%:Mac%><%:Ip%><%:Common App(TOP5)%><%:Online Status%>

<%:Collecting data...%>