🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 0d155c70be
commit 32600acc60
14258 files changed
+3954570

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Access Control Configuration
LUCI_DEPENDS:=+snmpd
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-accesscontrol-plus
PKG_VERSION:=1
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,21 @@
module("luci.controller.miaplus",package.seeall)
function index()
if not nixio.fs.access("/etc/config/miaplus") then
return
end
entry({"admin", "services", "miaplus"}, cbi("base"), _("Internet Access Schedule Control Plus"), 30).dependent = true
entry({"admin", "services", "miaplus", "status"}, call("act_status")).leaf = true
entry({"admin", "services", "miaplus", "base"}, cbi("base"), _("Base Setting"), 40).leaf = true
entry({"admin", "services", "miaplus", "advanced"}, cbi("advanced"), _("Advance Setting"), 50).leaf = true
entry({"admin", "services", "miaplus", "template"}, cbi("template"), nil).leaf = true
end
function act_status()
local e = {}
e.running = luci.sys.call("iptables -L INPUT |grep MIAPLUS >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -0,0 +1,21 @@
local ds = require "luci.dispatcher"
a = Map("miaplus")
t = a:section(TypedSection, "templates")
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
t.sortable = true
t.extedit = ds.build_url("admin/services/miaplus/template/%s")
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e.default = "1"
e = t:option(Value, "title", translate("Template"))
e.width = "40%"
e.optional = false
e.default = "default"
return a
@@ -0,0 +1,43 @@
local uci = luci.model.uci.cursor()
a = Map("miaplus")
a.title = translate("Internet Access Schedule Control Plus")
a.description = translate("Access Schedule Control Description")
a:section(SimpleSection).template = "miaplus/miaplus_status"
t = a:section(TypedSection, "basic")
t.anonymous = true
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e = t:option(Flag, "strict", translate("Strict Mode"))
e.description = translate("Strict Mode will degrade CPU performance, but it can achieve better results")
e.rmempty = false
e = t:option(Flag, "ipv6enable", translate("IPV6 Enabled"))
e.rmempty = false
t = a:section(TypedSection, "macbind", translate("Client Rules"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
t.sortable = true
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e.default = "1"
e = t:option(Value, "macaddr", translate("MAC address (Computer Name)"))
e.rmempty = true
luci.sys.net.mac_hints(function(t,a)
e:value(t,"%s (%s)"%{t,a})
end)
e = t:option(ListValue, "template", translate("Template"))
uci:foreach("miaplus", "templates",
function(s)
e:value(s['.name'],s['title'])
end)
return a
@@ -0,0 +1,51 @@
a = Map("miaplus")
local section = arg[1]
t = a:section(TypedSection, section, translate("Rules"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
t.sortable = true
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e.default = "1"
e = t:option(Value, "timeon", translate("Start time"))
e.optional = false
e.default = "00:00"
e = t:option(Value, "timeoff", translate("End time"))
e.optional=false
e.default = "23:59"
e = t:option(Flag, "z1", translate("Mon"))
e.rmempty = true
e.default = 1
e = t:option(Flag, "z2", translate("Tue"))
e.rmempty = true
e.default=1
e = t:option(Flag, "z3", translate("Wed"))
e.rmempty = true
e.default = 1
e = t:option(Flag, "z4", translate("Thu"))
e.rmempty = true
e.default = 1
e = t:option(Flag, "z5", translate("Fri"))
e.rmempty = true
e.default = 1
e = t:option(Flag, "z6", translate("Sat"))
e.rmempty = true
e.default = 1
e = t:option(Flag, "z7", translate("Sun"))
e.rmempty = true
e.default = 1
return a
@@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[miaplus]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('miaplus_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green><%:Internet Access Schedule Control Plus%> <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red><%:Internet Access Schedule Control Plus%> <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="miaplus_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>
+1
View File
@@ -0,0 +1 @@
zh_Hans
@@ -0,0 +1,60 @@
msgid "Internet Access Schedule Control Plus"
msgstr "上网时间控制Plus"
msgid "Access Schedule Control Description"
msgstr "设置客户端访问互联网的时间"
msgid "General switch"
msgstr "开启/关闭"
msgid "Base Setting"
msgstr "基本设置"
msgid "Advance Setting"
msgstr "高级设置"
msgid "Strict Mode"
msgstr "严格模式"
msgid "Strict Mode will degrade CPU performance, but it can achieve better results"
msgstr "严格模式会损耗部分CPU资源,但可以按照时间规则立即拦截数据包,效果更好"
msgid "Client Rules"
msgstr "客户端规则"
msgid "Description"
msgstr "描述"
msgid "MAC address (Computer Name)"
msgstr "MAC 地址 (主机名)"
msgid "Start time"
msgstr "开始时间"
msgid "End time"
msgstr "结束时间"
msgid "Mon"
msgstr "一"
msgid "Tue"
msgstr "二"
msgid "Wed"
msgstr "三"
msgid "Thu"
msgstr "四"
msgid "Fri"
msgstr "五"
msgid "Sat"
msgstr "六"
msgid "Sun"
msgstr "日"
msgid "Template"
msgstr "模板"
@@ -0,0 +1,8 @@
config basic
option enable '0'
option strict '0'
config templates
option enable '0'
option title 'default'
+169
View File
@@ -0,0 +1,169 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2015 OpenWrt-dist
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
START=30
CONFIG=miaplus
uci_export_section_name() {
local ret=$(uci -n export $CONFIG | grep "config $1" | awk '{print $3}' | awk -F\' '{print $2}')
echo ${ret:=$2}
}
uci_get_by_name() {
local ret=$(uci get $CONFIG.$1.$2 2>/dev/null)
echo ${ret:=$3}
}
uci_get_by_type() {
local index=0
if [ -n "$4" ]; then
index=$4
fi
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
echo ${ret:=$3}
}
uci_get_mac_by_template(){
local ret=""
for i in $(seq 0 100)
do
local enable=$(uci_get_by_type macbind enable '' $i)
local macaddr=$(uci_get_by_type macbind macaddr '' $i)
local template=$(uci_get_by_type macbind template '' $i)
if [ -z $enable ] || [ -z $macaddr ] || [ -z $template ]; then
break
fi
if [ "$enable" == "1" ]; then
if [ -z "$1" ] || [ "$template" == "$1" ]; then
if [ "$ret" == "" ]; then
ret=$macaddr
else
ret="$ret $macaddr"
fi
fi
fi
done
echo ${ret:=$2}
}
add_rules(){
local sections=$(uci_export_section_name templates '')
if [ -n "$sections" ]; then
for s in $sections
do
local enable=$(uci_get_by_name $s enable '' $i)
local title=$(uci_get_by_name $s title '' $i)
if [ -z $enable ]; then
break
fi
if [ "$enable" == "1" ]; then
add_rule $s
fi
done
fi
}
add_rule(){
ipv6enable=$(uci get miaplus.@basic[0].ipv6enable)
local macaddrs=$(uci_get_mac_by_template $1 '')
if [ -z "$macaddrs" ]; then
exit 0
fi
for macaddr in $macaddrs
do
iptables -t filter -A MIAPLUS -m mac --mac-source $macaddr -j DROP
[ $ipv6enable -eq 1 ] && ip6tables -t filter -A MIAPLUS -m mac --mac-source $macaddr -j DROP
done
for i in $(seq 0 100)
do
local enable=$(uci_get_by_type $1 enable '' $i)
local timeon=$(uci_get_by_type $1 timeon '' $i)
local timeoff=$(uci_get_by_type $1 timeoff '' $i)
local z1=$(uci_get_by_type $1 z1 '' $i)
local z2=$(uci_get_by_type $1 z2 '' $i)
local z3=$(uci_get_by_type $1 z3 '' $i)
local z4=$(uci_get_by_type $1 z4 '' $i)
local z5=$(uci_get_by_type $1 z5 '' $i)
local z6=$(uci_get_by_type $1 z6 '' $i)
local z7=$(uci_get_by_type $1 z7 '' $i)
[ "$z1" == "1" ] && Z1="Mon,"
[ "$z2" == "1" ] && Z2="Tue,"
[ "$z3" == "1" ] && Z3="Wed,"
[ "$z4" == "1" ] && Z4="Thu,"
[ "$z5" == "1" ] && Z5="Fri,"
[ "$z6" == "1" ] && Z6="Sat,"
[ "$z7" == "1" ] && Z7="Sun"
if [ -z $enable ] || [ -z $timeoff ] || [ -z $timeon ]; then
break
fi
if [ "$enable" == "1" ]; then
for macaddr in $macaddrs
do
iptables -t filter -I MIAPLUS -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j ACCEPT
[ $ipv6enable -eq 1 ] && ip6tables -t filter -I MIAPLUS -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j ACCEPT
done
fi
for n in $(seq 1 7)
do
unset "Z$n"
done
done
}
del_rule(){
type=$1
blackMacAdd=$(iptables -t nat -L $type | grep -w RETURN | grep -w "MAC" | awk '{print $7}')
[ -n "$blackMacAdd" ] && {
for macaddrb in $blackMacAdd
do
iptables -t nat -D $type -m mac --mac-source $macaddrb -j RETURN
done
}
}
start(){
stop
enable=$(uci get miaplus.@basic[0].enable)
[ $enable -eq 0 ] && exit 0
iptables -t filter -N MIAPLUS
iptables -I INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS
iptables -I INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
strict=$(uci get miaplus.@basic[0].strict)
[ $strict -eq 1 ] && iptables -t filter -I FORWARD -m comment --comment "Rule For Control" -j MIAPLUS
ipv6enable=$(uci get miaplus.@basic[0].ipv6enable)
if [ "$ipv6enable" -eq 1 ]; then
ip6tables -t filter -N MIAPLUS
ip6tables -I INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS
ip6tables -I INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
ip6tables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control"
[ $strict -eq 1 ] && ip6tables -t filter -I FORWARD -m comment --comment "Rule For Control" -j MIAPLUS
fi
add_rules
}
stop(){
iptables -t filter -D FORWARD -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
iptables -D INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
iptables -D INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null
iptables -t nat -D PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null
iptables -t filter -F MIAPLUS 2>/dev/null
iptables -t filter -X MIAPLUS 2>/dev/null
notfound=$(type ip6tables | grep not)
if [ -z "$notfound" ]; then
ip6tables -t filter -D FORWARD -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
ip6tables -D INPUT -p udp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
ip6tables -D INPUT -p tcp --dport 53 -m comment --comment "Rule For Control" -j MIAPLUS 2>/dev/null
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null
ip6tables -t nat -D PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 -m comment --comment "Rule For Control" 2>/dev/null
ip6tables -t filter -F MIAPLUS 2>/dev/null
ip6tables -t filter -X MIAPLUS 2>/dev/null
fi
}
@@ -0,0 +1 @@
/etc/init.d/miaplus restart
@@ -0,0 +1,25 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-miaplus.json" ] && {
cat > /usr/share/ucitrack/luci-app-miaplus.json << EEOF
{
"config": "miaplus",
"init": "miaplus"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@miaplus[-1]
add ucitrack miaplus
set ucitrack.@miaplus[-1].init=miaplus
commit ucitrack
delete firewall.miaplus
set firewall.miaplus=include
set firewall.miaplus.type=script
set firewall.miaplus.path=/etc/miaplus.include
set firewall.miaplus.reload=1
commit firewall
EOF
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,11 @@
{
"luci-app-accesscontrol-plus": {
"description": "Grant UCI access for luci-app-accesscontrol-plus",
"read": {
"uci": [ "miaplus" ]
},
"write": {
"uci": [ "miaplus" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "miaplus",
"init": "miaplus"
}