diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/luci-app-oaf/Makefile b/luci-app-oaf/Makefile index 86747552..6dce8d62 100755 --- a/luci-app-oaf/Makefile +++ b/luci-app-oaf/Makefile @@ -7,9 +7,9 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=Open App Filter Module LUCI_PKGARCH:=all -LUCI_DEPENDS:=+appfilter +kmod-oaf +LUCI_DEPENDS:=+appfilter +kmod-oaf +luci-compat PKG_NAME:=luci-app-oaf -PKG_VERSION:=5.0 +PKG_VERSION:=5.0.2 PKG_RELEASE:=1 include $(TOPDIR)/feeds/luci/luci.mk # call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-oaf/luasrc/controller/appfilter.lua b/luci-app-oaf/luasrc/controller/appfilter.lua index 9f5b47a5..5f48d10c 100755 --- a/luci-app-oaf/luasrc/controller/appfilter.lua +++ b/luci-app-oaf/luasrc/controller/appfilter.lua @@ -10,24 +10,24 @@ function index() local page entry({"admin", "services", "appfilter"}, alias("admin", "services", "appfilter", "user_list"), - _("应用过滤"), 20).dependent = true + _("App Filter"), 20).dependent = 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 + _("User List"), 21).leaf=true entry({"admin", "services", "appfilter", "base_setting"}, - cbi("appfilter/base_setting"), _("基本设置"), 22).leaf=true + cbi("appfilter/base_setting"), _("Basic Settings"), 22).leaf=true entry({"admin", "services", "appfilter", "user_setting"}, - cbi("appfilter/user_setting"), _("生效用户"), 23).leaf=true + cbi("appfilter/user_setting"), _("Effective User"), 23).leaf=true entry({"admin", "services", "appfilter", "time_setting"}, - cbi("appfilter/time_setting"), _("生效时间"), 24).leaf=true + cbi("appfilter/time_setting"), _("Effective Time"), 24).leaf=true entry({"admin", "services", "appfilter", "feature"}, - cbi("appfilter/feature", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), _("特征库升级"), 25).leaf=true + cbi("appfilter/feature", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}), _("App Feature"), 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/base_setting.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua index 9458ec1e..86f45557 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/base_setting.lua @@ -13,36 +13,59 @@ local SYS = require "luci.sys" local m, s m = Map("appfilter", translate("App Filter"), translate( - "请先关闭所有加速(acc)、广告过滤、多拨等可能冲突的模块")) + "Please close the modules that may conflict, such as acceleration, ad filtering, and multi-dial")) s = m:section(TypedSection, "global", translate("Basic Settings")) s:option(Flag, "enable", translate("Enable App Filter"), translate("")) s.anonymous = true -o=s:option(ListValue, "work_mode", translate("工作模式"),translate("请正确选择模式,一般经过了WAN口转发则为主路由,建议切换模式后重启设备")) +o=s:option(ListValue, "work_mode", translate("Work Mode"),translate("")) o.default=0 -o:value(0,"主路由模式") -o:value(1,"旁路由模式") +o:value(0, translate("Gateway Mode")) +o:value(1,translate("Bypass Mode")) local rule_count = 0 local version = "" -s = m:section(TypedSection, "appfilter", translate("App Filter Rules")) +s = m:section(TypedSection, "appfilter", translate("App Filter Rules"), +translate("If there is no app you want, you can add the app by updating the app feature file")) s.anonymous = true s.addremove = false - +function get_class_i18n_name(class_name) + local fd = io.open("/tmp/app_class.txt", "r") + if not fd then return end + while true do + local ln = fd:read("*l") + if not ln then + break + end + local id, name1, name2 = ln:match("^(%d+) (%S+) (%S+)") + if class_name == name1 then + fd:close() + return name2 + end + end + fd:close() + return nil +end local class_fd = io.popen("find /tmp/appfilter/ -type f -name '*.class'") if class_fd then while true do local apps local class + local i18n_name local path = class_fd:read("*l") if not path then break end class = path:match("([^/]+)%.class$") - s:tab(class, translate(class)) + i18n_name=get_class_i18n_name(class) + if nil ~= i18n_name then + s:tab(class, i18n_name) + else + s:tab(class, class) + end apps = s:taboption(class, MultiValue, class .. "apps", translate("")) apps.rmempty = true apps.widget = "checkbox" diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua index 44b41111..275dec63 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/feature.lua @@ -13,19 +13,25 @@ local SYS = require "luci.sys" local m, s m = Map("appfilter", translate(""), - translate("特征库用于描述app特征,app过滤效果和个数依赖特征库")) + translate("The feature library is used to describe app features, app filtering effect and number-dependent feature library")) local rule_count = 0 local version = "" +local format = "" 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 +format=SYS.exec("uci get appfilter.feature.format") +if format == "" then + format="v2.0" +end -local display_str = "当前版本: " .. version .. "
特征码个数: " .. - rule_count .. - "
下载地址:https://destan19.github.io" -s = m:section(TypedSection, "feature", translate("Update feature"), display_str) +local display_str = ""..translate("Current version")..": " .. version .. + "
"..translate("Feature format")..": " ..format .. + "
"..translate("App number")..": " ..rule_count .. + "
"..translate("Feature download")..":www.openappfilter.com" +s = m:section(TypedSection, "feature", translate("App Feature"), display_str) fu = s:option(FileUpload, "") fu.template = "cbi/oaf_upload" @@ -38,6 +44,8 @@ local dir, fd dir = "/tmp/upload/" nixio.fs.mkdir(dir) http.setfilehandler(function(meta, chunk, eof) + local feature_file = "/etc/appfilter/feature.cfg" + local f_format="v1.0" if not fd then if not meta then return @@ -55,16 +63,25 @@ http.setfilehandler(function(meta, chunk, eof) if eof and fd then fd:close() local fd2 = io.open("/tmp/upload/" .. meta.file) - local line = fd2:read("*l"); + local version_line = fd2:read("*l"); + local format_line = fd2:read("*l"); fd2:close() - local ret = string.match(line, "#version") - local feature_file = "/etc/appfilter/feature.cfg" + local ret = string.match(version_line, "#version") if ret ~= nil then + if string.match(format_line, "#format") then + f_format = SYS.exec("echo '"..format_line.."'|awk '{print $2}'") + end + if not string.match(f_format, format) then + um.value = translate("Failed to update feature file, format error"..",feature format:"..f_format) + os.execute("rm /tmp/upload/* -fr"); + return + end 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 &"); + os.execute("uci set appfilter.feature.update=1"); + 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") diff --git a/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua b/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua index b950551e..52a8aa96 100755 --- a/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua +++ b/luci-app-oaf/luasrc/model/cbi/appfilter/time_setting.lua @@ -14,14 +14,14 @@ local m, s m = Map("appfilter", translate(""), translate("")) -s = m:section(TypedSection, "time", translate("Time Setting"),translate("时间2为选填,开始和结束时间需要同时设置,结束时间要大于开始时间")) +s = m:section(TypedSection, "time", translate("Time Setting"),translate("The second time is optional, the end time must be greater than the start time")) s.anonymous = true -o=s:option(ListValue, "time_mode", translate("时间匹配模式:"),translate("")) +o=s:option(ListValue, "time_mode", translate("Time Mode"),translate("")) o.default=0 -o:value(0,"时间范围内规则生效") -o:value(1,"时间范围外规则生效") +o:value(0,translate("Blacklist mode")) +o:value(1,translate("Whitelist mode")) days = s:option(MultiValue, "days", "", translate("")) days.widget = "checkbox" @@ -34,7 +34,7 @@ days:value("4", translate("Thur")); days:value("5", translate("Fri")); days:value("6", translate("Sat")); -hv = s:option(Value, "start_time", translate("Start Time1"),translate("格式xx:xx,下同")) +hv = s:option(Value, "start_time", translate("Start Time1"),translate("xx:xx")) hv.optional = false hv = s:option(Value, "end_time", translate("End Time1")) hv.optional = false diff --git a/luci-app-oaf/po/zh-cn/oaf.po b/luci-app-oaf/po/zh-cn/oaf.po index 53990b53..5a7e221b 100755 --- a/luci-app-oaf/po/zh-cn/oaf.po +++ b/luci-app-oaf/po/zh-cn/oaf.po @@ -164,4 +164,66 @@ msgstr "分" msgid "Enable App Filter" msgstr "开启应用过滤" +msgid "App Feature" +msgstr "应用特征库" +msgid "Effective User" +msgstr "生效用户" + +msgid "Effective Time" +msgstr "生效时间" + +msgid "Basic Settings" +msgstr "基本设置" + +msgid "Please close the modules that may conflict, such as acceleration, ad filtering, and multi-dial" +msgstr "请先关闭加速、广告过滤、多拨等可能冲突的模块" + + +msgid "Work Mode" +msgstr "工作模式" + +msgid "Gateway Mode" +msgstr "网关模式" + +msgid "Bypass Mode" +msgstr "旁路模式" + +msgid "Bypass Mode" +msgstr "旁路模式" + +msgid "Current version" +msgstr "当前版本" + +msgid "Current version" +msgstr "当前版本" + +msgid "App number" +msgstr "App个数" + +msgid "Feature download" +msgstr "特征库下载" + +msgid "The second time is optional, the end time must be greater than the start time" +msgstr "时间2为选填,结束时间要大于开始时间" + +msgid "Time Mode" +msgstr "时间匹配模式" + +msgid "Blacklist mode" +msgstr "黑名单模式" + +msgid "Whitelist mode" +msgstr "白名单模式" + +msgid "The feature library is used to describe app features, app filtering effect and number-dependent feature library" +msgstr "特征库用于描述app特征,app过滤效果和个数依赖特征库" + +msgid "User List" +msgstr "用户列表" + +msgid "If there is no app you want, you can add the app by updating the app feature file" +msgstr "如果没有你想要的APP,可以通过升级特征库增加APP" + +msgid "Feature format" +msgstr "特征码格式" \ No newline at end of file diff --git a/luci-app-oaf/po/zh_Hans/oaf.po b/luci-app-oaf/po/zh_Hans/oaf.po new file mode 100755 index 00000000..951e470f --- /dev/null +++ b/luci-app-oaf/po/zh_Hans/oaf.po @@ -0,0 +1,229 @@ + +msgid "website" +msgstr "常用网站" + +msgid "appfilter" +msgstr "应用过滤" + +msgid "App Filter" +msgstr "应用过滤" + +msgid "game" +msgstr "游戏" + +msgid "web" +msgstr "网页" + +msgid "video" +msgstr "视频" + +msgid "chat" +msgstr "聊天" + +msgid "download" +msgstr "下载" + +msgid "p2p" +msgstr "p2p" + +msgid "music" +msgstr "音乐" + +msgid "shopping" +msgstr "购物" + +msgid "working" +msgstr "办公" + +msgid "employee" +msgstr "招聘" + +msgid "Basic Settings" +msgstr "基本设置" + +msgid "App Filter Rules" +msgstr "应用过滤规则" + +msgid "It takes effect for all users by default, and only takes effect for the selected users when checked" +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 Time1" +msgstr "开始时间1" + +msgid "End Time1" +msgstr "结束时间1" + + +msgid "Start Time2" +msgstr "开始时间2" + +msgid "End Time2" +msgstr "结束时间2" + +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 "开启应用过滤" + +msgid "App Feature" +msgstr "应用特征库" + +msgid "Effective User" +msgstr "生效用户" + +msgid "Effective Time" +msgstr "生效时间" + +msgid "Basic Settings" +msgstr "基本设置" + +msgid "Please close the modules that may conflict, such as acceleration, ad filtering, and multi-dial" +msgstr "请先关闭加速、广告过滤、多拨等可能冲突的模块" + + +msgid "Work Mode" +msgstr "工作模式" + +msgid "Gateway Mode" +msgstr "网关模式" + +msgid "Bypass Mode" +msgstr "旁路模式" + +msgid "Bypass Mode" +msgstr "旁路模式" + +msgid "Current version" +msgstr "当前版本" + +msgid "Current version" +msgstr "当前版本" + +msgid "App number" +msgstr "App个数" + +msgid "Feature download" +msgstr "特征库下载" + +msgid "The second time is optional, the end time must be greater than the start time" +msgstr "时间2为选填,结束时间要大于开始时间" + +msgid "Time Mode" +msgstr "时间匹配模式" + +msgid "Blacklist mode" +msgstr "黑名单模式" + +msgid "Whitelist mode" +msgstr "白名单模式" + +msgid "The feature library is used to describe app features, app filtering effect and number-dependent feature library" +msgstr "特征库用于描述app特征,app过滤效果和个数依赖特征库" + +msgid "User List" +msgstr "用户列表" + +msgid "If there is no app you want, you can add the app by updating the app feature file" +msgstr "如果没有你想要的APP,可以通过升级特征库增加APP" + +msgid "Feature format" +msgstr "特征码格式" diff --git a/luci-app-oaf/root/etc/uci-defaults/93_feature_2.0 b/luci-app-oaf/root/etc/uci-defaults/93_feature_2.0 new file mode 100755 index 00000000..5bcaeda7 --- /dev/null +++ b/luci-app-oaf/root/etc/uci-defaults/93_feature_2.0 @@ -0,0 +1,7 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + set appfilter.feature.update='0' + set appfilter.feature.format='v2.0' + commit appfilter +EOF diff --git a/open-app-filter/Makefile b/open-app-filter/Makefile index 9d574bea..a431b42b 100755 --- a/open-app-filter/Makefile +++ b/open-app-filter/Makefile @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=appfilter -PKG_VERSION:=5.0 +PKG_VERSION:=5.0.2 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) @@ -47,7 +47,6 @@ define Package/appfilter/install $(INSTALL_DIR) $(1)/etc/appfilter $(INSTALL_DIR) $(1)/etc/config $(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.txt b/open-app-filter/files/app_class.txt deleted file mode 100755 index 8e2a09d6..00000000 --- a/open-app-filter/files/app_class.txt +++ /dev/null @@ -1,8 +0,0 @@ -1 聊天 -2 游戏 -3 视频 -4 购物 -5 音乐 -6 招聘 -7 下载 -8 常用网站 \ No newline at end of file diff --git a/open-app-filter/files/app_class_en.txt b/open-app-filter/files/app_class_en.txt deleted file mode 100755 index 0b89f4e4..00000000 --- a/open-app-filter/files/app_class_en.txt +++ /dev/null @@ -1,8 +0,0 @@ -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 e28cb390..f223e9cf 100755 --- a/open-app-filter/files/appfilter.config +++ b/open-app-filter/files/appfilter.config @@ -5,6 +5,8 @@ config global global config appfilter appfilter config feature feature + option update 0 + option format 'v2.0' config time 'time' option time_mode '0' diff --git a/open-app-filter/files/appfilter.init b/open-app-filter/files/appfilter.init index 0624a37c..61003cfd 100755 --- a/open-app-filter/files/appfilter.init +++ b/open-app-filter/files/appfilter.init @@ -18,23 +18,19 @@ stop_service(){ } start_service(){ - 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 + local update + #lang=`uci get luci.main.lang` + rm $FEATURE_FILE + update=`uci get appfilter.feature.update` + if [ x"1" == x"$update" ];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 + uci get luci.languages.zh_cn >/dev/null + if [ $? -eq 0 ];then + test -f $FEATURE_FILE && rm $FEATURE_FILE + ln -s /etc/appfilter/feature_cn.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 + ln -s /etc/appfilter/feature_en.cfg $FEATURE_FILE fi fi gen_class.sh /tmp/feature.cfg diff --git a/open-app-filter/files/feature.cfg b/open-app-filter/files/feature_cn.cfg similarity index 86% rename from open-app-filter/files/feature.cfg rename to open-app-filter/files/feature_cn.cfg index ab4c104c..a9c4ac57 100755 --- a/open-app-filter/files/feature.cfg +++ b/open-app-filter/files/feature_cn.cfg @@ -1,8 +1,7 @@ #version v22.3.24 +#format v2.0 #id name:[proto;sport;dport;host url;request;dict] -#class chat -1001 QQ:[tcp;;;;;00:02|-1:03,tcp;;;;;02:02|-1:03,tcp;;14000;;;,tcp;;8080;;;00:ca|01:3c,tcp;;;;;00:00|01:00|02:00|03:15] -1002 微信:[tcp;;;;;01:f1|02:03,tcp;;;;;00:ab|01:00|02:00,tcp;;80;;/mmtls;] +#class chat 1 聊天 1003 微博:[tcp;;443;weibo;;] 1004 陌陌:[tcp;;;momo;;,tcp;;;;;04:2f|05:66|06:65|07:65,tcp;;;;;00:03|01:03|02:00] 1005 支付宝:[tcp;;443;alipay.com;;] @@ -12,9 +11,10 @@ 1009 探探:[tcp;;;tancdn;;,tcp;;;tantanapp;;] 1010 多闪:[tcp;;;ppkankan;;] -#class game -2001 王者荣耀:[tcp;;;;;00:33|01:66|02:00|03:09,udp;;;;;00:01|01:02|02:00|03:00] -2003 英雄联盟:[udp;;;;;44:00|45:00|46:00|47:02] +#class game 2 游戏 +2001 王者荣耀:[tcp;;;;;00:33|1:66|02:00|03:0b] +2002 和平精英:[tcp;;17500;;;00:33|1:66|03:0a|05:0a] +2003 英雄联盟手游:[tcp;;;;;00:33|01:66|02:00|03:0b,tcp;;443;;;00:01|01:00|10:86|11:47] 2015 我的世界:[tcp;;443;g79mclobt.nie.netease;;] 2005 欢乐斗地主:[tcp;;8000;;;00:74|01:67|02:77|03:5f] 2006 梦幻西游:[tcp;;;;;00:0e|01:00|02:fe|03:ff] @@ -28,9 +28,28 @@ 2014 第五人格:[tcp;;4010;;;,tcp;;4010;;;,tcp;;4020;;;,tcp;;4030;;;,tcp;;4040;;;,tcp;;4050;;;,tcp;;4060;;;,tcp;;4070;;;,tcp;;4080;;;,tcp;;4090;;;] 2016 皇室战争:[udp;;9339;;;] 2017 炉石传说:[tcp;;3724;;;00:73:01:00:02:00] +2023 原神:[tcp;;443;yuanshen.com;;] +2025 天涯明月刀:[tcp;;10000;;;00:43|01:66|02:aa] +2026 微信小游戏:[tcp;;443;mmgame;;,tcp;;443;game.weixin.qq;;] +2033 我叫MT4:[tcp;;21248;;;,tcp;;;dir.mt4.qq.com;;] +2034 神都夜行录:[udp;;;;;00:00|01:00|02:00|03:00|04:56|05:40] +2041 光遇:[udp;;10000-15000;;;00:8f|01:ff,tcp;;;ma75.update.netease.com;;,tcp;;;ma75.proxima.nie.netease;;] +2042 保卫萝卜4:[tcp;;;s4.luobo.cn;;] +2040 哈利波特:[tcp;;10021-12000;;;00:02|01:00|02:00|03:00|04:00|05:00,tcp;;443;g92.proxima;;] +2067 9377游戏:[tcp;;;www.9377.com;;] +2068 4399游戏:[tcp;;;4399.com;;] +2069 7k7k游戏:[tcp;;;7k7k.com;;] +2070 17173游戏:[tcp;;;17173.com;;] +2071 37网游:[tcp;;;37.com;;] +2072 游民星空:[tcp;;;gamersky.com;;] +2073 游侠网:[tcp;;;ali213.net;;] +2074 hao123游戏:[tcp;;;game.hao123.com;;] +2075 51游戏:[tcp;;;www.51.com;;] +2050 uu加速器:[tcp;;;mg.uu.163.com;;] +2051 腾讯加速器:[tcp;;;m.acc.qq.com;;] +2080 乐逗游戏:[tcp;;;.uu.cc;;] - -#class video +#class video 3 视频 3001 抖音短视频:[tcp;;;-dy-;;,tcp;;;-dy.;;,tcp;;;douyin;;] 3002 火山小视频:[tcp;;;.huoshan.com;;,tcp;;;hs.pstatp.com;;,tcp;;;hs.ixigua.com;;] 3003 腾讯视频:[tcp;;443;v.qq.com;;,tcp;;443;video.qq.com;;,tcp;;443;btrace.qq.com;;] @@ -60,8 +79,7 @@ 3029 酷狗短酷:[tcp;;;bssdl.kugou;;] 3030 酷狗直播:[tcp;;;rt-m.kugou;;,tcp;;;kgimg.com;;] - -#class shopping +#class shopping 4 购物 4001 淘宝:[tcp;;;taobao;;,tcp;;;alicdn.com;;,tcp;;;tmall.com;;,tcp;;;;;00:d3|01:00,,tcp;;;;;00:d4|01:00,,tcp;;;;;00:d3|01:00] 4002 京东:[tcp;;;360buyimg;;,tcp;;;jd.com;;,tcp;;;jdcdn.com;;,tcp;;;;;00:d5|01:00] 4003 唯品会:[tcp;;;vips-mobile;;,tcp;;;vipshop;;,tcp;;;vip.com;;,tcp;;;vipstatic.com;;,tcp;;;appsimg.com;;] @@ -89,7 +107,7 @@ 4025 宜家家居:[tcp;;;ikea.cn;;] 4026 小象优品:[tcp;;;xiaoxiangyoupin;;] -#class music +#class music 5 音乐 5001 网易云音乐:[tcp;;;music.163;;,tcp;;;music.126;;] 5002 QQ音乐:[tcp;;;;^/amobile.music.tc.qq.com;,tcp;;;qqmusic;;] 5003 酷狗音乐:[tcp;;;kugou;;,tcp;;;kgimg;;,tcp;;;fanxing;;] @@ -103,7 +121,7 @@ 5011 音乐随心听:[tcp;;;fm.taihe.com;;] 5012 懒人听书:[tcp;;;lrts.me;;] -#class employee +#class employee 6 招聘 6001 前程无忧:[tcp;;;51job;;] 6002 智联招聘:[tcp;;;zhaopin;;] 6003 猎聘:[tcp;;;liepin;;] @@ -119,7 +137,7 @@ 6013 boss直聘:[tcp;;;zhipin.com;;] 6014 实习僧:[tcp;;;shixiseng.com;;] -#class download +#class download 7 下载 7001 迅雷:[udp;12345;;;;,udp;15000;;;;,tcp;;54321;;;,tcp;;12345;;;,udp;6881;;;;,udp;;12346;;;,udp;12346;;;;] 7002 AppStore:[tcp;;;itunes.apple.com;;] HIDE:0 7003 samba共享:[tcp;;445;;;] HIDE:0 @@ -137,7 +155,7 @@ 7032 阿里云盘:[tcp;;;aliyundrive;;] 7035 SSH:[tcp;;;;;00:53|01:53|02:48] -#class website +#class website 8 常用网站 8001 百度:[tcp;;;baidu.com;;] 8002 新浪:[tcp;;;sina.com;;] 8003 搜狐:[tcp;;;sohu.com;;] diff --git a/open-app-filter/files/feature_en.cfg b/open-app-filter/files/feature_en.cfg index ba4adf0f..35378746 100755 --- a/open-app-filter/files/feature_en.cfg +++ b/open-app-filter/files/feature_en.cfg @@ -1,27 +1,32 @@ -#version v21.9.1 +#version v22.11.11 +#format v2.0 #id name:[proto;sport;dport;host url;request;dict] -#class chat +#class chat 1 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;;] +1007 Snapchat:[tcp;;;snapchat.com;;] +1008 Tinder:[tcp;;;tinder.com;;] -#class video +#class video 3 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;;] +3002 Tiktok:[tcp;;;tiktok;;] +3003 NetFlix:[tcp;;;netflix;;] +3004 Vimeo:[tcp;;;vimeo;;] +3005 DailyMotion:[tcp;;;dailymotion;;] +3006 Hulu:[tcp;;;hulu;;] +3007 Vube:[tcp;;;vube;;] +3008 Twitch:[tcp;;;twitch;;] 3009 LiveLeak:[tcp;;;itemfix;;] -3010 Xvideos:[tcp;;;xvideos.com;;] -3011 Pornhub:[tcp;;;pornhub.com;;] +3010 Spotify:[tcp;;;spotify.com;;] +3050 Xvideos:[tcp;;;xvideos.com;;] +3051 Pornhub:[tcp;;;pornhub.com;;] +3052 Xnxx:[tcp;;;xnxx.com;;] -#class shopping +#class shopping 4 Shopping 4001 Amazon:[tcp;;;amazon.com;;] 4002 eBay:[tcp;;;ebay.com;;] 4003 Etsy:[tcp;;;etsy.com;;] @@ -35,17 +40,60 @@ 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 download 7 Download +7001 GooglePlay:[tcp;;;play.google.com;;] +7002 AppStore:[tcp;;;iosapps.itunes.apple.com;;] +7003 WindowsUpdate:[tcp;;80;update.microsoft.com;;,tcp;;;windowsupdate.com;;] +7050 Speedtest:[tcp;;;speedtest.net;;] +7060 samba:[tcp;;445;;;] +7061 ftp:[tcp;;21;;;] +7062 ssh:[tcp;;22;;;] -#class website +#class website 8 Website 8001 Google:[tcp;;;www.google.com;;] -8002 Wiki:[tcp;;;www.wikipedia.com;;] -8003 Yahoo:[tcp;;;www.yahoo.com;;] +8002 Wiki:[tcp;;;wikipedia.com;;] +8003 Yahoo:[tcp;;;yahoo;;] 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 +8010 Reddit:[tcp;;;reddit.com;;] +8011 Outlook:[tcp;;;outlook.live.com;;] +8012 Naver:[tcp;;;naver.com;;] +8013 Fandom:[tcp;;;fandom.com;;] +8015 Globo:[tcp;;;globo.com;;] +8016 Yelp:[tcp;;;yelp.com;;] +8017 Pinterest:[tcp;;;www.pinterest.com;;] +8018 BBC:[tcp;;;www.bbc.com;;] +8020 Linkedin:[tcp;;;linkedin.com;;] +8022 Merriam-webster:[tcp;;;merriam-webster.com;;] +8027 Dictionary:[tcp;;;dictionary.com;;] +8028 Tripadvisor:[tcp;;;tripadvisor.com;;] +8029 Britannica:[tcp;;;britannica.com;;] +8030 Cambridge:[tcp;;;cambridge.org;;] +8032 Weather:[tcp;;;weather.com;;] +8033 Wiktionary:[tcp;;;wiktionary.org;;] +8034 Espn:[tcp;;;espn.com;;] +8035 Microsoft:[tcp;;;microsoft.com;;] +8038 Gsmarena:[tcp;;;gsmarena.com;;] +8039 Webmd:[tcp;;;webmd.com;;] +8040 Craigslist:[tcp;;;craigslist.org;;] +8041 Cricbuzz:[tcp;;;cricbuzz.com;;] +8042 Mayoclinic:[tcp;;;mayoclinic.org;;] +8043 Timeanddate:[tcp;;;timeanddate.com;;] +8044 Espncricinfo:[tcp;;;espncricinfo.com;;] +8045 Healthline:[tcp;;;healthline.com;;] +8047 Rottentomatoes:[tcp;;;rottentomatoes.com;;] +8049 Thefreedictionary:[tcp;;;thefreedictionary.com;;] +8052 Bestbuy:[tcp;;;bestbuy.com;;] +8053 Indeed:[tcp;;;indeed.com;;] +8058 Samsung:[tcp;;;samsung.com;;] +8059 Investopedia:[tcp;;;investopedia.com;;] +8060 Flashscore:[tcp;;;flashscore.com;;] +8061 Steampowered:[tcp;;;steampowered.com;;] +8064 Roblox:[tcp;;;roblox.com;;] +8065 Nordstrom:[tcp;;;nordstrom.com;;] +8066 Thepiratebay:[tcp;;;thepiratebay.org;;] +8067 Indiatimes:[tcp;;;indiatimes.com;;] +8068 Cnbc:[tcp;;;cnbc.com;;] +8069 Ssyoutube:[tcp;;;ssyoutube.com;;] +8070 Adobe:[tcp;;;adobe.com;;] +8071 Speedtest:[tcp;;;speedtest.net;;] +8072 Lowes:[tcp;;;lowes.com;;] diff --git a/open-app-filter/files/gen_class.sh b/open-app-filter/files/gen_class.sh index 80350ca0..b173fcb5 100755 --- a/open-app-filter/files/gen_class.sh +++ b/open-app-filter/files/gen_class.sh @@ -1,11 +1,13 @@ #!/bin/sh - +CLASS_NAME_FILE="/tmp/app_class.txt" f_file=$1 -test -z "$f_file" && return -test -d /tmp/appfilter && return cur_class="" cur_class_file="" +test -z "$f_file" && return +test -d /tmp/appfilter && rm /tmp/appfilter -fr + mkdir /tmp/appfilter +rm $CLASS_NAME_FILE while read line do echo "$line"| grep "^#class" @@ -18,13 +20,13 @@ do rm $cur_class_file fi touch $cur_class_file + echo $line | awk '{print $3 " " $2 " "$4}' >>$CLASS_NAME_FILE fi + continue fi test -z "$cur_class" && continue appid=`echo "$line" |awk '{print $1}'` appname=`echo "$line" | awk '{print $2}' | awk -F: '{print $1}'` - + echo "appid = $appid, appname=$appname" echo "$appid $appname" >> $cur_class_file done < $f_file -echo "ok" - diff --git a/open-app-filter/src/appfilter_config.c b/open-app-filter/src/appfilter_config.c index 05369025..5c464c90 100755 --- a/open-app-filter/src/appfilter_config.c +++ b/open-app-filter/src/appfilter_config.c @@ -195,7 +195,8 @@ void init_app_class_name_table(void) } while (fgets(line_buf, sizeof(line_buf), fp)) { - sscanf(line_buf, "%d %s", &class_id, class_name); + sscanf(line_buf, "%d %*s %s", &class_id, class_name); + printf("line buf = %s, class_name = %s\n", line_buf, class_name); strcpy(CLASS_NAME_TABLE[class_id - 1], class_name); g_cur_class_num++; } diff --git a/open-app-filter/src/appfilter_netlink.c b/open-app-filter/src/appfilter_netlink.c index 33a2442f..9f7f6a5d 100755 --- a/open-app-filter/src/appfilter_netlink.c +++ b/open-app-filter/src/appfilter_netlink.c @@ -47,7 +47,6 @@ void appfilter_nl_handler(struct uloop_fd *u, unsigned int ev) int type; int id; char *mac = NULL; - printf("%s %d\n", __func__, __LINE__); struct msghdr msg = { .msg_name = &nladdr, @@ -92,7 +91,6 @@ void appfilter_nl_handler(struct uloop_fd *u, unsigned int ev) printf("parse json failed:%s", kdata); return; } - printf("recv msg = %s\n", kdata); struct json_object *mac_obj = json_object_object_get(root, "mac"); @@ -158,8 +156,6 @@ void appfilter_nl_handler(struct uloop_fd *u, unsigned int ev) } else { - printf("%s %d\n", __func__, __LINE__); - visit_info_t *visit_node = (visit_info_t *)calloc(1, sizeof(visit_info_t)); visit_node->action = action; visit_node->appid = appid; @@ -167,8 +163,6 @@ void appfilter_nl_handler(struct uloop_fd *u, unsigned int ev) visit_node->first_time = cur_time.tv_sec - MIN_VISIT_TIME; visit_node->next = NULL; add_visit_info_node(&node->visit_htable[hash], visit_node); - - //printf("add visit info curtime=%d\n", cur_time.tv_sec); } } @@ -183,8 +177,6 @@ int send_msg_to_kernel(int fd, void *msg, int len) daddr.nl_family = AF_NETLINK; daddr.nl_pid = 0; // to kernel daddr.nl_groups = 0; - printf("%s %d\n", __func__, __LINE__); - int ret = 0; struct nlmsghdr *nlh = NULL; nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_NL_MSG_LEN)); @@ -201,8 +193,6 @@ int send_msg_to_kernel(int fd, void *msg, int len) char *p_data = msg_buf + sizeof(struct af_msg_hdr); memcpy(p_data, msg, len); - // memset(nlh, 0, sizeof(struct nlmsghdr)); - memcpy(NLMSG_DATA(nlh), msg_buf, len + sizeof(struct af_msg_hdr)); ret = sendto(fd, nlh, nlh->nlmsg_len, 0, (struct sockaddr *)&daddr, sizeof(struct sockaddr_nl)); @@ -211,7 +201,6 @@ int send_msg_to_kernel(int fd, void *msg, int len) perror("sendto error\n"); return -1; } - printf("%s %d\n", __func__, __LINE__); return 0; }