update 2022-11-29 23:39:07

This commit is contained in:
github-actions[bot] 2022-11-29 23:39:08 +08:00
parent 8a729b23ba
commit c4a06a3469
9 changed files with 11 additions and 380 deletions

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=aliyundrive-webdav
PKG_VERSION:=1.10.3
PKG_VERSION:=1.10.4
PKG_RELEASE:=$(AUTORELEASE)
PKG_LICENSE:=MIT

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-aliyundrive-webdav
PKG_VERSION:=1.10.3
PKG_VERSION:=1.10.4
PKG_RELEASE:=1
PKG_PO_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)

View File

@ -1204,10 +1204,8 @@ int netlink_oaf_init(void)
static int __init app_filter_init(void)
{
printk("appfilter version:" AF_VERSION "\n");
if (0 != load_feature_config())
{
printk("load feature failed\n");
return -1;
}

View File

@ -6,10 +6,7 @@ PKG_VERSION:=5.0.2
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
#include $(INCLUDE_DIR)/kernel.mk
define Package/appfilter
SECTION:=Derry Apps
@ -42,7 +39,6 @@ endef
define Package/appfilter/install
echo "install"
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/appfilter
$(INSTALL_DIR) $(1)/etc/config

View File

@ -19,13 +19,12 @@ stop_service(){
start_service(){
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
else
uci get luci.languages.zh_cn >/dev/null
uci get luci.languages.zh_cn >/dev/null 2>&1
if [ $? -eq 0 ];then
test -f $FEATURE_FILE && rm $FEATURE_FILE
ln -s /etc/appfilter/feature_cn.cfg $FEATURE_FILE

View File

@ -1,262 +0,0 @@
#!/usr/bin/lua
local libubus = require "ubus"
local uloop = require "uloop"
local UBUS_STATUS_OK = 0
local UBUS_STATUS_INVALID_COMMAND = 1
local UBUS_STATUS_INVALID_ARGUMENT = 2
local UBUS_STATUS_METHOD_NOT_FOUND = 3
local UBUS_STATUS_NOT_FOUND = 4
local UBUS_STATUS_NO_DATA = 5
local UBUS_STATUS_PERMISSION_DENIED = 6
local UBUS_STATUS_TIMEOUT = 7
local UBUS_STATUS_NOT_SUPPORTED = 8
local UBUS_STATUS_UNKNOWN_ERROR = 9
local UBUS_STATUS_CONNECTION_FAILED = 10
local UBUS_STATUS_ALREADY_EXISTS = 11
local cfg_file = "/etc/appfilter/feature.cfg"
local cfg = {}
local class = {}
local ubus
cfg.__index = cfg
class.__index = class
function cfg:init(file)
local f = io.open(file, "r")
local t = {}
local t2 = {}
if f then
for line in f:lines() do
table.insert(t, line)
local tt = line:match("#class (%S+)")
if tt then
table.insert(t2, tt)
end
end
setmetatable(t, self)
setmetatable(t2, self)
return t,t2
end
return nil
end
function cfg:lookup(o)
if not o then return UBUS_STATUS_INVALID_ARGUMENT end
local tab = self
for _, v in ipairs(tab) do
if v:match(o) then
if v:match("#class") then
local tt = {}
local t2 = {}
local found
for _, t in ipairs(tab) do
repeat
if t:match(o) then
found = true
table.insert(tt, t)
break
end
if t:match("#class") then
found = false
table.insert(t2, t)
break
end
if found then
table.insert(tt, t)
else
table.insert(t2, t)
end
until true
end
setmetatable(tt, self)
setmetatable(t2, self)
return tt, t2
else
return v
end
end
end
return nil
end
function cfg:lookup_class(m)
if not m then return UBUS_STATUS_INVALID_ARGUMENT end
local t1, t2 = self:lookup(m)
if type(t1) ~= "table" then return nil end
return t1, t2
end
function cfg:add_class(m)
if not m then return UBUS_STATUS_INVALID_ARGUMENT end
local f = io.open(cfg_file, "r+")
local tab = self
if f then
io.output(f)
for _, v in ipairs(tab) do
io.write(v)
io.write("\n")
end
io.write("#class "..m)
f:flush()
f:close()
return UBUS_STATUS_OK
else
return UBUS_STATUS_NOT_FOUND
end
end
function cfg:add_app(m, name, proto, sport, dport, url, request, dict)
if not name then return UBUS_STATUS_INVALID_ARGUMENT end
local id
local offset
local f = io.open(cfg_file, "r+")
io.output(f)
local t1,t2 = self:lookup_class(m)
if t1[#t1] == nil or "" then
offset = 0
id = math.modf(string.match(t1[#t1-1], "(%d+) %S+:") +1)
else
offset = 1
id = math.modf(string.match(t1[#t1], "(%d+) %S+:") +1)
end
local str = string.format("%d %s:[%s;%s;%s;%s;%s;%s]", id, name, proto, sport or "", dport or "", url or "", request or "", dict or "")
table.insert(t1, #t1+offset, str)
if f then
for _, v in ipairs(t2) do
if v then
io.write(v)
io.write("\n")
end
end
for _, v in ipairs(t1) do
if v then
io.write(v)
io.write("\n")
end
end
f:flush()
f:close()
end
return id
end
function cfg:del_app(id, name)
local t = self
local f = io.open(cfg_file, "r+")
local ret
if id then
for i, v in ipairs(t) do
if v:match(id) then
table.remove(t, i)
ret = i
end
end
end
if name then
for i, v in ipairs(t) do
if v:match(name) then
table.remove(t, i)
ret = i
end
end
end
if f then
io.output(f)
for _, v in ipairs(t) do
io.write(v)
io.write("\n")
end
f:flush()
f:close()
end
return ret
end
local methods = {
["appfilter"] = {
add_class = {
function(req, msg)
if not msg.class then return UBUS_STATUS_INVALID_ARGUMENT end
local t = cfg:init(cfg_file)
local ret
if t:lookup_class(msg.class) then return ubus.reply(req, {ret = UBUS_STATUS_ALREADY_EXISTS}) end
ret = t:add_class(msg.class)
ubus.reply(req, {msg = ret})
end, {class = libubus.STRING}
},
add_app = {
function (req, msg)
if not msg.class then return UBUS_STATUS_INVALID_ARGUMENT end
if not msg.name then return UBUS_STATUS_INVALID_ARGUMENT end
if not msg.proto then return UBUS_STATUS_INVALID_ARGUMENT end
local t = cfg:init(cfg_file)
local ret
if t:lookup(msg.name) then return ubus.reply(req, {ret = UBUS_STATUS_ALREADY_EXISTS}) end
ret = t:add_app(msg.class, msg.name, msg.proto, msg.sport, msg.dport, msg.url, msg.request, msg.dict)
ubus.reply(req, {ret = ret})
end,{class = libubus.STRING, name = libubus.STRING, proto = libubus.STRING, sport = libubus.INT32, dport = libubus.INT32, url = libubus.STRING, request = libubus.STRING, dict = libubus.STRING}
},
del_app = {
function(req, msg)
local t = cfg:init(cfg_file)
local ret = t:del_app(msg.id, msg.name)
ubus.reply(req, {ret = ret})
end,{id = libubus.INT32, name = libubus.STRING}
},
list_class = {
function (req, msg)
local _, c = cfg:init(cfg_file)
ubus.reply(req, {result = c})
end,{}
},
list_app = {
function (req, msg)
if not msg.class then return UBUS_STATUS_INVALID_ARGUMENT end
local t = cfg:init(cfg_file)
local ret = {}
for i, v in ipairs(t:lookup_class(msg.class)) do
if not v:match("#class") then
local id, name = v:match("(%d+) (%S+):%[")
ret[i-1] = {id = id, name = name}
end
end
ubus.reply(req, {result = ret})
end,{class = libubus.STRING}
}
}
}
function ubus_init()
local conn = libubus.connect()
if not conn then
error("Failed to connect to ubus")
end
conn:add(methods)
return {
call = function(object, method, params)
return conn:call(object, method, params or {})
end,
reply = function(req, msg)
conn:reply(req, msg)
end
}
end
local function main()
uloop.init()
ubus = ubus_init()
uloop.run()
end
main()

View File

@ -1,88 +0,0 @@
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
config_apply()
{
test -z "$1" && return 1
if [ -e "/dev/appfilter" ];then
echo "config json str=$1"
echo "$1" >/dev/appfilter
fi
}
clean_rule()
{
json_init
echo "clean appfilter rule..."
json_add_int "op" 3
json_add_object "data"
json_str=`json_dump`
config_apply "$json_str"
json_cleanup
}
load_rule()
{
json_init
config_load appfilter
config_get enable "global" enable
echo "enable = $enable"
if [ x"$enable" != x"1" ];then
echo "appfilter is disabled"
echo 0 >/proc/sys/oaf/enable>/dev/null
return 0
else
insmod oaf >/dev/null
echo 1 >/proc/sys/oaf/enable
fi
echo "appfilter is enabled"
json_add_int "op" 1
json_add_object "data"
json_add_array "apps"
for file in `ls /tmp/appfilter/*.class`
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:
do
json_add_int "" $appid
done
fi
done
json_str=`json_dump`
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

View File

@ -27,6 +27,5 @@ do
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

View File

@ -5,9 +5,7 @@
config_apply()
{
test -z "$1" && return 1
if [ -e "/dev/appfilter" ];then
echo "config json str=$1"
echo "$1" >/dev/appfilter
fi
}
@ -15,14 +13,10 @@ config_apply()
clean_rule()
{
json_init
echo "clean appfilter rule..."
json_add_int "op" 3
json_add_object "data"
json_str=`json_dump`
config_apply "$json_str"
json_cleanup
}
@ -32,18 +26,17 @@ load_rule()
json_add_int "op" 1
json_add_object "data"
json_add_array "apps"
for file in `ls /tmp/appfilter/*.class`
do
class_name=`echo "$file" | awk -F/ '{print $4}'| awk -F. '{print $1}'`
config_get appid_list "appfilter" "${class_name}apps"
class_name=`echo "$file" | awk -F/ '{print $4}'| awk -F. '{print $1}'`
config_get appid_list "appfilter" "${class_name}apps"
if ! test -z "$appid_list";then
for appid in $appid_list:
do
json_add_int "" $appid
done
fi
if ! test -z "$appid_list";then
for appid in $appid_list:
do
json_add_int "" $appid
done
fi
done
json_str=`json_dump`
@ -59,7 +52,6 @@ load_mac_list()
json_add_object "data"
json_add_array "mac_list"
config_get mac_list "user" "users"
echo "mac list=$mac_list"
if [ x"$mac_list" != x"" ];then
for mac in $mac_list:
do
@ -79,16 +71,13 @@ reload_rule(){
}
reload_base_config(){
local old_work_mode
config_load appfilter
config_get work_mode "global" "work_mode"
echo "work mode=$work_mode"
echo "$work_mode" >/proc/sys/oaf/work_mode
}
case $1 in
"reload")
echo "reload appfilter rule..."
reload_base_config
reload_rule
;;