update 2026-09-24 16:56:26

This commit is contained in:
action committed 2026-09-24 16:56:26 +08:00
1 parent b31a5c3878
commit e4cee331e9
6885 files changed
+3240523

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:=2
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
@@ -0,0 +1,18 @@
module("luci.controller.weburl", package.seeall)
function index()
if not nixio.fs.access("/etc/config/luci-app-control-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 -w -L FORWARD | grep WEBURL >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
@@ -0,0 +1,51 @@
local o = require "luci.sys"
a = Map("luci-app-control-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'
@@ -0,0 +1,74 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
# Copyright (C) 2024 Lienol
START=99
CONFIG="luci-app-control-weburl"
iptables_w(){
iptables -w 1 "$@"
ip6tables -w 1 "$@"
}
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}"
)
iptables_w -t filter -N WEBURL_REJECT
iptables_w -t filter -I WEBURL_REJECT -j DROP
iptables_w -t filter -I WEBURL_REJECT -p tcp -j REJECT --reject-with tcp-reset
iptables_w -t filter -N WEBURL_RULES
iptables_w -t filter -N WEBURL
iptables_w -t filter -I WEBURL -i $interface -m length --length 53:768 -j WEBURL_RULES
# iptables_w -t filter -I WEBURL -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables_w -t filter -I FORWARD -j WEBURL
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
iptables_w -t filter -I WEBURL_RULES $settime -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT
else
iptables_w -t filter -I WEBURL_RULES $settime -m mac --mac-source $macaddr -m string --string "$keyword" --algo $WEBURL_ALGOS -j WEBURL_REJECT
fi
unset enable macaddr timeon timeoff keyword
done
logger -t weburl "weburl filter on $interface"
}
stop(){
iptables_w -t filter -D FORWARD -j WEBURL 2>/dev/null
iptables_w -t filter -F WEBURL 2>/dev/null
iptables_w -t filter -X WEBURL 2>/dev/null
iptables_w -t filter -F WEBURL_RULES 2>/dev/null
iptables_w -t filter -X WEBURL_RULES 2>/dev/null
iptables_w -t filter -F WEBURL_REJECT 2>/dev/null
iptables_w -t filter -X WEBURL_REJECT 2>/dev/null
}
@@ -0,0 +1,11 @@
{
"luci-app-control-weburl": {
"description": "Grant UCI access for luci-app-control-weburl",
"read": {
"uci": [ "luci-app-control-weburl" ]
},
"write": {
"uci": [ "luci-app-control-weburl" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "luci-app-control-weburl",
"init": "luci-app-control-weburl"
}