update 2026-09-24 10:46:53

This commit is contained in:
action committed 2026-09-24 10:46:53 +08:00
1 parent 907a158127
commit b31a5c3878
4914 files changed
-1716179

No files matched your search

-15
View File
@@ -1,15 +0,0 @@
# Copyright (C) 2020 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Time Control
LUCI_PKGARCH:=all
PKG_VERSION:=20260426
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -1,16 +0,0 @@
module("luci.controller.timecontrol", package.seeall)
function index()
if not nixio.fs.access("/etc/config/luci-app-timecontrol") then return end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
entry({"admin", "control", "timecontrol"}, cbi("timecontrol"), _("Internet Time Control"), 10).dependent = true
entry({"admin", "control", "timecontrol", "status"}, call("status")).leaf = true
end
function status()
local e = {}
e.status = luci.sys.call("iptables -w -L FORWARD | grep TIMECONTROL >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -1,60 +0,0 @@
local o = require "luci.sys"
local a, t, e
a = Map("luci-app-timecontrol", translate("Internet Time Control"))
a.template = "timecontrol/index"
t = a:section(TypedSection, "basic")
t.anonymous = true
e = t:option(DummyValue, "timecontrol_status", translate("Status"))
e.template = "timecontrol/timecontrol"
e.value = translate("Collecting data...")
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
t = a:section(TypedSection, "macbind", translate("Client Settings"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
e = t:option(Flag, "enable", translate("Enabled"))
e.rmempty = false
e = t:option(Value, "macaddr", "MAC")
e.rmempty = true
o.net.mac_hints(function(t, a)
e:value(t, "%s (%s)" % {t, a})
end)
e = t:option(Value, "timeon", translate("No Internet start time"))
e.default = "00:00"
e.optional = false
e = t:option(Value, "timeoff", translate("No Internet end time"))
e.default = "23:59"
e.optional = false
e = t:option(Flag, "z1", translate("Monday"))
e.rmempty = true
e = t:option(Flag, "z2", translate("Tuesday"))
e.rmempty = true
e = t:option(Flag, "z3", translate("Wednesday"))
e.rmempty = true
e = t:option(Flag, "z4", translate("Thursday"))
e.rmempty = true
e = t:option(Flag, "z5", translate("Friday"))
e.rmempty = true
e = t:option(Flag, "z6", translate("Saturday"))
e.rmempty = true
e = t:option(Flag, "z7", translate("Sunday"))
e.rmempty = true
return a
@@ -1,12 +0,0 @@
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "timecontrol", "status")%>', null,
function (x, result) {
var status = document.getElementsByClassName('timecontrol_status')[0];
status.setAttribute("style", "font-weight:bold;");
status.setAttribute("color", result.status ? "green" : "red");
status.innerHTML = result.status ? '<%=translate("RUNNING")%>' : '<%=translate("NOT RUNNING")%>';
}
)
//]]>
</script>
@@ -1,3 +0,0 @@
<%+cbi/valueheader%>
<font class="timecontrol_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -1,47 +0,0 @@
msgid "Control"
msgstr "管控"
msgid "Internet Time Control"
msgstr "上网时间控制"
msgid "Status"
msgstr "状态"
msgid "Enabled"
msgstr "启用"
msgid "Client Settings"
msgstr "客户端设置"
msgid "No Internet start time"
msgstr "禁止上网开始时间"
msgid "No Internet end time"
msgstr "取消禁止上网时间"
msgid "Monday"
msgstr "周一"
msgid "Tuesday"
msgstr "周二"
msgid "Wednesday"
msgstr "周三"
msgid "Thursday"
msgstr "周四"
msgid "Friday"
msgstr "周五"
msgid "Saturday"
msgstr "周六"
msgid "Sunday"
msgstr "周日"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"
-1
View File
@@ -1 +0,0 @@
zh-cn
@@ -1,3 +0,0 @@
config basic
option enable '0'
@@ -1,99 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
CONFIG="luci-app-timecontrol"
TIMECONTROL_ENABLE=0
iptables_w(){
iptables -w 1 "$@"
ip6tables -w 1 "$@" 2>/dev/null
}
add_rule(){
local enable macaddr timeoff timeon z1 z2 z3 z4 z5 z6 z7
config_get enable "$1" enable "0"
config_get macaddr "$1" macaddr
config_get timeoff "$1" timeoff
config_get timeon "$1" timeon
config_get z1 "$1" z1
config_get z2 "$1" z2
config_get z3 "$1" z3
config_get z4 "$1" z4
config_get z5 "$1" z5
config_get z6 "$1" z6
config_get z7 "$1" z7
if [ -z $enable ] || [ "$enable" != "1" ] || [ -z $macaddr ] || [ -z $timeoff ] || [ -z $timeon ]; then
return 0
fi
local Z1 Z2 Z3 Z4 Z5 Z6 Z7
[ "$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"
local table
for table in filter nat; do
iptables_w -t $table -A TIMECONTROL_RULES -m mac --mac-source $macaddr -m time --kerneltz --timestart $timeon --timestop $timeoff --weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7 -j TIMECONTROL_REJECT
done
}
timecontrol_header(){
config_get TIMECONTROL_ENABLE "$1" enable "0"
}
start(){
local table
config_load ${CONFIG}
config_foreach timecontrol_header basic
[ "$TIMECONTROL_ENABLE" != "1" ] && return 0
# resolve interface
local interface=$(
. /lib/functions/network.sh
network_is_up "lan" && network_get_device device "lan"
echo "${device:-br-lan}"
)
for table in filter nat; do
iptables_w -t $table -N TIMECONTROL
iptables_w -t $table -F TIMECONTROL
iptables_w -t $table -N TIMECONTROL_RULES
iptables_w -t $table -F TIMECONTROL_RULES
iptables_w -t $table -N TIMECONTROL_REJECT
iptables_w -t $table -F TIMECONTROL_REJECT
done
iptables_w -t filter -I TIMECONTROL_REJECT -j DROP
iptables_w -t filter -I TIMECONTROL_REJECT -p tcp -j REJECT --reject-with tcp-reset
iptables_w -t nat -I TIMECONTROL_REJECT -j ACCEPT
config_foreach add_rule macbind
iptables_w -t filter -I TIMECONTROL -i $interface -j TIMECONTROL_RULES
iptables_w -t filter -I FORWARD -j TIMECONTROL
iptables_w -t nat -I TIMECONTROL -i $interface -j TIMECONTROL_RULES
iptables_w -t nat -I PREROUTING -j TIMECONTROL
echo "/etc/init.d/${CONFIG} restart" > "/var/etc/${CONFIG}.include"
}
stop(){
local table
iptables_w -t filter -D FORWARD -j TIMECONTROL
iptables_w -t nat -D PREROUTING -j TIMECONTROL
for table in filter nat; do
iptables_w -t $table -F TIMECONTROL
iptables_w -t $table -X TIMECONTROL
iptables_w -t $table -F TIMECONTROL_RULES
iptables_w -t $table -X TIMECONTROL_RULES
iptables_w -t $table -F TIMECONTROL_REJECT
iptables_w -t $table -X TIMECONTROL_REJECT
done
}
@@ -1,12 +0,0 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete firewall.luci_app_timecontrol
set firewall.luci_app_timecontrol=include
set firewall.luci_app_timecontrol.type=script
set firewall.luci_app_timecontrol.path=/var/etc/luci-app-timecontrol.include
set firewall.luci_app_timecontrol.reload=1
EOF
rm -rf /tmp/luci-*cache
exit 0
@@ -1,11 +0,0 @@
{
"luci-app-timecontrol": {
"description": "Grant UCI access for luci-app-timecontrol",
"read": {
"uci": [ "luci-app-timecontrol" ]
},
"write": {
"uci": [ "luci-app-timecontrol" ]
}
}
}
@@ -1,4 +0,0 @@
{
"config": "luci-app-timecontrol",
"init": "luci-app-timecontrol"
}