🌴 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 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#
# Copyright 2019-2024 sirpdboy
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
NAME:=parentcontrol
PKG_NAME:=luci-app-$(NAME)
PKG_VERSION:=1.7.2
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
LUCI_TITLE:=LuCI support for Parent Control
LUCI_DEPENDS:=+iptables-mod-filter +kmod-ipt-filter
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/conffiles
/etc/config/parentcontrol
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
+68
View File
@@ -0,0 +1,68 @@
## 访问数:![hello](https://views.whatilearened.today/views/github/sirpdboy/deplives.svg)[![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ)
<h1 align="center">
<br>luci-app-parentcontrol<br>
</h1>
<p align="center">
<a href="https://openwrt.org"><img alt="OpenWrt" src="https://img.shields.io/badge/OpenWrt-%E2%89%A519.07-ff0000?logo=openwrt&logoColor=white"></a>
<a href="https://www.google.com/chrome/"><img alt="Chrome" src="https://img.shields.io/badge/Chrome-%E2%89%A5111-4285F3?logo=googlechrome&logoColor=white"></a>
<a href="https://www.apple.com/safari/"><img alt="Safari" src="https://img.shields.io/badge/Safari-%E2%89%A516.4-000000?logo=safari&logoColor=white"></a>
<a href="https://www.mozilla.org/firefox/"><img alt="Firefox" src="https://img.shields.io/badge/Firefox-%E2%89%A5128-FF7138?logo=firefoxbrowser&logoColor=white"></a>
<a target="_blank" href="https://github.com/sirpdboy/luci-app-parentcontrol/releases"> <img alt="GitHub release" src="https://img.shields.io/github/v/release/sirpdboy/luci-app-parentcontrol"></a>
<a href="https://github.com/sirpdboy/luci-app-parentcontrol/releases"><img alt="Downloads" src="https://img.shields.io/github/downloads/sirpdboy/luci-app-parentcontrol/total"></a>
</p>
https://github.com/sirpdboy/luci-app-parentcontrol
家长控制 ,可以按时间控制机器,端口和关键字过滤等。
本家长控制,是2022年群里某生找本人出钱定制界面开发,代码原来网上开源代码只是不符合要求,请本人二次开发,现经和需求方协议将代码开源!以感谢大家的支持与鼓励!!也算是为OPENWRT开源代码添砖加瓦!
当然,本身这代码也不是一个什么很高级的代码,权当是抛砖引玉,如果有什么不足之处,欢迎一起ISSE使之更完善。
最初版本参考Lienol大的网址过滤源码和参考部分网上开源代码而来。
参考来源:
https://github.com/Lienol/openwrt-package/tree/main/luci-app-control-weburl
## 界面
![screenshots](./doc/parentcontrol1.png)
![screenshots](./doc/parentcontrol2.png)
![screenshots](./doc/parentcontrol3.png)
# My other project
- 路由安全看门狗 :https://github.com/sirpdboy/luci-app-watchdog
- 网络速度测试 :https://github.com/sirpdboy/luci-app-netspeedtest
- 计划任务插件(原定时设置) : https://github.com/sirpdboy/luci-app-taskplan
- 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice
- opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd
- kucat酷猫主题: https://github.com/sirpdboy/luci-theme-kucat
- kucat酷猫主题设置工具: https://github.com/sirpdboy/luci-app-kucat-config
- NFT版上网时间控制插件: https://github.com/sirpdboy/luci-app-timecontrol
- 家长控制: https://github.com/sirpdboy/luci-theme-parentcontrol
- 定时限速: https://github.com/sirpdboy/luci-app-eqosplus
- 系统高级设置 : https://github.com/sirpdboy/luci-app-advanced
- ddns-go动态域名: https://github.com/sirpdboy/luci-app-ddns-go
- 进阶设置(系统高级设置+主题设置kucat/agron/opentopd): https://github.com/sirpdboy/luci-app-advancedplus
- 网络设置向导: https://github.com/sirpdboy/luci-app-netwizard
- 一键分区扩容: https://github.com/sirpdboy/luci-app-partexp
- lukcy大吉: https://github.com/sirpdboy/luci-app-lukcy
## 捐助
![screenshots](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/说明3.jpg)
| <img src="https://img.shields.io/badge/-支付宝-F5F5F5.svg" href="#赞助支持本项目-" height="25" alt="图飞了😂"/> | <img src="https://img.shields.io/badge/-微信-F5F5F5.svg" height="25" alt="图飞了😂" href="#赞助支持本项目-"/> |
| :-----------------: | :-------------: |
|![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/支付宝.png) | ![xm1](https://raw.githubusercontent.com/sirpdboy/openwrt/master/doc/微信.png) |
<a href="#readme">
<img src="https://img.shields.io/badge/-返回顶部-orange.svg" alt="图飞了😂" title="返回顶部" align="right"/>
</a>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

@@ -0,0 +1,21 @@
module("luci.controller.parentcontrol", package.seeall)
function index()
if not nixio.fs.access("/etc/config/parentcontrol") then return end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
local e = entry({"admin","control","parentcontrol"},firstchild(),_("Parent Control"),2)
e.dependent=false
e.acl_depends = { "luci-app-parentcontrol" }
entry({"admin","control","parentcontrol","time"},cbi("parentcontrol/time"),_("Time Control"),1).leaf=true
entry({"admin", "control", "parentcontrol","weburl"}, cbi("parentcontrol/weburl"), _("Weburl Control"), 20).leaf = true
entry({"admin", "control", "parentcontrol","protocol"}, cbi("parentcontrol/protocol"), _("Protocol Control"), 30).leaf = true
entry({"admin", "control", "parentcontrol","status"}, call("status")).leaf = true
end
function status()
local e = {}
e.status = luci.sys.call("iptables -L FORWARD | grep PARENTCONTROL >/dev/null || iptables -L INPUT | grep PARENTCONTROL >/dev/null || iptables -L OUTPUT | grep PARENTCONTROL >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -0,0 +1,111 @@
local o = require "luci.sys"
local fs = require "nixio.fs"
local ipc = require "luci.ip"
local net = require "luci.model.network".init()
local sys = require "luci.sys"
local a, t, e
a = Map("parentcontrol", translate("Parent Control"), translate("<b><font color=\"green\">利用iptables来管控数据包过滤以禁止符合设定条件的用户连接互联网的工具软件。</font> </b></br>\
协议过滤:可以控制指定MAC机器是否使用指定协议端口,包括IPV4和IPV6,端口可以是连续端口范围用冒号分隔如5000:5100或多个端口用逗号分隔如:5100,5110,5001:5002,440:443</br>不指定MAC就是代表限制所有机器,星期用1-7表示,多个日期用:1,5表示星期一和星期五" ))
a.template = "parentcontrol/index"
t = a:section(TypedSection, "basic", translate(""))
t.anonymous = true
e = t:option(DummyValue, "parentcontrol_status", translate("当前状态"))
e.template = "parentcontrol/parentcontrol"
e.value = translate("Collecting data...")
e = t:option(Flag, "enabled", translate("开启"))
e.rmempty = false
e = t:option(ListValue, "control_mode",translate("管控强度"), translate("普通管控:管控国内网站端口,出国插件的国外端口无法管控!"))
e.rmempty = false
e:value("0", "普通管控")
e.default = "0"
t = a:section(TypedSection, "protocol", translate("协议过滤列表"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
e = t:option(Value, 'remarks', translate('Remarks'))
e = t:option(Flag, "enable", translate("开启"))
e.rmempty = false
e.default = '1'
e = t:option(Value, "mac", translate("MAC地址<font color=\"green\">(留空为全部客户端)</font>"))
e.placeholder = "ALL"
e.rmempty = true
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
e = t:option(ListValue, "proto", translate("<font color=\"gray\">端口协议</font>"))
e.rmempty = false
e.default = 'tcp'
e:value("tcp", translate("TCP"))
e:value("udp", translate("UDP"))
e:value("icmp", translate("ICMP"))
e = t:option(Value, "ports", translate("<font color=\"gray\">源端口</font>"))
e.rmempty = true
e = t:option(Value, "portd", translate("<font color=\"gray\">目的端口</font>"))
e:value("",translate("ICMP"))
e:value("80", "TCP-HTTP")
e:value("443", "TCP-HTTPS")
e:value("22", "TCP-SSH")
e:value("1723", "TCP-PPTP")
e:value("25", "TCP-SMTP")
e:value("110", "TCP-POP3")
e:value("21", "TCP-FTP21")
e:value("23", "TCP-TELNET")
e:value("53", "TCP-DNS53")
e:value("20", "UDP-FTP20")
e:value("1701", "UDP-L2TP")
e:value("69", "UDP-TFTP")
e:value("500", "UDP-IPSEC")
e:value("53", "UDP-DNS53")
e:value("161", "UDP-SNMP")
e.rmempty = true
function validate_time(self, value, section)
local hh, mm, ss
hh, mm, ss = string.match (value, "^(%d?%d):(%d%d)$")
hh = tonumber (hh)
mm = tonumber (mm)
if hh and mm and hh <= 23 and mm <= 59 then
return value
else
return nil, "时间格式必须为 HH:MM 或者留空"
end
end
e = t:option(Value, "timestart", translate("起控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
e = t:option(Value, "timeend", translate("停控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
week=t:option(Value,"week",translate("Week Day"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(7,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
return a
@@ -0,0 +1,82 @@
local o = require "luci.sys"
local fs = require "nixio.fs"
local ipc = require "luci.ip"
local net = require "luci.model.network".init()
local sys = require "luci.sys"
local a, t, e
a = Map("parentcontrol", translate("Parent Control"), translate("<b><font color=\"green\">利用iptables来管控数据包过滤以禁止符合设定条件的用户连接互联网的工具软件。</font> </b></br>\
时间限制:限制指定MAC地址机器是否联网.包括IPV4和IPV6</br>不指定MAC就是代表限制所有机器,星期用1-7表示,多个日期用自定义:1,5表示星期一和星期五" ))
a.template = "parentcontrol/index"
t = a:section(TypedSection, "basic", translate(""))
t.anonymous = true
e = t:option(DummyValue, "parentcontrol_status", translate("当前状态"))
e.template = "parentcontrol/parentcontrol"
e.value = translate("Collecting data...")
e = t:option(Flag, "enabled", translate("开启"))
e.rmempty = false
e = t:option(ListValue, "control_mode",translate("管控强度"), translate("普通管控:管控国内网站,出国插件的国外网站无法管控。强力管控:国内国外都可管控,注意:被管控的机器将无法连接上软路由后台!"))
e.rmempty = false
e:value("0", "普通管控")
e:value("1", "强力管控")
e.default = "0"
t = a:section(TypedSection, "time", translate("时间限制列表"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
e = t:option(Value, 'remarks', translate('Remarks'))
e = t:option(Flag, "enable", translate("开启"))
e.rmempty = false
e.default = '1'
e = t:option(Value, "mac", translate("MAC地址<font color=\"green\">(留空为全部客户端)</font>"))
e.rmempty = true
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
function validate_time(self, value, section)
local hh, mm, ss
hh, mm, ss = string.match (value, "^(%d?%d):(%d%d)$")
hh = tonumber (hh)
mm = tonumber (mm)
if hh and mm and hh <= 23 and mm <= 59 then
return value
else
return nil, "时间格式必须为 HH:MM 或者留空"
end
end
e = t:option(Value, "timestart", translate("起控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
e = t:option(Value, "timeend", translate("停控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
week=t:option(Value,"week",translate("Week Day"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(7,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
return a
@@ -0,0 +1,90 @@
local o = require "luci.sys"
local fs = require "nixio.fs"
local ipc = require "luci.ip"
local net = require "luci.model.network".init()
local sys = require "luci.sys"
local a, t, e
a = Map("parentcontrol", translate("Parent Control"), translate("<b><font color=\"green\">利用iptables来管控数据包过滤以禁止符合设定条件的用户连接互联网的工具软件。</font> </b></br>\
网址过滤:指定“关键词/URL”过滤,可以是字符串或网址.包括IPV4和IPV6</br>不指定MAC就是代表限制所有机器,星期用1-7表示,多个日期用自定义:1,5表示星期一和星期五" ))
a.template = "parentcontrol/index"
t = a:section(TypedSection, "basic", translate(""))
t.anonymous = true
e = t:option(DummyValue, "parentcontrol_status", translate("当前状态"))
e.template = "parentcontrol/parentcontrol"
e.value = translate("Collecting data...")
e = t:option(Flag, "enabled", translate("开启"))
e.rmempty = false
e = t:option(ListValue, "algos", translate("过滤力度"))
e:value("bm", "一般过滤")
e:value("kmp", "强效过滤")
e.default = "kmp"
e = t:option(ListValue, "control_mode",translate("管控强度"), translate("普通管控:管控国内网站,出国插件的国外网站无法管控"))
e.rmempty = false
e:value("0", "普通管控")
e.default = "0"
t = a:section(TypedSection, "weburl", translate("网址过滤列表"))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
remarks = t:option(Value, 'remarks', translate('Remarks'))
e = t:option(Flag, "enable", translate("开启"))
e.rmempty = false
e.default = '1'
e = t:option(Value, "mac", translate("MAC地址<font color=\"green\">(必指定客户端)</font>"))
e.rmempty = true
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
e = t:option( Value, "word", translate("关键词/URL<font color=\"green\">(可留空)</font>"))
e.rmempty = true
function validate_time(self, value, section)
local hh, mm, ss
hh, mm, ss = string.match (value, "^(%d?%d):(%d%d)$")
hh = tonumber (hh)
mm = tonumber (mm)
if hh and mm and hh <= 23 and mm <= 59 then
return value
else
return nil, "时间格式必须为 HH:MM 或者留空"
end
end
e = t:option(Value, "timestart", translate("起控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
e = t:option(Value, "timeend", translate("停控时间"))
e.placeholder = '00:00'
e.default = '00:00'
e.validate = validate_time
e.rmempty = true
week=t:option(Value,"week",translate("Week Day"))
week.rmempty = false
week.optional = false
week:value('*',translate("Everyday"))
week:value(7,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
return a
@@ -0,0 +1,12 @@
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "parentcontrol", "status")%>', null,
function (x, result) {
var status = document.getElementsByClassName('parentcontrol_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>
@@ -0,0 +1,3 @@
<%+cbi/valueheader%>
<font class="parentcontrol_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -0,0 +1,23 @@
msgid "Control"
msgstr "管控"
msgid "Parent Control"
msgstr "家长控制"
msgid "Time Control"
msgstr "时间限制"
msgid "Weburl Control"
msgstr "网址过滤"
msgid "Protocol Control"
msgstr "协议过滤"
msgid "feature Control"
msgstr "配置过滤库"
msgid "Week Day"
msgstr "设定星期"
msgid "Everyday"
msgstr "每天"
@@ -0,0 +1,23 @@
msgid "Control"
msgstr "管控"
msgid "Parent Control"
msgstr "家长控制"
msgid "Time Control"
msgstr "时间限制"
msgid "Weburl Control"
msgstr "网址过滤"
msgid "Protocol Control"
msgstr "协议过滤"
msgid "feature Control"
msgstr "配置过滤库"
msgid "Week Day"
msgstr "设定星期"
msgid "Everyday"
msgstr "每天"
@@ -0,0 +1,54 @@
config basic
option algos 'kmp'
option control_mode '0'
option enabled '0'
config weburl
option word 'baidu'
option timestart '00:00'
option timeend '00:00'
option week '*'
option enable '0'
config weburl
option timestart '00:00'
option timeend '00:00'
option word 'youtube'
option week '1,2,3,4,5'
option enable '0'
config protocol
option proto 'tcp'
option timestart '00:00'
option week '*'
option timeend '23:00'
option portd '80'
option enable '0'
config protocol
option proto 'tcp'
option timestart '00:00'
option week '*'
option portd '443'
option timeend '23:00'
option enable '0'
config protocol
option proto 'tcp'
option timestart '00:00'
option timeend '00:00'
option week '1,2,3,4,5'
option enable '0'
config time
option timestart '00:00'
option week '*'
option timeend '23:59'
option enable '0'
config time
option timestart '00:00'
option enable '0'
option week '1,2,3,4,5'
option timeend '23:59'
@@ -0,0 +1,7 @@
#!/bin/sh
CONFIG=parentcontrol
[ "$ACTION" = ifup ] || exit 0
[ "$(`uci -q get $CONFIG.@basic[0].enabled`)" == 1 ] || exit 0
/etc/init.d/parentcontrol start
+155
View File
@@ -0,0 +1,155 @@
#!/bin/sh /etc/rc.common
# sirpdboy at 2021-2023 , <herboy2008@gmail.com>
DIR="$(cd "$(dirname "$0")" && pwd)"
MY_PATH=$DIR/iptables.sh
START=98
CONFIG=parentcontrol
LOG_FILE=/tmp/log/$CONFIG.log
LOCK_DIR=/tmp/lock
LOCK=/tmp/lock/${CONFIG}.lock
ipt=$(command -v iptables-legacy || command -v iptables)
ipt6=$(command -v ip6tables-legacy || command -v ip6tables)
TAG="PARENTCONTROL_TIME"
TAGP="PARENTCONTROL_PROTOCOL"
TAGW="PARENTCONTROL_WEBURL"
FWI="/var/etc/$CONFIG.include"
elog() {
local d="$(date "+%Y-%m-%d %H:%M:%S")"
echo -e "$d: $*" >>$LOG_FILE
}
clean_log() {
[ `cat $LOG_FILE | wc -l ` -gt 500 ] && {
elog "clear log ."
}
}
set_rules() {
mmode=$1
case $mmode in
time)
controlmode=`uci -q get $CONFIG.@basic[0].control_mode`
[ "x$controlmode" == 'x1' ] && chain=INPUT || chain=FORWARD
for ip in "$ipt" "$ipt6" ; do
$ip -N $TAG 2>/dev/null || $i -F $TAG 2>/dev/null
$ip -C $chain -j $TAG 2>/dev/null || $ip -I $chain -j $TAG 2>/dev/null
done
;;
protocol)
chain=FORWARD
for ip in "$ipt" "$ipt6" ; do
$ip -N $TAGP 2>/dev/null || $i -F $TAGP 2>/dev/null
$ip -C $chain -j $TAGP 2>/dev/null || $ip -I $chain -j $TAGP 2>/dev/null
done
;;
weburl)
chain=OUTPUT
algos=`uci -q get $CONFIG.@basic[0].algos`
for ip in "$ipt" "$ipt6" ; do
$ip -N $TAGW 2>/dev/null || $i -F $TAGW 2>/dev/null
$ip -C $chain -j $TAGW 2>/dev/null || $ip -I $chain -j $TAGW 2>/dev/null
done
;;
esac
idlist=`uci show $CONFIG | grep "enable='1'" | grep "$mmode" | grep -oE '\[.*?\]' | grep -o '[0-9]'`
for i in $idlist ;do
mac=$(uci -q get $CONFIG.@$mmode[$i].mac ) && MAC="-m mac --mac-source $mac" || MAC=""
timestart=$(uci -q get $CONFIG.@$mmode[$i].timestart ) || timestart="00:00"
timeend=$(uci -q get $CONFIG.@$mmode[$i].timeend) || timeend="00:00"
wweek=$(uci -q get $CONFIG.@$mmode[$i].week ) || wweek='*'
local Z1,Z2,Z3,Z4,Z5,Z6,Z7=0,0,0,0,0,0,0
for ww in `echo $wweek | sed 's/,/ /g' `; do
[ "$ww" == "1" ] && Z1="Mon,"
[ "$ww" == "2" ] && Z2="Tue,"
[ "$ww" == "3" ] && Z3="Wed,"
[ "$ww" == "4" ] && Z4="Thu,"
[ "$ww" == "5" ] && Z5="Fri,"
[ "$ww" == "6" ] && Z6="Sat,"
[ "$ww" == "7" ] && Z7="Sun"
done
[ -z "$timestart" -o -z "$timeend" -o "$timestart" = "$timeend" ] && TIME="" || TIME="--timestart ${timestart} --timestop ${timeend}"
[ -z "$wweek" -o "x$wweek" = "x*" ] && WEEK="" || WEEK="--weekdays $Z1$Z2$Z3$Z4$Z5$Z6$Z7"
[ -n "$TIME" -o -n "$WEEK" ] && WT="-m time --kerneltz ${TIME} ${WEEK}" || WT=""
case $mmode in
time)
for pt in "$ipt" "$ipt6" ; do
$pt -I $TAG ${MAC} ${WT} -j REJECT 2>/dev/null
elog "$mmode:$pt -- ${MAC} -- ${WT} "
done
;;
protocol)
proto=$(uci -q get $CONFIG.@$mmode[$i].proto ) || proto="tcp"
ports=$(uci -q get $CONFIG.@$mmode[$i].ports ) && SPO="--sport ${ports}" || SPO=""
portd=$(uci -q get $CONFIG.@$mmode[$i].portd ) && DPO="--dport ${portd}" || DPO=""
mMPT=`echo "$ports"|grep ","` && mSPO="-m multiport" || mSPO=""
mMPT=`echo "$portd"|grep ","` && mDPO="-m multiport" || mDPO=""
[ -z "$ports" -a -z "$portd" ] && PTO="" || PTO="-p ${proto} ${mSPO} ${SPO} ${mDPO} ${DPO}"
for pt in "$ipt" "$ipt6" ; do
$pt -I $TAGP ${MAC} ${WT} ${PTO} -j REJECT 2>/dev/null
elog "$mmode: $pt -- ${MAC} -- ${WT} -- ${PTO}"
done
;;
weburl)
word=$(uci -q get $CONFIG.@$mmode[$i].word ) && STR="-m string --algo ${algos} --string ${word}" || STR=""
word2=$(uci -q get $CONFIG.@$mmode[$i].word ) && STR2="-m string --algo ${algos} --hex-string ${word2}" || STR2=""
for pt in "$ipt" "$ipt6" ; do
$pt -I $TAGW -p UDP --dport 53 ${MAC} ${WT} ${STR} -j DROP 2>/dev/null
$pt -I $TAGW -p UDP --dport 53 ${MAC} ${WT} ${STR2} -j DROP 2>/dev/null
$pt -I $TAGW -p TCP --dport 853 ${MAC} ${WT} ${STR} -j DROP 2>/dev/null
$pt -I $TAGW -p TCP --dport 853 ${MAC} ${WT} ${STR2} -j DROP 2>/dev/null
elog "$mmode: $pt -- ${MAC} -- ${WT} -- ${STR}"
done
;;
*) ;;
esac
unset STR MAC WT PTO
done
}
flush_include() {
echo '#!/bin/sh' >$FWI
}
del_rule() {
for ip in "$ipt" "$ipt6" ; do
for ta in "$TAG" "$TAGW" "$TAGP" ; do
for chain in "PREROUTING" "FORWARD" "OUTPUT" "INPUT" ; do
$ip -D $chain -j $ta 2>/dev/null
# elog "delrule: $ip -- $ta -- ${chain} "
done
$ip -F $ta 2>/dev/null
$ip -X $ta 2>/dev/null
done
done
}
start(){
[ -f $LOCK ] && exit 1
del_rule
enabled=`uci -q get $CONFIG.@basic[0].enabled`
[ "x$enabled" == "x1" ] || exit 1
allsum=`grep -c 'enable .1.' /etc/config/$CONFIG`
[ "$allsum" -gt 0 ] && {
touch $LOCK
set_rules time
set_rules protocol
set_rules weburl
}
clean_log
rm -f $LOCK 2>/dev/null
}
stop(){
del_rule
rm -f $LOCK 2>/dev/null
}
@@ -0,0 +1,2 @@
/etc/init.d/parentcontrol start
@@ -0,0 +1,3 @@
baidu
163.com
@@ -0,0 +1 @@
baidu.com
@@ -0,0 +1,27 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-parentcontrol.json" ] && {
cat > /usr/share/ucitrack/luci-app-parentcontrol.json << EEOF
{
"config": "parentcontrol",
"init": "parentcontrol"
}
EEOF
}
[ -e "/etc/config/ucitrack" ] && {
uci -q batch <<-EOF >/dev/null
delete ucitrack.@parentcontrol[-1]
add ucitrack parentcontrol
set ucitrack.@parentcontrol[-1].init=parentcontrol
commit ucitrack
EOF
}
uci -q delete firewall.parentcontrol
uci -q set firewall.parentcontrol=include
uci -q set firewall.parentcontrol.type=script
uci -q set firewall.parentcontrol.path=/etc/parentcontrol.include
uci -q set firewall.parentcontrol.reload=1
uci commit firewall
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,11 @@
{
"luci-app-parentcontrol": {
"description": "Grant UCI access for luci-app-parentcontrol",
"read": {
"uci": [ "parentcontrol" ]
},
"write": {
"uci": [ "parentcontrol" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "parentcontrol",
"init": "parentcontrol"
}