mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-26 20:22:51 +08:00
update 2026-09-26 17:00:06
This commit is contained in:
1 parent
97ae9f68da
commit
bcc9ceb04a
4756 files changed
+1670713
No files matched your search
@@ -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%>
|
||||
Reference in new issue
Block a user