🌴 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

+16
View File
@@ -0,0 +1,16 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Weburl
LUCI_DEPENDS:=+iptables-mod-filter +kmod-ipt-filter
LUCI_PKGARCH:=all
PKG_VERSION:=1.1
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,16 @@
module("luci.controller.weburl", package.seeall)
function index()
if not nixio.fs.access("/etc/config/weburl") then return end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
entry({"admin", "control", "weburl"}, cbi("weburl"), _("URL Filter"), 12).dependent = true
entry({"admin", "control", "weburl", "status"}, call("status")).leaf = true
end
function status()
local e = {}
e.status = luci.sys.call("iptables -L FORWARD | grep WEBURL >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -0,0 +1,46 @@
local o = require "luci.sys"
a = Map("weburl", translate("URL Filter"), translate("Set keyword filtering here, can be any character in the URL, can filter such as video sites, QQ, thunder, Taobao..."))
a.template = "weburl/index"
t = a:section(TypedSection, "basic", translate("Running Status"))
t.anonymous = true
e = t:option(DummyValue, "weburl_status", translate("Running Status"))
e.template = "weburl/weburl"
e.value = translate("Collecting data...")
t = a:section(TypedSection, "basic", translate("Basic setting"), translate("In general, normal filtering works fine, but forced filtering uses more complex algorithms and leads to higher CPU usage."))
t.anonymous = true
e = t:option(Flag, "enable", translate("Enable"))
e.rmempty = false
e = t:option(Flag, "algos", translate("Forced filter"))
e.rmempty = false
t = a:section(TypedSection, "macbind", translate("Keyword setting"), translate("MAC addresses do not filter out all clients. For example, only specified clients are filtered out. Filtering time is optional."))
t.template = "cbi/tblsection"
t.anonymous = true
t.addremove = true
e = t:option(Flag, "enable", translate("Enable"))
e.rmempty = false
e = t:option(Value, "macaddr", translate("MAC Address"))
e.rmempty = true
o.net.mac_hints(function(t, a) e:value(t, "%s (%s)" % {t, a}) end)
e = t:option(Value, "timeon", translate("Start time"))
e.placeholder = "00:00"
e.rmempty = true
e = t:option(Value, "timeoff", translate("End time"))
e.placeholder = "23:59"
e.rmempty = true
e = t:option(Value, "keyword", translate("Keyword"))
e.rmempty = false
return a
@@ -0,0 +1,18 @@
<%#
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
Licensed to the public under the Apache License 2.0.
-%>
<% include("cbi/map") %>
<script type="text/javascript">//<![CDATA[
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "weburl", "status")%>', null,
function(x, result)
{
var status = document.getElementsByClassName('weburl_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="weburl_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
<%+cbi/valuefooter%>
@@ -0,0 +1,50 @@
msgid "Control"
msgstr "管控"
msgid "Running Status"
msgstr "运行状态"
msgid "Collecting data..."
msgstr "正在收集数据..."
msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"
msgid "URL Filter"
msgstr "网址过滤"
msgid "Set keyword filtering here, can be any character in the URL, can filter such as video sites, QQ, thunder, Taobao..."
msgstr "在这里设置关键词过滤,可以是URL里任意字符,可以过滤如视频网站、QQ、迅雷、淘宝。。。"
msgid "Basic setting"
msgstr "基本设置"
msgid "In general, normal filtering works fine, but forced filtering uses more complex algorithms and leads to higher CPU usage."
msgstr "一般来说普通过滤效果就很好了,强制过滤会使用更复杂的算法导致更高的CPU占用。"
msgid "Enable"
msgstr "启用"
msgid "Forced filter"
msgstr "强效过滤"
msgid "Keyword setting"
msgstr "关键词设置"
msgid "MAC addresses do not filter out all clients. For example, only specified clients are filtered out. Filtering time is optional."
msgstr "MAC不设置为全客户端过滤,如设置只过滤指定的客户端。过滤时间可不设置。"
msgid "MAC Address"
msgstr "MAC 地址"
msgid "Start time"
msgstr "开始时间"
msgid "End time"
msgstr "结束时间"
msgid "Keyword"
msgstr "关键字"
+1
View File
@@ -0,0 +1 @@
zh-cn
@@ -0,0 +1,22 @@
config basic
option enable '0'
option algos '0'
config macbind
option keyword 'qq.com'
option enable '0'
option macaddr '00:0C:29:C8:99:9E'
config macbind
option keyword 'taobao.com'
option enable '0'
config macbind
option enable '0'
option keyword 'youku.com'
config macbind
option enable '0'
option keyword 'www'
+90
View File
@@ -0,0 +1,90 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
# Copyright (C) 2024 Lienol
START=99
CONFIG=weburl
ipt="iptables -w"
ip6t="ip6tables -w"
start(){
stop
ENABLED=$(uci -q get ${CONFIG}.@basic[0].enable || echo "0")
[ "${ENABLED}" != "1" ] && exit 0
ALGOS=$(uci -q get ${CONFIG}.@basic[0].algos || echo "0")
WEBURL_ALGOS="bm"
[ "${ALGOS}" = "1" ] && WEBURL_ALGOS="kmp"
# resolve interface
local interface=$(
. /lib/functions/network.sh
network_is_up "lan" && network_get_device device "lan"
echo "${device:-br-lan}"
)
$ipt -t filter -N WEBURL_REJECT
$ipt -t filter -I WEBURL_REJECT -j DROP
$ipt -t filter -I WEBURL_REJECT -p tcp -j REJECT --reject-with tcp-reset
$ipt -t filter -N WEBURL_RULES
$ipt -t filter -N WEBURL
$ipt -t filter -I WEBURL -i $interface -m length --length 53:768 -j WEBURL_RULES
# $ipt -t filter -I WEBURL -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
$ipt -t filter -I FORWARD -j WEBURL
$ip6t -t filter -N WEBURL_REJECT 2>/dev/null
$ip6t -t filter -I WEBURL_REJECT -j DROP 2>/dev/null
$ip6t -t filter -I WEBURL_REJECT -p tcp -j REJECT --reject-with tcp-reset 2>/dev/null
$ip6t -t filter -N WEBURL_RULES 2>/dev/null
$ip6t -t filter -N WEBURL 2>/dev/null
$ip6t -t filter -I WEBURL -i $interface -m length --length 53:768 -j WEBURL_RULES 2>/dev/null
# $ip6t -t filter -I WEBURL -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 2>/dev/null
$ip6t -t filter -I FORWARD -j WEBURL 2>/dev/null
local items=$(uci show ${CONFIG} | grep "=macbind" | cut -d '.' -sf 2 | cut -d '=' -sf 1)
for i in $items; do
enable=$(uci -q get ${CONFIG}.${i}.enable || echo "0")
macaddr=$(uci -q get ${CONFIG}.${i}.macaddr)
timeon=$(uci -q get ${CONFIG}.${i}.timeon)
timeoff=$(uci -q get ${CONFIG}.${i}.timeoff)
keyword=$(uci -q get ${CONFIG}.${i}.keyword)
if [ "$enable" == "0" ] || [ -z "$keyword" ]; then
continue
fi
if [ -z "$timeon" ] || [ -z "$timeoff" ]; then
settime=""
else
settime="-m time --kerneltz --timestart $timeon --timestop $timeoff"
fi
if [ -z "$macaddr" ]; then
$ipt -t filter -I WEBURL_RULES $settime -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT
$ip6t -t filter -I WEBURL_RULES $settime -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT 2>/dev/null
else
$ipt -t filter -I WEBURL_RULES $settime -m mac --mac-source $macaddr -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT
$ip6t -t filter -I WEBURL_RULES $settime -m mac --mac-source $macaddr -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT 2>/dev/null
fi
unset enable macaddr timeon timeoff keyword
done
logger -t weburl "weburl filter on $interface"
}
stop(){
$ipt -t filter -D FORWARD -j WEBURL 2>/dev/null
$ipt -t filter -F WEBURL 2>/dev/null
$ipt -t filter -X WEBURL 2>/dev/null
$ipt -t filter -F WEBURL_RULES 2>/dev/null
$ipt -t filter -X WEBURL_RULES 2>/dev/null
$ipt -t filter -F WEBURL_REJECT 2>/dev/null
$ipt -t filter -X WEBURL_REJECT 2>/dev/null
$ip6t -t filter -D FORWARD -j WEBURL 2>/dev/null
$ip6t -t filter -F WEBURL 2>/dev/null
$ip6t -t filter -X WEBURL 2>/dev/null
$ip6t -t filter -F WEBURL_RULES 2>/dev/null
$ip6t -t filter -X WEBURL_RULES 2>/dev/null
$ip6t -t filter -F WEBURL_REJECT 2>/dev/null
$ip6t -t filter -X WEBURL_REJECT 2>/dev/null
}
@@ -0,0 +1,19 @@
#!/bin/sh
[ ! -f "/usr/share/ucitrack/luci-app-weburl.json" ] && {
cat > /usr/share/ucitrack/luci-app-weburl.json << EEOF
{
"config": "weburl",
"init": "weburl"
}
EEOF
}
uci -q batch <<-EOF >/dev/null
delete ucitrack.@weburl[-1]
add ucitrack weburl
set ucitrack.@weburl[-1].init=weburl
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
@@ -0,0 +1,11 @@
{
"luci-app-control-weburl": {
"description": "Grant UCI access for luci-app-control-weburl",
"read": {
"uci": [ "weburl" ]
},
"write": {
"uci": [ "weburl" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "weburl",
"init": "weburl"
}