OpenAppFilter: sync with upstream source
This commit is contained in:
parent
140c472163
commit
a9246e89b6
@ -24,10 +24,8 @@ function get_hostname_by_mac(dst_mac)
|
||||
break
|
||||
end
|
||||
local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
|
||||
print(ln)
|
||||
if dst_mac == mac then
|
||||
print("match mac", mac, "hostname=", name);
|
||||
fd:close()
|
||||
fd:close()
|
||||
return name
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,16 +1,3 @@
|
||||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
local ds = require "luci.dispatcher"
|
||||
|
||||
@ -81,6 +68,57 @@ if class_fd then
|
||||
end
|
||||
class_fd:close()
|
||||
end
|
||||
|
||||
|
||||
s=m:section(TypedSection,"user",translate("Select users"))
|
||||
s.anonymous = true
|
||||
users = s:option(MultiValue, "users", "", translate("Select at least one user, otherwise it will take effect for all users"))
|
||||
users.widget="checkbox"
|
||||
|
||||
function get_hostname_by_mac(dst_mac)
|
||||
leasefile="/tmp/dhcp.leases"
|
||||
local fd = io.open(leasefile, "r")
|
||||
if not fd then return end
|
||||
while true do
|
||||
local ln = fd:read("*l")
|
||||
if not ln then
|
||||
break
|
||||
end
|
||||
local ts, mac, ip, name, duid = ln:match("^(%d+) (%S+) (%S+) (%S+) (%S+)")
|
||||
print(ln)
|
||||
if dst_mac == mac then
|
||||
fd:close()
|
||||
return name
|
||||
end
|
||||
end
|
||||
fd:close()
|
||||
return nil
|
||||
end
|
||||
|
||||
users.widget="checkbox"
|
||||
--users.widget="select"
|
||||
users.size=1
|
||||
|
||||
local fd = io.open("/proc/net/arp", "r")
|
||||
if not fd then return end
|
||||
while true do
|
||||
local line = fd:read("*l")
|
||||
if not line then
|
||||
break
|
||||
end
|
||||
if not line:match("Ip*") then
|
||||
local ip, hw_type, flags, mac, mask, device = line:match("(%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+) %s+ (%S+)")
|
||||
if device:match("lan") then
|
||||
local hostname=get_hostname_by_mac(mac)
|
||||
if not hostname then
|
||||
users:value(mac, mac);
|
||||
else
|
||||
users:value(mac, hostname);
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
m:section(SimpleSection).template = "admin_network/user_status"
|
||||
|
||||
|
||||
|
||||
@ -1,99 +1,53 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Last-Translator: Automatically generated\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh_Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua:28
|
||||
msgid "App Filter Rules"
|
||||
msgstr "应用过滤规则"
|
||||
msgid "website"
|
||||
msgstr "常用网站"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:75
|
||||
msgid "App名称"
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua:23
|
||||
msgid "Basic Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:82
|
||||
msgid "Collecting data..."
|
||||
msgstr ""
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua:24
|
||||
msgid "Enable App Filter"
|
||||
msgstr "开启应用过滤"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/controller/appfilter.lua:10
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/model/cbi/appfilter/appfilter.lua:20
|
||||
msgid "appfilter"
|
||||
msgstr "应用过滤"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:74
|
||||
msgid "ip地址"
|
||||
msgstr ""
|
||||
msgid "game"
|
||||
msgstr "游戏"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:73
|
||||
msgid "mac地址"
|
||||
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 "办公"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:76
|
||||
msgid "丢包次数"
|
||||
msgstr ""
|
||||
msgid "employee"
|
||||
msgstr "招聘"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:72
|
||||
msgid "主机名"
|
||||
msgstr ""
|
||||
msgid "Basic Settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:78
|
||||
msgid "最后访问时间"
|
||||
msgstr ""
|
||||
msgid "App Filter Rules"
|
||||
msgstr "应用过滤规则"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:77
|
||||
msgid "访问次数"
|
||||
msgstr ""
|
||||
msgid "Select at least one user, otherwise it will take effect for all users"
|
||||
msgstr "至少选择一个用户,否则对所有用户生效"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:69
|
||||
msgid "访问记录"
|
||||
msgstr ""
|
||||
msgid "Select users"
|
||||
msgstr "选择用户"
|
||||
|
||||
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-appfilter/luasrc/view/admin_network/user_status.htm:79
|
||||
msgid "过滤状态"
|
||||
msgstr ""
|
||||
msgid "Enable App Filter"
|
||||
msgstr "开启应用过滤"
|
||||
|
||||
#~ msgid "website"
|
||||
#~ 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 "招聘"
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set appfilter.user=user
|
||||
commit appfilter
|
||||
EOF
|
||||
exit 0
|
||||
@ -3,12 +3,12 @@ include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=oaf
|
||||
PKG_VERSION:=3.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/destan19/OpenAppFilter.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2020-05-26
|
||||
PKG_SOURCE_VERSION:=bba08ecedaf97bd4bbb991e32b89eb81ad017da6
|
||||
PKG_SOURCE_DATE:=2020-06-15
|
||||
PKG_SOURCE_VERSION:=08f07db43d7dd424cb763f50ed7437d35449af7c
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
@ -64,6 +64,25 @@ load_rule()
|
||||
config_apply "$json_str"
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
load_mac_list()
|
||||
{
|
||||
json_init
|
||||
config_load appfilter
|
||||
json_add_int "op" 4
|
||||
json_add_object "data"
|
||||
json_add_array "mac_list"
|
||||
config_get appid_list "user" "users"
|
||||
echo "appid list=$appid_list"
|
||||
for appid in $appid_list:
|
||||
do
|
||||
echo "appid=$appid"
|
||||
json_add_string "" $appid
|
||||
done
|
||||
json_str=`json_dump`
|
||||
config_apply "$json_str"
|
||||
echo "json str=$json_str"
|
||||
json_cleanup
|
||||
}
|
||||
clean_rule
|
||||
load_rule
|
||||
load_mac_list
|
||||
|
||||
Loading…
Reference in New Issue
Block a user