mirror of
https://github.com/kenzok8/small-package
synced 2025-01-05 11:36:47 +08:00
update 2023-03-03 19:12:20
This commit is contained in:
parent
9dbad56e6d
commit
4cd8e02d2c
32
autoupdate/Makefile
Executable file
32
autoupdate/Makefile
Executable file
@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2020-2022 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=autoupdate
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Upgrade OpenWrt by one-key
|
||||
DEPENDS:=+bash +jq
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
autoupdate - Upgrade OpenWrt by one-key
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(INSTALL_BIN) ./files/bin/autoupdate $(1)/bin
|
||||
$(INSTALL_DIR) $(1)/etc/autoupdate
|
||||
$(CP) ./files/etc/autoupdate/* $(1)/etc/autoupdate
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
1427
autoupdate/files/bin/autoupdate
Executable file
1427
autoupdate/files/bin/autoupdate
Executable file
File diff suppressed because it is too large
Load Diff
2
autoupdate/files/etc/autoupdate/default
Executable file
2
autoupdate/files/etc/autoupdate/default
Executable file
@ -0,0 +1,2 @@
|
||||
## 请不要修改此文件中的内容, 自定义变量请在 custom 中添加或修改
|
||||
## 该文件将在运行 autoupdate 脚本时被读取, 且该文件中的内容优先级低于 custom
|
@ -1,71 +0,0 @@
|
||||
# Copyright (C) 2020-2023 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-adguardhome
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=20230123
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-adguardhome
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=LuCI support for AdGuard Home [Modified by Hyy2001]
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+!wget-ssl&&!curl:wget-ssl +xz-utils +xz
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/description
|
||||
LuCI support for AdGuard Home
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/conffiles
|
||||
/usr/share/AdGuardHome/links.txt
|
||||
/etc/config/AdGuardHome
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
|
||||
cp -pR ./luasrc/* $(1)/usr/lib/lua/luci
|
||||
$(INSTALL_DIR) $(1)/
|
||||
cp -pR ./root/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||
po2lmo ./po/zh-cn/AdGuardHome.po $(1)/usr/lib/lua/luci/i18n/AdGuardHome.zh-cn.lmo
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/postinst
|
||||
#!/bin/sh
|
||||
/etc/init.d/AdGuardHome enable >/dev/null 2>&1
|
||||
enable=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
|
||||
if [ "$enable" == "1" ]; then
|
||||
/etc/init.d/AdGuardHome reload
|
||||
fi
|
||||
rm -f /tmp/luci-indexcache
|
||||
rm -f /tmp/luci-modulecache/*
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/luci-app-adguardhome/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
/etc/init.d/AdGuardHome disable
|
||||
/etc/init.d/AdGuardHome stop
|
||||
uci -q batch <<-EOF >/dev/null 2>&1
|
||||
delete ucitrack.@AdGuardHome[-1]
|
||||
commit ucitrack
|
||||
EOF
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-adguardhome))
|
@ -1,17 +0,0 @@
|
||||
# luci-app-adguardhome
|
||||
|
||||
## 修改内容
|
||||
|
||||
- 修复 本地 AdGuardHome 核心文件版本号获取
|
||||
|
||||
- 优化 AdGuardHome 核心更新以及UPX压缩流程
|
||||
|
||||
- 汉化 AdGuardHome 核心更新时显示的内容
|
||||
|
||||
- 优化 默认模板、DNS 服务器以及 DNS 封锁清单
|
||||
|
||||
## Based on
|
||||
|
||||
- [rufengsuixing](https://github.com/rufengsuixing/luci-app-adguardhome)
|
||||
|
||||
- [Lienol](https://github.com/Lienol)
|
@ -1,130 +0,0 @@
|
||||
module("luci.controller.AdGuardHome", package.seeall)
|
||||
local fs = require "nixio.fs"
|
||||
local http = require "luci.http"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
function index()
|
||||
entry({"admin", "services", "AdGuardHome"}, alias("admin", "services", "AdGuardHome", "base"), _("AdGuard Home"), 10).dependent = true
|
||||
entry({"admin", "services", "AdGuardHome", "base"}, cbi("AdGuardHome/base"), _("Base Setting"), 1).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "log"}, form("AdGuardHome/log"), _("Log"), 2).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "manual"}, cbi("AdGuardHome/manual"), _("Manual Config"), 3).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "status"}, call("act_status")).leaf = true
|
||||
entry({"admin", "services", "AdGuardHome", "check"}, call("check_update"))
|
||||
entry({"admin", "services", "AdGuardHome", "doupdate"}, call("do_update"))
|
||||
entry({"admin", "services", "AdGuardHome", "getlog"}, call("get_log"))
|
||||
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
|
||||
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
|
||||
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
|
||||
end
|
||||
|
||||
function get_template_config()
|
||||
local b
|
||||
local d = ""
|
||||
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
if not fs.access(file) then
|
||||
file = "/tmp/resolv.conf.auto"
|
||||
end
|
||||
for cnt in io.lines(file) do
|
||||
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
|
||||
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
|
||||
end
|
||||
local f = io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||
local tbl = {}
|
||||
local a = ""
|
||||
while (1) do
|
||||
a = f:read("*l")
|
||||
if (a == "#bootstrap_dns") then
|
||||
a = d
|
||||
elseif (a == "#upstream_dns") then
|
||||
a = d
|
||||
elseif (a == nil) then
|
||||
break
|
||||
end
|
||||
table.insert(tbl, a)
|
||||
end
|
||||
f:close()
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
http.write(table.concat(tbl, "\n"))
|
||||
end
|
||||
|
||||
function reload_config()
|
||||
fs.remove("/tmp/AdGuardHometmpconfig.yaml")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
local binpath = uci:get("AdGuardHome", "AdGuardHome", "binpath")
|
||||
e.running = luci.sys.call("pgrep " .. binpath .. " >/dev/null") == 0
|
||||
e.redirect = (fs.readfile("/var/run/AdGredir") == "1")
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
end
|
||||
|
||||
function do_update()
|
||||
fs.writefile("/var/run/lucilogpos", "0")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
local arg
|
||||
if luci.http.formvalue("force") == "1" then
|
||||
arg = "force"
|
||||
else
|
||||
arg = ""
|
||||
end
|
||||
if fs.access("/var/run/update_core") then
|
||||
if arg == "force" then
|
||||
luci.sys.exec("kill $(pgrep /usr/share/AdGuardHome/update_core.sh) ; sh /usr/share/AdGuardHome/update_core.sh " .. arg .. " >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||
end
|
||||
else
|
||||
luci.sys.exec("sh /usr/share/AdGuardHome/update_core.sh " .. arg .. " >/tmp/AdGuardHome_update.log 2>&1 &")
|
||||
end
|
||||
end
|
||||
|
||||
function get_log()
|
||||
local logfile = uci:get("AdGuardHome", "AdGuardHome", "logfile")
|
||||
if (logfile == nil) then
|
||||
http.write("no log available\n")
|
||||
return
|
||||
elseif (logfile == "syslog") then
|
||||
if not fs.access("/var/run/AdGuardHomesyslog") then
|
||||
luci.sys.exec("(/usr/share/AdGuardHome/getsyslog.sh &); sleep 1;")
|
||||
end
|
||||
logfile = "/tmp/AdGuardHometmp.log"
|
||||
fs.writefile("/var/run/AdGuardHomesyslog", "1")
|
||||
elseif not fs.access(logfile) then
|
||||
http.write("")
|
||||
return
|
||||
end
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||
local f = io.open(logfile, "r+")
|
||||
f:seek("set", fdp)
|
||||
local a = f:read(2048000) or ""
|
||||
fdp = f:seek()
|
||||
fs.writefile("/var/run/lucilogpos", tostring(fdp))
|
||||
f:close()
|
||||
http.write(a)
|
||||
end
|
||||
|
||||
function do_dellog()
|
||||
local logfile = uci:get("AdGuardHome", "AdGuardHome", "logfile")
|
||||
fs.writefile(logfile, "")
|
||||
http.prepare_content("application/json")
|
||||
http.write('')
|
||||
end
|
||||
|
||||
function check_update()
|
||||
http.prepare_content("text/plain; charset=utf-8")
|
||||
local fdp = tonumber(fs.readfile("/var/run/lucilogpos")) or 0
|
||||
local f = io.open("/tmp/AdGuardHome_update.log", "r+")
|
||||
f:seek("set", fdp)
|
||||
local a = f:read(2048000) or ""
|
||||
fdp = f:seek()
|
||||
fs.writefile("/var/run/lucilogpos", tostring(fdp))
|
||||
f:close()
|
||||
if fs.access("/var/run/update_core") then
|
||||
http.write(a)
|
||||
else
|
||||
http.write(a .. "\0")
|
||||
end
|
||||
end
|
@ -1,316 +0,0 @@
|
||||
require("luci.sys")
|
||||
require("luci.util")
|
||||
require("io")
|
||||
local m, s, o, o1
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local configpath = uci:get("AdGuardHome", "AdGuardHome", "configpath") or "/etc/config/AdGuardHome.yaml"
|
||||
local binpath = uci:get("AdGuardHome", "AdGuardHome", "binpath") or "/usr/bin/AdGuardHome/AdGuardHome"
|
||||
httpport = uci:get("AdGuardHome", "AdGuardHome", "httpport") or "3000"
|
||||
|
||||
m = Map("AdGuardHome", "AdGuard Home")
|
||||
m.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
|
||||
m:section(SimpleSection).template = "AdGuardHome/AdGuardHome_status"
|
||||
|
||||
s = m:section(TypedSection, "AdGuardHome")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
---- enable
|
||||
o = s:option(Flag, "enabled", translate("Enable"))
|
||||
o.default = 0
|
||||
o.optional = false
|
||||
|
||||
---- httpport
|
||||
o = s:option(Value, "httpport", translate("Browser management port"))
|
||||
o.placeholder = 3000
|
||||
o.default = 3000
|
||||
o.datatype = "port"
|
||||
o.optional = false
|
||||
o.description = translate("<input type='button' style='width:210px; border-color:Teal; text-align:center; font-weight:bold;color:Green;' value='AdGuardHome Web:" .. httpport .. "' onclick=\"window.open('http://'+window.location.hostname+':" .. httpport .. "')\"/>")
|
||||
|
||||
---- update warning not safe
|
||||
local binmtime = uci:get("AdGuardHome", "AdGuardHome", "binmtime") or "0"
|
||||
local e = ""
|
||||
if not fs.access(configpath) then e = e .. " " .. translate("no config") end
|
||||
if not fs.access(binpath) then
|
||||
e = e .. " " .. translate("no core")
|
||||
else
|
||||
local version = uci:get("AdGuardHome", "AdGuardHome", "version")
|
||||
local testtime = fs.stat(binpath, "mtime")
|
||||
if testtime ~= tonumber(binmtime) or version == nil then
|
||||
-- local tmp=luci.sys.exec(binpath.." -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o")
|
||||
-- version=string.sub(tmp, 1, -2)
|
||||
version = luci.sys.exec(string.format("echo -n $(%s --version 2>&1 | awk -F 'version ' '{print $2}' | awk -F ',' '{print $1}')", binpath))
|
||||
if version == "" then version = "core error" end
|
||||
uci:set("AdGuardHome", "AdGuardHome", "version", version)
|
||||
uci:set("AdGuardHome", "AdGuardHome", "binmtime", testtime)
|
||||
uci:commit("AdGuardHome")
|
||||
end
|
||||
e = version .. e
|
||||
end
|
||||
|
||||
o = s:option(ListValue, "core_version", translate("Core Version"))
|
||||
o:value("latest", translate("Latest Version"))
|
||||
o:value("beta", translate("Beta Version"))
|
||||
o.default = "latest"
|
||||
|
||||
o = s:option(Button, "restart", translate("Upgrade Core"))
|
||||
o.inputtitle = translate("Update core version")
|
||||
o.template = "AdGuardHome/AdGuardHome_check"
|
||||
o.showfastconfig = (not fs.access(configpath))
|
||||
o.description = string.format(translate("Current core version:") .. "<strong><font id='updateversion' color='green'>%s </font></strong>", e)
|
||||
|
||||
---- port warning not safe
|
||||
local port = luci.sys.exec("awk '/ port:/{printf($2);exit;}' " .. configpath .. " 2>nul")
|
||||
if (port == "") then port = "?" end
|
||||
|
||||
---- Redirect
|
||||
o = s:option(ListValue, "redirect", port .. translate("Redirect"), translate("AdGuardHome redirect mode"))
|
||||
o.placeholder = "none"
|
||||
o:value("none", translate("none"))
|
||||
o:value("dnsmasq-upstream", translate("Run as dnsmasq upstream server"))
|
||||
o:value("redirect", translate("Redirect 53 port to AdGuardHome"))
|
||||
o:value("exchange", translate("Use port 53 replace dnsmasq"))
|
||||
o.default = "none"
|
||||
o.optional = true
|
||||
|
||||
---- bin path
|
||||
o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
|
||||
o.default = "/usr/bin/AdGuardHome/AdGuardHome"
|
||||
o.datatype = "string"
|
||||
o.optional = false
|
||||
o.rmempty = false
|
||||
o.validate = function(self, value)
|
||||
if value == "" then return nil end
|
||||
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
|
||||
if fs.stat(value, "type") == "dir" then
|
||||
if (m.message) then
|
||||
m.message = m.message .. "\nerror!bin path is a dir"
|
||||
else
|
||||
m.message = "error!bin path is a dir"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
--- upx
|
||||
o = s:option(ListValue, "upxflag", translate("use upx to compress bin after download"))
|
||||
o:value("", translate("none"))
|
||||
o:value("-1", translate("compress faster"))
|
||||
o:value("-9", translate("compress better"))
|
||||
o:value("--best", translate("compress best(can be slow for big files)"))
|
||||
o:value("--brute", translate("try all available compression methods & filters [slow]"))
|
||||
o:value("--ultra-brute", translate("try even more compression variants [very slow]"))
|
||||
o.default = ""
|
||||
o.description = translate("bin use less space,but may have compatibility issues")
|
||||
o.rmempty = true
|
||||
|
||||
---- config path
|
||||
o = s:option(Value, "configpath", translate("Config Path"), translate("AdGuardHome config path"))
|
||||
o.default = "/etc/config/AdGuardHome.yaml"
|
||||
o.datatype = "string"
|
||||
o.optional = false
|
||||
o.rmempty = false
|
||||
o.validate = function(self, value)
|
||||
if value == nil then return nil end
|
||||
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
|
||||
if fs.stat(value, "type") == "dir" then
|
||||
if m.message then
|
||||
m.message = m.message .. "\nerror!config path is a dir"
|
||||
else
|
||||
m.message = "error!config path is a dir"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
---- work dir
|
||||
o = s:option(Value, "workdir", translate("Work dir"), translate("AdGuardHome work dir include rules,audit log and database"))
|
||||
o.default = "/usr/bin/AdGuardHome"
|
||||
o.datatype = "string"
|
||||
o.optional = false
|
||||
o.rmempty = false
|
||||
o.validate = function(self, value)
|
||||
if value == "" then return nil end
|
||||
if fs.stat(value, "type") == "reg" then
|
||||
if m.message then
|
||||
m.message = m.message .. "\nerror!work dir is a file"
|
||||
else
|
||||
m.message = "error!work dir is a file"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
if string.sub(value, -1) == "/" then
|
||||
return string.sub(value, 1, -2)
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
---- log file
|
||||
o = s:option(Value, "logfile", translate("Runtime log file"), translate("AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"))
|
||||
o.datatype = "string"
|
||||
o.rmempty = true
|
||||
o.validate = function(self, value)
|
||||
if fs.stat(value, "type") == "dir" then fs.rmdir(value) end
|
||||
if fs.stat(value, "type") == "dir" then
|
||||
if m.message then
|
||||
m.message = m.message .. "\nerror!log file is a dir"
|
||||
else
|
||||
m.message = "error!log file is a dir"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
---- debug
|
||||
o = s:option(Flag, "verbose", translate("Verbose log"))
|
||||
o.default = 0
|
||||
o.optional = true
|
||||
|
||||
---- gfwlist
|
||||
local a = luci.sys.call("grep -m 1 -q programadd " .. configpath)
|
||||
if (a == 0) then
|
||||
a = "Added"
|
||||
else
|
||||
a = "Not added"
|
||||
end
|
||||
|
||||
o = s:option(Button, "gfwdel", translate("Del gfwlist"), translate(a))
|
||||
o.optional = true
|
||||
o.inputtitle = translate("Del")
|
||||
o.write = function()
|
||||
luci.sys.exec("sh /usr/share/AdGuardHome/gfw2adg.sh del 2>&1")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "AdGuardHome"))
|
||||
end
|
||||
|
||||
o = s:option(Button, "gfwadd", translate("Add gfwlist"), translate(a))
|
||||
o.optional = true
|
||||
o.inputtitle = translate("Add")
|
||||
o.write = function()
|
||||
luci.sys.exec("sh /usr/share/AdGuardHome/gfw2adg.sh 2>&1")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "AdGuardHome"))
|
||||
end
|
||||
|
||||
o = s:option(Value, "gfwupstream", translate("Gfwlist upstream dns server"), translate("Gfwlist domain upstream dns service") .. translate(a))
|
||||
o.default = "tcp://208.67.220.220:5353"
|
||||
o.datatype = "string"
|
||||
o.optional = true
|
||||
|
||||
---- chpass
|
||||
o = s:option(Value, "hashpass", translate("Change browser management password"), translate("Press load culculate model and culculate finally save/apply"))
|
||||
o.default = ""
|
||||
o.datatype = "string"
|
||||
o.template = "AdGuardHome/AdGuardHome_chpass"
|
||||
o.optional = true
|
||||
|
||||
---- upgrade protect
|
||||
o = s:option(MultiValue, "upprotect", translate("Keep files when system upgrade"))
|
||||
o:value("$binpath", translate("core bin"))
|
||||
o:value("$configpath", translate("config file"))
|
||||
o:value("$logfile", translate("log file"))
|
||||
o:value("$workdir/data/sessions.db", translate("sessions.db"))
|
||||
o:value("$workdir/data/stats.db", translate("stats.db"))
|
||||
o:value("$workdir/data/querylog.json", translate("querylog.json"))
|
||||
o:value("$workdir/data/filters", translate("filters"))
|
||||
o.widget = "checkbox"
|
||||
o.default = nil
|
||||
o.optional = true
|
||||
|
||||
---- wait net on boot
|
||||
o = s:option(Flag, "waitonboot", translate("On boot when network ok restart"))
|
||||
o.default = 1
|
||||
o.optional = true
|
||||
|
||||
---- backup workdir on shutdown
|
||||
local workdir = uci:get("AdGuardHome", "AdGuardHome", "workdir") or "/usr/bin/AdGuardHome"
|
||||
o = s:option(MultiValue, "backupfile", translate("Backup workdir files when shutdown"))
|
||||
o1 = s:option(Value, "backupwdpath", translate("Backup workdir path"))
|
||||
local name
|
||||
o:value("filters", "filters")
|
||||
o:value("stats.db", "stats.db")
|
||||
o:value("querylog.json", "querylog.json")
|
||||
o:value("sessions.db", "sessions.db")
|
||||
o1:depends("backupfile", "filters")
|
||||
o1:depends("backupfile", "stats.db")
|
||||
o1:depends("backupfile", "querylog.json")
|
||||
o1:depends("backupfile", "sessions.db")
|
||||
for name in fs.glob(workdir .. "/data/*") do
|
||||
name = fs.basename(name)
|
||||
if name ~= "filters" and name ~= "stats.db" and name ~= "querylog.json" and
|
||||
name ~= "sessions.db" then
|
||||
o:value(name, name)
|
||||
o1:depends("backupfile", name)
|
||||
end
|
||||
end
|
||||
o.widget = "checkbox"
|
||||
o.default = nil
|
||||
o.optional = false
|
||||
o.description = translate("Will be restore when workdir/data is empty")
|
||||
----backup workdir path
|
||||
o1.default = "/usr/bin/AdGuardHome"
|
||||
o1.datatype = "string"
|
||||
o1.optional = false
|
||||
o1.validate = function(self, value)
|
||||
if fs.stat(value, "type") == "reg" then
|
||||
if m.message then
|
||||
m.message = m.message .. "\nerror!backup dir is a file"
|
||||
else
|
||||
m.message = "error!backup dir is a file"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
if string.sub(value, -1) == "/" then
|
||||
return string.sub(value, 1, -2)
|
||||
else
|
||||
return value
|
||||
end
|
||||
end
|
||||
|
||||
----Crontab
|
||||
o = s:option(MultiValue, "crontab", translate("Crontab task"), translate("Please change time and args in crontab"))
|
||||
o:value("autoupdate", translate("Auto update core"))
|
||||
o:value("cutquerylog", translate("Auto tail querylog"))
|
||||
o:value("cutruntimelog", translate("Auto tail runtime log"))
|
||||
o:value("autohost", translate("Auto update ipv6 hosts and restart adh"))
|
||||
o:value("autogfw", translate("Auto update gfwlist and restart adh"))
|
||||
o.widget = "checkbox"
|
||||
o.default = nil
|
||||
o.optional = true
|
||||
|
||||
o = s:option(Value, "update_url", translate("Core Update URL"))
|
||||
o.default = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
|
||||
o.placeholder = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
|
||||
function m.on_commit(map)
|
||||
if (fs.access("/var/run/AdGserverdis")) then
|
||||
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||
return
|
||||
end
|
||||
local ucitracktest = uci:get("AdGuardHome", "AdGuardHome", "ucitracktest")
|
||||
if ucitracktest == "1" then
|
||||
return
|
||||
elseif ucitracktest == "0" then
|
||||
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||
else
|
||||
if (fs.access("/var/run/AdGlucitest")) then
|
||||
uci:set("AdGuardHome", "AdGuardHome", "ucitracktest", "0")
|
||||
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||
else
|
||||
fs.writefile("/var/run/AdGlucitest", "")
|
||||
if (ucitracktest == "2") then
|
||||
uci:set("AdGuardHome", "AdGuardHome", "ucitracktest", "1")
|
||||
else
|
||||
uci:set("AdGuardHome", "AdGuardHome", "ucitracktest", "2")
|
||||
end
|
||||
end
|
||||
uci:commit("AdGuardHome")
|
||||
end
|
||||
end
|
||||
return m
|
@ -1,16 +0,0 @@
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local f, t
|
||||
f = SimpleForm("logview")
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 20
|
||||
t.template = "AdGuardHome/log"
|
||||
t.readonly = "readonly"
|
||||
local logfile = uci:get("AdGuardHome", "AdGuardHome", "logfile") or ""
|
||||
t.timereplace = (logfile ~= "syslog" and logfile ~= "")
|
||||
t.pollcheck = logfile ~= ""
|
||||
fs.writefile("/var/run/lucilogpos", "0")
|
||||
return f
|
@ -1,100 +0,0 @@
|
||||
local m, s, o
|
||||
local fs = require "nixio.fs"
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local sys = require "luci.sys"
|
||||
require("string")
|
||||
require("io")
|
||||
require("table")
|
||||
function gen_template_config()
|
||||
local b
|
||||
local d = ""
|
||||
local file = "/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
if not fs.access(file) then
|
||||
file = "/tmp/resolv.conf.auto"
|
||||
end
|
||||
for cnt in io.lines(file) do
|
||||
b = string.match(cnt, "^[^#]*nameserver%s+([^%s]+)$")
|
||||
if (b ~= nil) then d = d .. " - " .. b .. "\n" end
|
||||
end
|
||||
local f = io.open("/usr/share/AdGuardHome/AdGuardHome_template.yaml", "r+")
|
||||
local tbl = {}
|
||||
local a = ""
|
||||
while (1) do
|
||||
a = f:read("*l")
|
||||
if (a == "#bootstrap_dns") then
|
||||
a = d
|
||||
elseif (a == "#upstream_dns") then
|
||||
a = d
|
||||
elseif (a == nil) then
|
||||
break
|
||||
end
|
||||
table.insert(tbl, a)
|
||||
end
|
||||
f:close()
|
||||
return table.concat(tbl, "\n")
|
||||
end
|
||||
|
||||
m = Map("AdGuardHome")
|
||||
local configpath = uci:get("AdGuardHome", "AdGuardHome", "configpath")
|
||||
local binpath = uci:get("AdGuardHome", "AdGuardHome", "binpath")
|
||||
s = m:section(TypedSection, "AdGuardHome")
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
--- config
|
||||
o = s:option(TextValue, "escconf")
|
||||
o.rows = 66
|
||||
o.wrap = "off"
|
||||
o.rmempty = true
|
||||
o.cfgvalue = function(self, section)
|
||||
return fs.readfile("/tmp/AdGuardHometmpconfig.yaml") or fs.readfile(configpath) or gen_template_config() or ""
|
||||
end
|
||||
o.validate = function(self, value)
|
||||
fs.writefile("/tmp/AdGuardHometmpconfig.yaml", value:gsub("\r\n", "\n"))
|
||||
if fs.access(binpath) then
|
||||
if (sys.call(binpath .. " -c /tmp/AdGuardHometmpconfig.yaml --check-config 2> /tmp/AdGuardHometest.log") == 0) then return value end
|
||||
else
|
||||
return value
|
||||
end
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "AdGuardHome", "manual"))
|
||||
return nil
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
fs.move("/tmp/AdGuardHometmpconfig.yaml", configpath)
|
||||
end
|
||||
o.remove = function(self, section, value) fs.writefile(configpath, "") end
|
||||
|
||||
--- js and reload button
|
||||
o = s:option(DummyValue, "")
|
||||
o.anonymous = true
|
||||
o.template = "AdGuardHome/yamleditor"
|
||||
if not fs.access(binpath) then
|
||||
o.description = translate("WARNING!!! no bin found apply config will not be test")
|
||||
end
|
||||
|
||||
--- log
|
||||
if (fs.access("/tmp/AdGuardHometmpconfig.yaml")) then
|
||||
local c = fs.readfile("/tmp/AdGuardHometest.log")
|
||||
if (c ~= "") then
|
||||
o = s:option(TextValue, "")
|
||||
o.readonly = true
|
||||
o.rows = 5
|
||||
o.rmempty = true
|
||||
o.name = ""
|
||||
o.cfgvalue = function(self, section)
|
||||
return fs.readfile("/tmp/AdGuardHometest.log")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function m.on_commit(map)
|
||||
local ucitracktest = uci:get("AdGuardHome", "AdGuardHome", "ucitracktest")
|
||||
if ucitracktest == "1" then
|
||||
return
|
||||
elseif ucitracktest == "0" then
|
||||
io.popen("/etc/init.d/AdGuardHome reload &")
|
||||
else
|
||||
fs.writefile("/var/run/AdGlucitest", "")
|
||||
end
|
||||
end
|
||||
return m
|
@ -1,78 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<%local fs=require"nixio.fs"%>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_button" value="<%:Update core version%>" onclick=" return apply_update() "/>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="apply_forceupdate_button" value="<%:Force update%>" onclick=" return apply_forceupdate()" style="display:none"/>
|
||||
<% if self.showfastconfig then %>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="to_configpage" value="<%:Fast config%>" onclick="location.href='<%=url([[admin]], [[services]], [[AdGuardHome]], [[manual]])%>'"/>
|
||||
<%end%>
|
||||
<div id="logview" style="display:none">
|
||||
<input type="checkbox" id="reversetag" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;"><%:reverse%></input>
|
||||
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:block;" data-update="change" rows="5" cols="60" readonly="readonly" > </textarea>
|
||||
</div>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var updatebtn = document.getElementById('apply_update_button');
|
||||
var forceupdatebtn = document.getElementById('apply_forceupdate_button');
|
||||
var islogreverse = false;
|
||||
function apply_forceupdate(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[doupdate]])%>',{ force: 1 },function(x, data){}
|
||||
);
|
||||
updatebtn.disabled = true;
|
||||
poll_check();
|
||||
return
|
||||
}
|
||||
function reverselog(){
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||
if (islogreverse){
|
||||
islogreverse=false;
|
||||
}else{
|
||||
islogreverse=true;
|
||||
}
|
||||
return
|
||||
}
|
||||
function apply_update(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[doupdate]])%>',null,function(x, data){}
|
||||
);
|
||||
updatebtn.disabled = true;
|
||||
updatebtn.value = '<%:Check...%>';
|
||||
forceupdatebtn.style.display="inline"
|
||||
poll_check();
|
||||
return
|
||||
}
|
||||
function poll_check(){
|
||||
var tag = document.getElementById('logview');
|
||||
tag.style.display="block"
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[check]])%>', null,
|
||||
function(x, data) {
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
if (x.responseText && lv) {
|
||||
if (x.responseText=="\u0000"){
|
||||
for(j = 0,len=this.XHR._q.length; j < len; j++) {
|
||||
if (this.XHR._q[j].url == '<%=url([[admin]], [[services]], [[AdGuardHome]], [[check]])%>'){
|
||||
this.XHR._q.splice(j,1);
|
||||
updatebtn.disabled = false;
|
||||
updatebtn.value = '<%:Updated%>';
|
||||
break;
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if (islogreverse){
|
||||
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML += x.responseText;
|
||||
}
|
||||
}
|
||||
}
|
||||
);}
|
||||
<% if fs.access("/var/run/update_core") then %>
|
||||
updatebtn.disabled = true;
|
||||
updatebtn.value = '<%:Check...%>';
|
||||
forceupdatebtn.style.display="inline"
|
||||
poll_check();
|
||||
<%elseif fs.access("/var/run/update_core_error") then %>
|
||||
poll_check();
|
||||
<%end%>
|
||||
//]]>
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -1,49 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function chpass(btn)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:loading...%>';
|
||||
if (typeof bcryptloaded == 'undefined' ){
|
||||
var theHead = document.getElementsByTagName('head').item(0);
|
||||
//创建脚本的dom对象实例
|
||||
var myScript = document.createElement('script');
|
||||
myScript.src = '<%=resource%>/twin-bcrypt.min.js'; //指定脚本路径
|
||||
myScript.type = 'text/javascript'; //指定脚本类型
|
||||
myScript.defer = true; //程序下载完后再解析和执行
|
||||
theHead.appendChild(myScript);
|
||||
bcryptloaded=1;
|
||||
btn.value = '<%:Culculate%>';
|
||||
btn.disabled = false;
|
||||
return
|
||||
}
|
||||
var lv = document.getElementById('cbid.AdGuardHome.AdGuardHome.hashpass');
|
||||
if (lv.value != ""){
|
||||
var hash = TwinBcrypt.hashSync(lv.value);
|
||||
lv.value=hash;
|
||||
btn.value = '<%:Please save/apply%>';
|
||||
}else{
|
||||
btn.value = '<%:is empty%>';
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
//]]>
|
||||
</script>
|
||||
<input data-update="change"<%=
|
||||
attr("id", cbid) ..
|
||||
attr("name", cbid) ..
|
||||
attr("type", self.password and "password" or "text") ..
|
||||
attr("class", self.password and "cbi-input-password" or "cbi-input-text") ..
|
||||
attr("value", self:cfgvalue(section) or self.default) ..
|
||||
ifattr(self.size, "size") ..
|
||||
ifattr(self.placeholder, "placeholder") ..
|
||||
ifattr(self.readonly, "readonly") ..
|
||||
ifattr(self.maxlength, "maxlength") ..
|
||||
ifattr(self.datatype, "data-type", self.datatype) ..
|
||||
ifattr(self.datatype, "data-optional", self.optional or self.rmempty) ..
|
||||
ifattr(self.combobox_manual, "data-manual", self.combobox_manual) ..
|
||||
ifattr(#self.keylist > 0, "data-choices", { self.keylist, self.vallist })
|
||||
%> />
|
||||
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="cbid.AdGuardHome.AdGuardHome.applychpass" value="<%:Load culculate model%>" onclick="return chpass(this)"/>
|
||||
<%+cbi/valuefooter%>
|
@ -1,27 +0,0 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('AdGuardHome_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
tb.innerHTML = '<em><b><font color=green>AdGuardHome <%:RUNNING%></font></b></em>';
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>AdGuardHome <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
if (data.redirect)
|
||||
{
|
||||
tb.innerHTML+='<em><b><font color=green><%:Redirected%></font></b></em>'
|
||||
} else {
|
||||
tb.innerHTML+='<em><b><font color=red><%:Not redirect%></font></b></em>'
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="AdGuardHome_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -1,110 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<input type="checkbox" name="NAME" value="reverse" onclick=" return reverselog()" style="vertical-align:middle;height: auto;" checked><%:reverse%></input>
|
||||
<%if self.timereplace then%>
|
||||
<input type="checkbox" name="NAME" value="localtime" onclick=" return chlogtime()" style="vertical-align:middle;height: auto;" checked><%:localtime%></input><br>
|
||||
<%end%>
|
||||
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" > </textarea>
|
||||
<input type="button" class="cbi-button cbi-button-apply" id="apply_update_button" value="<%:dellog%>" onclick=" return apply_del_log() "/>
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:download log%>" style=" display:inline;" onclick=" return download_log()" />
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var islogreverse = true;
|
||||
var isutc2local = <%=tostring(self.timereplace)%>;
|
||||
function createAndDownloadFile(fileName, content) {
|
||||
var aTag = document.createElement('a');
|
||||
var blob = new Blob([content]);
|
||||
aTag.download = fileName;
|
||||
aTag.href = URL.createObjectURL(blob);
|
||||
aTag.click();
|
||||
URL.revokeObjectURL(blob);
|
||||
}
|
||||
function download_log(){
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
var dt = new Date();
|
||||
var timestamp = (dt.getMonth()+1)+"-"+dt.getDate()+"-"+dt.getHours()+"_"+dt.getMinutes();
|
||||
createAndDownloadFile("AdGuardHome"+timestamp+".log",lv.innerHTML)
|
||||
return
|
||||
}
|
||||
function apply_del_log(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[dodellog]])%>',null,function(x, data){
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML="";
|
||||
}
|
||||
);
|
||||
return
|
||||
}
|
||||
function chlogtime(){
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
if (isutc2local){
|
||||
lv.innerHTML=line_toUTC(lv.innerHTML).join('\n');
|
||||
isutc2local=false;
|
||||
}else{
|
||||
lv.innerHTML=line_tolocal(lv.innerHTML).join('\n');
|
||||
isutc2local=true;
|
||||
}
|
||||
return
|
||||
}
|
||||
function reverselog(){
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
|
||||
if (islogreverse){
|
||||
islogreverse=false;
|
||||
}else{
|
||||
islogreverse=true;
|
||||
}
|
||||
return
|
||||
}
|
||||
function p(s) {
|
||||
return s < 10 ? '0' + s: s;
|
||||
}
|
||||
function line_tolocal(str){
|
||||
var strt=new Array();
|
||||
str.trim().split('\n').forEach(function(v, i) {
|
||||
var dt = new Date(v.substring(0,19)+" UTC");
|
||||
if (dt != "Invalid Date"){
|
||||
strt[i]=dt.getFullYear()+"/"+p(dt.getMonth()+1)+"/"+p(dt.getDate())+" "+p(dt.getHours())+":"+p(dt.getMinutes())+":"+p(dt.getSeconds())+v.substring(19);
|
||||
}else{
|
||||
strt[i]=v;}})
|
||||
return strt
|
||||
}
|
||||
function line_toUTC(str){
|
||||
var strt=new Array();
|
||||
str.trim().split('\n').forEach(function(v, i) {
|
||||
var dt = new Date(v.substring(0,19))
|
||||
if (dt != "Invalid Date"){
|
||||
strt[i]=dt.getUTCFullYear()+"/"+p(dt.getUTCMonth()+1)+"/"+p(dt.getUTCDate())+" "+p(dt.getUTCHours())+":"+p(dt.getUTCMinutes())+":"+p(dt.getUTCSeconds())+v.substring(19);
|
||||
}else{
|
||||
strt[i]=v;}})
|
||||
return strt
|
||||
}
|
||||
function poll_check(){
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[getlog]])%>', null,
|
||||
function(x, data) {
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
if (x.responseText && lv) {
|
||||
if (isutc2local)
|
||||
{
|
||||
var lines=line_tolocal(x.responseText);
|
||||
if (islogreverse){
|
||||
lv.innerHTML = lines.reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML += lines.join('\n');
|
||||
}
|
||||
}else{
|
||||
if (islogreverse){
|
||||
lv.innerHTML = x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
|
||||
}else{
|
||||
lv.innerHTML += x.responseText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);}
|
||||
<%if self.pollcheck then%>
|
||||
poll_check();
|
||||
<%else%>
|
||||
var lv = document.getElementById('cbid.logview.1.conf');
|
||||
lv.innerHTML="<%:Please add log path in config to enable log%>"
|
||||
<%end%>
|
||||
//]]>
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -1,39 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script src="/luci-static/resources/codemirror/lib/codemirror.js"></script>
|
||||
<link rel="stylesheet" href="/luci-static/resources/codemirror/lib/codemirror.css"/>
|
||||
<script src="/luci-static/resources/codemirror/mode/yaml/yaml.js"></script>
|
||||
<link rel="stylesheet" href="/luci-static/resources/codemirror/theme/dracula.css"/>
|
||||
<link rel="stylesheet" href="/luci-static/resources/codemirror/addon/fold/foldgutter.css"/>
|
||||
<script src="/luci-static/resources/codemirror/addon/fold/foldcode.js"></script>
|
||||
<script src="/luci-static/resources/codemirror/addon/fold/foldgutter.js"></script>
|
||||
<script src="/luci-static/resources/codemirror/addon/fold/indent-fold.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("cbid.AdGuardHome.AdGuardHome.escconf"), {
|
||||
mode: "text/yaml", //实现groovy代码高亮
|
||||
styleActiveLine: true,
|
||||
lineNumbers: true, //显示行号
|
||||
theme: "dracula", //设置主题
|
||||
lineWrapping: true, //代码折叠
|
||||
foldGutter: true,
|
||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
|
||||
matchBrackets: true //括号匹配
|
||||
}
|
||||
);
|
||||
function reload_config(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[reloadconfig]])%>', null,
|
||||
function(x, data) {
|
||||
location.reload();
|
||||
});}
|
||||
function use_template(){
|
||||
XHR.get('<%=url([[admin]], [[services]], [[AdGuardHome]], [[gettemplateconfig]])%>', null,
|
||||
function(x, data) {
|
||||
editor.setValue(x.responseText)
|
||||
});}
|
||||
//]]>
|
||||
</script>
|
||||
<%fs=require"nixio.fs"%>
|
||||
<%if fs.access("/tmp/AdGuardHometmpconfig.yaml") then%>
|
||||
<input type="button" id="apply_update_button" value="<%:Reload Config%>" onclick=" return reload_config() "/>
|
||||
<%end%>
|
||||
<input type="button" id="template_button" value="<%:Use template%>" onclick=" return use_template() "/>
|
||||
<%+cbi/valuefooter%>
|
@ -1,275 +0,0 @@
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome
|
||||
msgid "Base Setting"
|
||||
msgstr "基础设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Manual Config"
|
||||
msgstr "手动设置"
|
||||
|
||||
msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server."
|
||||
msgstr "免费开源, 功能强大的网络广告和跟踪程序拦截 DNS 服务器"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Redirected"
|
||||
msgstr "已重定向"
|
||||
|
||||
msgid "Not redirect"
|
||||
msgstr "未重定向"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "获取数据中..."
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Browser management port"
|
||||
msgstr "网页管理端口"
|
||||
|
||||
msgid "Upgrade Core"
|
||||
msgstr "更新核心"
|
||||
|
||||
msgid "Update core version"
|
||||
msgstr "更新核心版本"
|
||||
|
||||
msgid "Check..."
|
||||
msgstr "检查中 ..."
|
||||
|
||||
msgid "Updated"
|
||||
msgstr "已更新"
|
||||
|
||||
msgid "Force update"
|
||||
msgstr "强制更新核心"
|
||||
|
||||
msgid "Fast config"
|
||||
msgstr "快速配置"
|
||||
|
||||
msgid "Core Version"
|
||||
msgstr "核心版本"
|
||||
|
||||
msgid "Latest Version"
|
||||
msgstr "最新版"
|
||||
|
||||
msgid "Beta Version"
|
||||
msgstr "测试版"
|
||||
|
||||
msgid "Current core version:"
|
||||
msgstr "当前核心版本:"
|
||||
|
||||
msgid "no config"
|
||||
msgstr "没有配置文件"
|
||||
|
||||
msgid "no core"
|
||||
msgstr "没有核心"
|
||||
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "none"
|
||||
msgstr "无"
|
||||
|
||||
msgid "Run as dnsmasq upstream server"
|
||||
msgstr "作为 dnsmasq 的上游服务器"
|
||||
|
||||
msgid "Redirect 53 port to AdGuardHome"
|
||||
msgstr "重定向 53 端口到 AdGuardHome"
|
||||
|
||||
msgid "Use port 53 replace dnsmasq"
|
||||
msgstr "使用 53 端口替换 dnsmasq"
|
||||
|
||||
msgid "AdGuardHome redirect mode"
|
||||
msgstr "AdGuardHome 重定向模式"
|
||||
|
||||
msgid "Bin Path"
|
||||
msgstr "执行文件路径"
|
||||
|
||||
msgid "AdGuardHome Bin path if no bin will auto download"
|
||||
msgstr "AdGuardHome 执行文件路径, 启动时如果没有检测到执行文件将自动下载"
|
||||
|
||||
msgid "use upx to compress bin after download"
|
||||
msgstr "UPX 压缩核心"
|
||||
|
||||
msgid "compress faster"
|
||||
msgstr "快速压缩"
|
||||
|
||||
msgid "compress better"
|
||||
msgstr "更好的压缩"
|
||||
|
||||
msgid "compress best(can be slow for big files)"
|
||||
msgstr "最好的压缩[大文件可能很慢]"
|
||||
|
||||
msgid "try all available compression methods & filters [slow]"
|
||||
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
|
||||
|
||||
msgid "try even more compression variants [very slow]"
|
||||
msgstr "尝试更多变体压缩手段[很慢]"
|
||||
|
||||
msgid "bin use less space,but may have compatibility issues"
|
||||
msgstr "减小执行文件空间占用, 压缩后存在兼容性问题"
|
||||
|
||||
msgid "Config Path"
|
||||
msgstr "配置文件路径"
|
||||
|
||||
msgid "AdGuardHome config path"
|
||||
msgstr "AdGuardHome 配置文件路径"
|
||||
|
||||
msgid "Work dir"
|
||||
msgstr "工作目录"
|
||||
|
||||
msgid "AdGuardHome work dir include rules,audit log and database"
|
||||
msgstr "AdGuardHome 工作目录包含规则, 审计日志和数据库"
|
||||
|
||||
msgid "Runtime log file"
|
||||
msgstr "运行日志路径"
|
||||
|
||||
msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
|
||||
msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志"
|
||||
|
||||
msgid "Verbose log"
|
||||
msgstr "输出详细日志"
|
||||
|
||||
msgid "Add gfwlist"
|
||||
msgstr "添加 GFW 列表"
|
||||
|
||||
msgid "Add"
|
||||
msgstr "添加"
|
||||
|
||||
msgid "Added"
|
||||
msgstr "已添加"
|
||||
|
||||
msgid "Not added"
|
||||
msgstr "未添加"
|
||||
|
||||
msgid "Del gfwlist"
|
||||
msgstr "删除 GFW 列表"
|
||||
|
||||
msgid "Del"
|
||||
msgstr "删除"
|
||||
|
||||
msgid "Gfwlist upstream dns server"
|
||||
msgstr "GFW 列表上游服务器"
|
||||
|
||||
msgid "Gfwlist domain upstream dns service"
|
||||
msgstr "GFW 列表域名上游服务器"
|
||||
|
||||
msgid "Change browser management password"
|
||||
msgstr "更改网页登录密码"
|
||||
|
||||
msgid "Culculate"
|
||||
msgstr "计算"
|
||||
|
||||
msgid "Load culculate model"
|
||||
msgstr "载入计算模块"
|
||||
|
||||
msgid "loading..."
|
||||
msgstr "载入中 ..."
|
||||
|
||||
msgid "Please save/apply"
|
||||
msgstr "请点击[保存/应用]"
|
||||
|
||||
msgid "is empty"
|
||||
msgstr "为空"
|
||||
|
||||
msgid "Press load culculate model and culculate finally save/apply"
|
||||
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||
|
||||
msgid "Keep files when system upgrade"
|
||||
msgstr "系统升级时保留文件"
|
||||
|
||||
msgid "core bin"
|
||||
msgstr "核心执行文件"
|
||||
|
||||
msgid "config file"
|
||||
msgstr "配置文件"
|
||||
|
||||
msgid "log file"
|
||||
msgstr "日志文件"
|
||||
|
||||
msgid "querylog.json"
|
||||
msgstr "审计日志.json"
|
||||
#
|
||||
msgid "On boot when network ok restart"
|
||||
msgstr "开机后网络就绪时重启"
|
||||
|
||||
msgid "Backup workdir files when shutdown"
|
||||
msgstr "在关机时备份以下文件"
|
||||
|
||||
msgid "Will be restore when workdir/data is empty"
|
||||
msgstr "备份将在 工作目录/data 为空的时候恢复"
|
||||
|
||||
msgid "Backup workdir path"
|
||||
msgstr "工作目录备份路径"
|
||||
|
||||
msgid "Crontab task"
|
||||
msgstr "计划任务"
|
||||
|
||||
msgid "Auto update core"
|
||||
msgstr "自动升级核心"
|
||||
|
||||
msgid "Auto tail querylog"
|
||||
msgstr "自动截短查询日志"
|
||||
|
||||
msgid "Auto tail runtime log"
|
||||
msgstr "自动截短运行日志"
|
||||
|
||||
msgid "Auto update ipv6 hosts and restart adh"
|
||||
msgstr "自动更新 IPv6 主机并重启 AdGuardHome"
|
||||
|
||||
msgid "Auto update gfwlist and restart adh"
|
||||
msgstr "自动更新 GFW 列表并重启 AdGuardHome"
|
||||
|
||||
msgid "Please change time and args in crontab"
|
||||
msgstr "请在计划任务中修改时间和参数"
|
||||
|
||||
msgid "Core Update URL"
|
||||
msgstr "核心更新地址"
|
||||
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome/log/
|
||||
msgid "reverse"
|
||||
msgstr "逆序"
|
||||
|
||||
msgid "localtime"
|
||||
msgstr "本地时间"
|
||||
|
||||
msgid "Please add log path in config to enable log"
|
||||
msgstr "请在设置里填写运行日志路径以启用日志"
|
||||
|
||||
msgid "dellog"
|
||||
msgstr "删除日志"
|
||||
|
||||
msgid "download log"
|
||||
msgstr "下载日志"
|
||||
|
||||
#/cgi-bin/luci//admin/services/AdGuardHome/manual/
|
||||
msgid "Use template"
|
||||
msgstr "使用模板"
|
||||
|
||||
msgid "Reload Config"
|
||||
msgstr "重新载入配置"
|
||||
|
||||
msgid "WARNING!!! no bin found apply config will not be test"
|
||||
msgstr "警告!!! 未找到执行文件, 提交配置将不会进行校验"
|
||||
|
||||
msgid "Change browser management username"
|
||||
msgstr "更改网页登录用户名"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Check Config"
|
||||
msgstr "检查配置"
|
||||
|
||||
msgid "unknown"
|
||||
msgstr "未知"
|
||||
|
||||
msgid "Keep database when system upgrade"
|
||||
msgstr "系统升级时保留数据"
|
||||
|
||||
msgid "Boot delay until network ok"
|
||||
msgstr "开机时等到网络就绪后再启动"
|
@ -1,275 +0,0 @@
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome
|
||||
msgid "Base Setting"
|
||||
msgstr "基础设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Manual Config"
|
||||
msgstr "手动设置"
|
||||
|
||||
msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server."
|
||||
msgstr "免费开源, 功能强大的网络广告和跟踪程序拦截 DNS 服务器"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Redirected"
|
||||
msgstr "已重定向"
|
||||
|
||||
msgid "Not redirect"
|
||||
msgstr "未重定向"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "获取数据中..."
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Browser management port"
|
||||
msgstr "网页管理端口"
|
||||
|
||||
msgid "Upgrade Core"
|
||||
msgstr "更新核心"
|
||||
|
||||
msgid "Update core version"
|
||||
msgstr "更新核心版本"
|
||||
|
||||
msgid "Check..."
|
||||
msgstr "检查中 ..."
|
||||
|
||||
msgid "Updated"
|
||||
msgstr "已更新"
|
||||
|
||||
msgid "Force update"
|
||||
msgstr "强制更新核心"
|
||||
|
||||
msgid "Fast config"
|
||||
msgstr "快速配置"
|
||||
|
||||
msgid "Core Version"
|
||||
msgstr "核心版本"
|
||||
|
||||
msgid "Latest Version"
|
||||
msgstr "最新版"
|
||||
|
||||
msgid "Beta Version"
|
||||
msgstr "测试版"
|
||||
|
||||
msgid "Current core version:"
|
||||
msgstr "当前核心版本:"
|
||||
|
||||
msgid "no config"
|
||||
msgstr "没有配置文件"
|
||||
|
||||
msgid "no core"
|
||||
msgstr "没有核心"
|
||||
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "none"
|
||||
msgstr "无"
|
||||
|
||||
msgid "Run as dnsmasq upstream server"
|
||||
msgstr "作为 dnsmasq 的上游服务器"
|
||||
|
||||
msgid "Redirect 53 port to AdGuardHome"
|
||||
msgstr "重定向 53 端口到 AdGuardHome"
|
||||
|
||||
msgid "Use port 53 replace dnsmasq"
|
||||
msgstr "使用 53 端口替换 dnsmasq"
|
||||
|
||||
msgid "AdGuardHome redirect mode"
|
||||
msgstr "AdGuardHome 重定向模式"
|
||||
|
||||
msgid "Bin Path"
|
||||
msgstr "执行文件路径"
|
||||
|
||||
msgid "AdGuardHome Bin path if no bin will auto download"
|
||||
msgstr "AdGuardHome 执行文件路径, 启动时如果没有检测到执行文件将自动下载"
|
||||
|
||||
msgid "use upx to compress bin after download"
|
||||
msgstr "UPX 压缩核心"
|
||||
|
||||
msgid "compress faster"
|
||||
msgstr "快速压缩"
|
||||
|
||||
msgid "compress better"
|
||||
msgstr "更好的压缩"
|
||||
|
||||
msgid "compress best(can be slow for big files)"
|
||||
msgstr "最好的压缩[大文件可能很慢]"
|
||||
|
||||
msgid "try all available compression methods & filters [slow]"
|
||||
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
|
||||
|
||||
msgid "try even more compression variants [very slow]"
|
||||
msgstr "尝试更多变体压缩手段[很慢]"
|
||||
|
||||
msgid "bin use less space,but may have compatibility issues"
|
||||
msgstr "减小执行文件空间占用, 压缩后存在兼容性问题"
|
||||
|
||||
msgid "Config Path"
|
||||
msgstr "配置文件路径"
|
||||
|
||||
msgid "AdGuardHome config path"
|
||||
msgstr "AdGuardHome 配置文件路径"
|
||||
|
||||
msgid "Work dir"
|
||||
msgstr "工作目录"
|
||||
|
||||
msgid "AdGuardHome work dir include rules,audit log and database"
|
||||
msgstr "AdGuardHome 工作目录包含规则, 审计日志和数据库"
|
||||
|
||||
msgid "Runtime log file"
|
||||
msgstr "运行日志路径"
|
||||
|
||||
msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
|
||||
msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志"
|
||||
|
||||
msgid "Verbose log"
|
||||
msgstr "输出详细日志"
|
||||
|
||||
msgid "Add gfwlist"
|
||||
msgstr "添加 GFW 列表"
|
||||
|
||||
msgid "Add"
|
||||
msgstr "添加"
|
||||
|
||||
msgid "Added"
|
||||
msgstr "已添加"
|
||||
|
||||
msgid "Not added"
|
||||
msgstr "未添加"
|
||||
|
||||
msgid "Del gfwlist"
|
||||
msgstr "删除 GFW 列表"
|
||||
|
||||
msgid "Del"
|
||||
msgstr "删除"
|
||||
|
||||
msgid "Gfwlist upstream dns server"
|
||||
msgstr "GFW 列表上游服务器"
|
||||
|
||||
msgid "Gfwlist domain upstream dns service"
|
||||
msgstr "GFW 列表域名上游服务器"
|
||||
|
||||
msgid "Change browser management password"
|
||||
msgstr "更改网页登录密码"
|
||||
|
||||
msgid "Culculate"
|
||||
msgstr "计算"
|
||||
|
||||
msgid "Load culculate model"
|
||||
msgstr "载入计算模块"
|
||||
|
||||
msgid "loading..."
|
||||
msgstr "载入中 ..."
|
||||
|
||||
msgid "Please save/apply"
|
||||
msgstr "请点击[保存/应用]"
|
||||
|
||||
msgid "is empty"
|
||||
msgstr "为空"
|
||||
|
||||
msgid "Press load culculate model and culculate finally save/apply"
|
||||
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
|
||||
|
||||
msgid "Keep files when system upgrade"
|
||||
msgstr "系统升级时保留文件"
|
||||
|
||||
msgid "core bin"
|
||||
msgstr "核心执行文件"
|
||||
|
||||
msgid "config file"
|
||||
msgstr "配置文件"
|
||||
|
||||
msgid "log file"
|
||||
msgstr "日志文件"
|
||||
|
||||
msgid "querylog.json"
|
||||
msgstr "审计日志.json"
|
||||
#
|
||||
msgid "On boot when network ok restart"
|
||||
msgstr "开机后网络就绪时重启"
|
||||
|
||||
msgid "Backup workdir files when shutdown"
|
||||
msgstr "在关机时备份以下文件"
|
||||
|
||||
msgid "Will be restore when workdir/data is empty"
|
||||
msgstr "备份将在 工作目录/data 为空的时候恢复"
|
||||
|
||||
msgid "Backup workdir path"
|
||||
msgstr "工作目录备份路径"
|
||||
|
||||
msgid "Crontab task"
|
||||
msgstr "计划任务"
|
||||
|
||||
msgid "Auto update core"
|
||||
msgstr "自动升级核心"
|
||||
|
||||
msgid "Auto tail querylog"
|
||||
msgstr "自动截短查询日志"
|
||||
|
||||
msgid "Auto tail runtime log"
|
||||
msgstr "自动截短运行日志"
|
||||
|
||||
msgid "Auto update ipv6 hosts and restart adh"
|
||||
msgstr "自动更新 IPv6 主机并重启 AdGuardHome"
|
||||
|
||||
msgid "Auto update gfwlist and restart adh"
|
||||
msgstr "自动更新 GFW 列表并重启 AdGuardHome"
|
||||
|
||||
msgid "Please change time and args in crontab"
|
||||
msgstr "请在计划任务中修改时间和参数"
|
||||
|
||||
msgid "Core Update URL"
|
||||
msgstr "核心更新地址"
|
||||
|
||||
#/cgi-bin/luci/admin/services/AdGuardHome/log/
|
||||
msgid "reverse"
|
||||
msgstr "逆序"
|
||||
|
||||
msgid "localtime"
|
||||
msgstr "本地时间"
|
||||
|
||||
msgid "Please add log path in config to enable log"
|
||||
msgstr "请在设置里填写运行日志路径以启用日志"
|
||||
|
||||
msgid "dellog"
|
||||
msgstr "删除日志"
|
||||
|
||||
msgid "download log"
|
||||
msgstr "下载日志"
|
||||
|
||||
#/cgi-bin/luci//admin/services/AdGuardHome/manual/
|
||||
msgid "Use template"
|
||||
msgstr "使用模板"
|
||||
|
||||
msgid "Reload Config"
|
||||
msgstr "重新载入配置"
|
||||
|
||||
msgid "WARNING!!! no bin found apply config will not be test"
|
||||
msgstr "警告!!! 未找到执行文件, 提交配置将不会进行校验"
|
||||
|
||||
msgid "Change browser management username"
|
||||
msgstr "更改网页登录用户名"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Check Config"
|
||||
msgstr "检查配置"
|
||||
|
||||
msgid "unknown"
|
||||
msgstr "未知"
|
||||
|
||||
msgid "Keep database when system upgrade"
|
||||
msgstr "系统升级时保留数据"
|
||||
|
||||
msgid "Boot delay until network ok"
|
||||
msgstr "开机时等到网络就绪后再启动"
|
@ -1,11 +0,0 @@
|
||||
config AdGuardHome 'AdGuardHome'
|
||||
option enabled '0'
|
||||
option httpport '3000'
|
||||
option redirect 'dnsmasq-upstream'
|
||||
option configpath '/etc/config/AdGuardHome.yaml'
|
||||
option workdir '/usr/bin/AdGuardHome'
|
||||
option logfile '/tmp/AdGuardHome.log'
|
||||
option verbose '0'
|
||||
option binpath '/tmp/AdGuardHome/AdGuardHome'
|
||||
option upxflag ''
|
||||
|
@ -1,615 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=95
|
||||
STOP=01
|
||||
|
||||
CONFIGURATION=AdGuardHome
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
EXTRA_COMMANDS="do_redirect testbackup test_crontab force_reload isrunning"
|
||||
EXTRA_HELP=" do_redirect 0 or 1\
|
||||
testbackup backup or restore\
|
||||
test_crontab
|
||||
force_reload
|
||||
isrunning"
|
||||
set_forward_dnsmasq() {
|
||||
local PORT="$1"
|
||||
addr="127.0.0.1#$PORT"
|
||||
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
return
|
||||
fi
|
||||
uci delete dhcp.@dnsmasq[0].server 2>/dev/null
|
||||
uci add_list dhcp.@dnsmasq[0].server=$addr
|
||||
for server in $OLD_SERVER; do
|
||||
if [ "$server" = "$addr" ]; then
|
||||
continue
|
||||
fi
|
||||
uci add_list dhcp.@dnsmasq[0].server=$server
|
||||
done
|
||||
uci delete dhcp.@dnsmasq[0].resolvfile 2>/dev/null
|
||||
uci set dhcp.@dnsmasq[0].noresolv=1
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
stop_forward_dnsmasq() {
|
||||
local OLD_PORT="$1"
|
||||
addr="127.0.0.1#$OLD_PORT"
|
||||
OLD_SERVER="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
echo $OLD_SERVER | grep "^$addr" >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
|
||||
addrlist="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
|
||||
if [ -z "$addrlist" ] ; then
|
||||
resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
|
||||
[ ! -f "$resolvfile" ] && resolvfile="/tmp/resolv.conf.auto"
|
||||
uci set dhcp.@dnsmasq[0].resolvfile="$resolvfile" 2>/dev/null
|
||||
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
|
||||
fi
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
set_iptable() {
|
||||
local ipv6_server=$1
|
||||
local tcp_server=$2
|
||||
uci -q batch <<-EOF >/dev/null 2>&1
|
||||
delete firewall.AdGuardHome
|
||||
set firewall.AdGuardHome=include
|
||||
set firewall.AdGuardHome.type=script
|
||||
set firewall.AdGuardHome.path=/usr/share/AdGuardHome/firewall.start
|
||||
set firewall.AdGuardHome.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
[ "$tcp_server" == "1" ] && iptables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p tcp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
iptables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p udp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
|
||||
[ "$ipv6_server" == 0 ] && return
|
||||
|
||||
[ "$tcp_server" == "1" ] && ip6tables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p tcp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
ip6tables -t nat -I PREROUTING 1 -m comment --comment "AdGuardHome" -p udp --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT
|
||||
}
|
||||
|
||||
clear_iptable() {
|
||||
uci -q batch <<-EOF >/dev/null 2>&1
|
||||
delete firewall.AdGuardHome
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
nums=$(iptables -t nat -n -L PREROUTING 2>/dev/null | grep -c "AdGuardHome")
|
||||
if [ -n "$nums" ]; then
|
||||
until [ "$nums" = 0 ]
|
||||
do
|
||||
rules=$(iptables -t nat -n -L PREROUTING --line-num 2>/dev/null | grep "AdGuardHome" | awk '{print $1}')
|
||||
for rule in $rules
|
||||
do
|
||||
iptables -t nat -D PREROUTING $rule 2> /dev/null
|
||||
break
|
||||
done
|
||||
nums=$(expr $nums - 1)
|
||||
done
|
||||
fi
|
||||
|
||||
nums=$(ip6tables -t nat -n -L PREROUTING 2>/dev/null | grep -c "AdGuardHome")
|
||||
if [ -n "$nums" ]; then
|
||||
until [ "$nums" = 0 ]
|
||||
do
|
||||
rules=$(ip6tables -t nat -n -L PREROUTING --line-num 2>/dev/null | grep "AdGuardHome" | awk '{print $1}')
|
||||
for rule in $rules
|
||||
do
|
||||
ip6tables -t nat -D PREROUTING $rule 2> /dev/null
|
||||
break
|
||||
done
|
||||
nums=$(expr $nums - 1)
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONFIGURATION"
|
||||
[ "$(uci get AdGuardHome.AdGuardHome.redirect)" == "redirect" ] && procd_add_reload_trigger firewall
|
||||
}
|
||||
|
||||
isrunning() {
|
||||
config_load "${CONFIGURATION}"
|
||||
_isrunning
|
||||
local r=$?
|
||||
([ "$r" == "0" ] && echo "running") || ([ "$r" == "1" ] && echo "not run" ) || echo "no bin"
|
||||
return $r
|
||||
}
|
||||
|
||||
_isrunning() {
|
||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
||||
[ ! -f "$binpath" ] && return 2
|
||||
pgrep $binpath 2>&1 >/dev/null && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
config_load "${CONFIGURATION}"
|
||||
_isrunning && procd_send_signal "$CONFIGURATION" || start
|
||||
}
|
||||
|
||||
get_tz() {
|
||||
SET_TZ=""
|
||||
|
||||
if [ -e "/etc/localtime" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
for tzfile in /etc/TZ /var/etc/TZ
|
||||
do
|
||||
if [ ! -e "$tzfile" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
tz="`cat $tzfile 2>/dev/null`"
|
||||
done
|
||||
|
||||
if [ -z "$tz" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
SET_TZ=$tz
|
||||
}
|
||||
|
||||
rm_port53() {
|
||||
local AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||
dnsmasq_port=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||
if [ -z "$dnsmasq_port" ]; then
|
||||
dnsmasq_port="53"
|
||||
fi
|
||||
if [ "$dnsmasq_port" == "$AdGuardHome_PORT" ]; then
|
||||
if [ "$dnsmasq_port" == "53" ]; then
|
||||
dnsmasq_port="1745"
|
||||
fi
|
||||
elif [ "$dnsmasq_port" == "53" ]; then
|
||||
return
|
||||
fi
|
||||
config_editor "dns.port" "$dnsmasq_port" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="53"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
use_port53() {
|
||||
local AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||
dnsmasq_port=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||
if [ -z "$dnsmasq_port" ]; then
|
||||
dnsmasq_port="53"
|
||||
fi
|
||||
if [ "$dnsmasq_port" == "$AdGuardHome_PORT" ]; then
|
||||
if [ "$dnsmasq_port" == "53" ]; then
|
||||
AdGuardHome_PORT="1745"
|
||||
fi
|
||||
elif [ "$AdGuardHome_PORT" == "53" ]; then
|
||||
return
|
||||
fi
|
||||
config_editor "dns.port" "53" "$configpath"
|
||||
uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
|
||||
do_redirect() {
|
||||
config_load "${CONFIGURATION}"
|
||||
_do_redirect $1
|
||||
}
|
||||
|
||||
_do_redirect() {
|
||||
local section="$CONFIGURATION"
|
||||
args=""
|
||||
ipv6_server=1
|
||||
tcp_server=0
|
||||
enabled=$1
|
||||
if [ "$enabled" == "1" ]; then
|
||||
echo -n "1">/var/run/AdGredir
|
||||
else
|
||||
echo -n "0">/var/run/AdGredir
|
||||
fi
|
||||
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
||||
AdGuardHome_PORT=$(config_editor "dns.port" "" "$configpath" "1")
|
||||
if [ -z "$AdGuardHome_PORT" ]; then
|
||||
AdGuardHome_PORT="0"
|
||||
fi
|
||||
config_get "redirect" "$section" "redirect" "none"
|
||||
config_get "old_redirect" "$section" "old_redirect" "none"
|
||||
config_get "old_port" "$section" "old_port" "0"
|
||||
config_get "old_enabled" "$section" "old_enabled" "0"
|
||||
uci get dhcp.@dnsmasq[0].port >/dev/null 2>&1 || uci set dhcp.@dnsmasq[0].port="53" >/dev/null 2>&1
|
||||
uci commit dhcp
|
||||
if [ "$old_enabled" = "1" -a "$old_redirect" == "exchange" ]; then
|
||||
AdGuardHome_PORT=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ "$old_redirect" != "$redirect" ] || [ "$old_port" != "$AdGuardHome_PORT" ] || [ "$old_enabled" = "1" -a "$enabled" = "0" ]; then
|
||||
if [ "$old_redirect" != "none" ]; then
|
||||
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||
clear_iptable
|
||||
elif [ "$old_redirect" == "dnsmasq-upstream" ]; then
|
||||
stop_forward_dnsmasq "$old_port"
|
||||
elif [ "$old_redirect" == "exchange" ]; then
|
||||
rm_port53
|
||||
fi
|
||||
fi
|
||||
elif [ "$old_enabled" = "1" -a "$enabled" = "1" ]; then
|
||||
if [ "$old_redirect" == "redirect" -a "$old_port" != "0" ]; then
|
||||
clear_iptable
|
||||
fi
|
||||
fi
|
||||
uci delete AdGuardHome.@AdGuardHome[0].old_redirect 2>/dev/null
|
||||
uci delete AdGuardHome.@AdGuardHome[0].old_port 2>/dev/null
|
||||
uci delete AdGuardHome.@AdGuardHome[0].old_enabled 2>/dev/null
|
||||
uci add_list AdGuardHome.@AdGuardHome[0].old_redirect="$redirect" 2>/dev/null
|
||||
uci add_list AdGuardHome.@AdGuardHome[0].old_port="$AdGuardHome_PORT" 2>/dev/null
|
||||
uci add_list AdGuardHome.@AdGuardHome[0].old_enabled="$enabled" 2>/dev/null
|
||||
uci commit AdGuardHome
|
||||
[ "$enabled" == "0" ] && return 1
|
||||
if [ "$AdGuardHome_PORT" == "0" ]; then
|
||||
return 1
|
||||
fi
|
||||
if [ "$redirect" = "redirect" ]; then
|
||||
set_iptable $ipv6_server $tcp_server
|
||||
elif [ "$redirect" = "dnsmasq-upstream" ]; then
|
||||
set_forward_dnsmasq "$AdGuardHome_PORT"
|
||||
elif [ "$redirect" == "exchange" -a "$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)" == "53" ]; then
|
||||
use_port53
|
||||
fi
|
||||
}
|
||||
|
||||
get_filesystem() {
|
||||
# print out path filesystem
|
||||
echo $1 | awk '
|
||||
BEGIN{
|
||||
while (("mount"| getline ret) > 0)
|
||||
{
|
||||
split(ret,d);
|
||||
fs[d[3]]=d[5];
|
||||
m=index(d[1],":")
|
||||
if (m==0)
|
||||
{
|
||||
pt[d[3]]=d[1]
|
||||
}else{
|
||||
pt[d[3]]=substr(d[1],m+1)
|
||||
}}}{
|
||||
split($0,d,"/");
|
||||
if ("/" in fs)
|
||||
{
|
||||
result1=fs["/"];
|
||||
}
|
||||
if ("/" in pt)
|
||||
{
|
||||
result2=pt["/"];
|
||||
}
|
||||
for (i=2;i<=length(d);i++)
|
||||
{
|
||||
p[i]=p[i-1]"/"d[i];
|
||||
if (p[i] in fs)
|
||||
{
|
||||
result1=fs[p[i]];
|
||||
result2=pt[p[i]];
|
||||
}
|
||||
}
|
||||
if (result2 in fs){
|
||||
result=fs[result2]}
|
||||
else{
|
||||
result=result1}
|
||||
print(result);}'
|
||||
}
|
||||
|
||||
config_editor()
|
||||
{
|
||||
awk -v yaml="$1" -v value="$2" -v file="$3" -v ro="$4" '
|
||||
BEGIN{split(yaml,part,"\.");s="";i=1;l=length(part);}
|
||||
{
|
||||
if (match($0,s""part[i]":"))
|
||||
{
|
||||
if (i==l)
|
||||
{
|
||||
split($0,t,": ");
|
||||
if (ro==""){
|
||||
system("sed -i '\''"FNR"c \\"t[1]": "value"'\'' "file);
|
||||
}else{
|
||||
print(t[2]);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
s=s"[- ]{2}";
|
||||
i++;
|
||||
}
|
||||
}' $3
|
||||
}
|
||||
|
||||
boot_service() {
|
||||
rm /var/run/AdGserverdis >/dev/null 2>&1
|
||||
config_load "${CONFIGURATION}"
|
||||
config_get waitonboot $CONFIGURATION waitonboot "0"
|
||||
config_get_bool enabled $CONFIGURATION enabled 0
|
||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
||||
[ -f "$binpath" ] && start_service
|
||||
if [ "$enabled" == "1" ] && [ "$waitonboot" == "1" ]; then
|
||||
procd_open_instance "waitnet"
|
||||
procd_set_param command "/usr/share/AdGuardHome/waitnet.sh"
|
||||
procd_close_instance
|
||||
echo "no net start pinging"
|
||||
fi
|
||||
}
|
||||
|
||||
testbackup() {
|
||||
config_load "${CONFIGURATION}"
|
||||
if [ "$1" == "backup" ]; then
|
||||
backup
|
||||
elif [ "$1" == "restore" ]; then
|
||||
restore
|
||||
fi
|
||||
}
|
||||
|
||||
restore() {
|
||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
||||
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
|
||||
cp -u -r -f $backupwdpath/data $workdir
|
||||
}
|
||||
|
||||
backup() {
|
||||
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
|
||||
mkdir -p $backupwdpath/data
|
||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
||||
config_get backupfile $CONFIGURATION backupfile ""
|
||||
for one in $backupfile;
|
||||
do
|
||||
while :
|
||||
do
|
||||
if [ -d "$backupwdpath/data/$one" ]; then
|
||||
cpret=$(cp -u -r -f $workdir/data/$one $backupwdpath/data 2>&1)
|
||||
else
|
||||
cpret=$(cp -u -r -f $workdir/data/$one $backupwdpath/data/$one 2>&1)
|
||||
fi
|
||||
echo "$cpret"
|
||||
echo "$cpret" | grep "no space left on device"
|
||||
if [ "$?" == "0" ]; then
|
||||
echo "磁盘空间已满,删除 log 文件重试中 ..."
|
||||
del_querylog && continue
|
||||
rm -f -r $backupwdpath/data/filters
|
||||
rm -f -r $workdir/data/filters && continue
|
||||
echo "backup failed"
|
||||
fi
|
||||
break
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
start_service() {
|
||||
# Reading config
|
||||
rm /var/run/AdGserverdis >/dev/null 2>&1
|
||||
config_load "${CONFIGURATION}"
|
||||
# update password
|
||||
config_get hashpass $CONFIGURATION hashpass ""
|
||||
config_get configpath $CONFIGURATION configpath "/etc/AdGuardHome.yaml"
|
||||
[ -f $configpath ] && chmod 777 $configpath
|
||||
if [ -n "$hashpass" ]; then
|
||||
config_editor "users.password" "$hashpass" "$configpath"
|
||||
uci set $CONFIGURATION.$CONFIGURATION.hashpass=""
|
||||
fi
|
||||
local enabled
|
||||
config_get_bool enabled $CONFIGURATION enabled 0
|
||||
# update crontab
|
||||
do_crontab
|
||||
if [ "$enabled" == "0" ]; then
|
||||
_do_redirect 0
|
||||
return
|
||||
fi
|
||||
#what need to do before reload
|
||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
||||
|
||||
config_get backupfile $CONFIGURATION backupfile ""
|
||||
mkdir -p $workdir/data
|
||||
if [ -n "$backupfile" ] && [ ! -d "$workdir/data" ]; then
|
||||
restore
|
||||
fi
|
||||
local cwdfs=$(get_filesystem $workdir)
|
||||
echo "文件系统: ${cwdfs}"
|
||||
if [ "$cwdfs" == "jffs2" ]; then
|
||||
echo "fs error ln db to tmp $workdir $cwdfs"
|
||||
logger "AdGuardHome" "warning db redirect to tmp"
|
||||
touch $workdir/data/stats.db
|
||||
if [ ! -L $workdir/data/stats.db ]; then
|
||||
mv -f $workdir/data/stats.db /tmp/stats.db 2>/dev/null
|
||||
ln -s /tmp/stats.db $workdir/data/stats.db 2>/dev/null
|
||||
fi
|
||||
touch $workdir/data/sessions.db
|
||||
if [ ! -L $workdir/data/sessions.db ]; then
|
||||
mv -f $workdir/data/sessions.db /tmp/sessions.db 2>/dev/null
|
||||
ln -s /tmp/sessions.db $workdir/data/sessions.db 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
local ADDITIONAL_ARGS=""
|
||||
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
|
||||
|
||||
mkdir -p ${binpath%/*}
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -c $configpath"
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -w $workdir"
|
||||
config_get httpport $CONFIGURATION httpport 3000
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -p $httpport"
|
||||
|
||||
# hack to save config file when upgrade system
|
||||
config_get upprotect $CONFIGURATION upprotect ""
|
||||
eval upprotect=${upprotect// /\\\\n}
|
||||
echo -e "$upprotect" > /lib/upgrade/keep.d/luci-app-adguardhome
|
||||
|
||||
config_get logfile $CONFIGURATION logfile ""
|
||||
if [ -n "$logfile" ]; then
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -l $logfile"
|
||||
fi
|
||||
|
||||
if [ ! -f "$binpath" ]; then
|
||||
_do_redirect 0
|
||||
/usr/share/AdGuardHome/update_core.sh 2>&1 >/tmp/AdGuardHome_update.log &
|
||||
exit 0
|
||||
else
|
||||
chmod 777 $binpath
|
||||
fi
|
||||
|
||||
config_get_bool verbose $CONFIGURATION verbose 0
|
||||
if [ "$verbose" -eq 1 ]; then
|
||||
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -v"
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
get_tz
|
||||
if [ -n "$SET_TZ" ]; then
|
||||
procd_set_param env TZ="$SET_TZ"
|
||||
fi
|
||||
procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
|
||||
procd_set_param limits core="unlimited" nofile="65535 65535"
|
||||
procd_set_param stderr 1
|
||||
procd_set_param command $binpath $ADDITIONAL_ARGS
|
||||
procd_set_param file "$configpath" "/etc/hosts" "/etc/config/AdGuardHome"
|
||||
procd_close_instance
|
||||
if [ -f "$configpath" ]; then
|
||||
_do_redirect 1
|
||||
else
|
||||
_do_redirect 0
|
||||
config_get "redirect" "AdGuardHome" "redirect" "none"
|
||||
if [ "$redirect" != "none" ]; then
|
||||
procd_open_instance "waitconfig"
|
||||
procd_set_param command "/usr/share/AdGuardHome/watchconfig.sh"
|
||||
procd_close_instance
|
||||
echo "no config start watching"
|
||||
fi
|
||||
fi
|
||||
echo "AdGuardHome 服务已启用"
|
||||
(sleep 10 && [ -z "$(pgrep $binpath)" ] && logger "AdGuardHome" "no process in 10s cancel redirect" && _do_redirect 0 )&
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
rm /var/run/AdGlucitest >/dev/null 2>&1
|
||||
echo "重载 AdGuardHome 服务..."
|
||||
start
|
||||
}
|
||||
|
||||
del_querylog() {
|
||||
local btarget=$(ls $backupwdpath/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||
local wtarget=$(ls $workdir/data | grep -F "querylog.json" | sort -r | head -n 1)
|
||||
if [ "$btarget"x == "$wtarget"x ]; then
|
||||
[ -z "$btarget" ] && return 1
|
||||
rm -f $workdir/data/$wtarget
|
||||
rm -f $backupwdpath/data/$btarget
|
||||
return 0
|
||||
fi
|
||||
if [ "$btarget" \> "$wtarget" ]; then
|
||||
rm -f $backupwdpath/data/$btarget
|
||||
return 0
|
||||
else
|
||||
rm -f $workdir/data/$wtarget
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
stop_service() {
|
||||
config_load "${CONFIGURATION}"
|
||||
_do_redirect 0
|
||||
do_crontab
|
||||
if [ "$1" != "nobackup" ]; then
|
||||
config_get backupfile $CONFIGURATION backupfile "0"
|
||||
if [ -n "$backupfile" ]; then
|
||||
backup
|
||||
fi
|
||||
fi
|
||||
echo "AdGuardHome 服务已停止"
|
||||
touch /var/run/AdGserverdis
|
||||
}
|
||||
|
||||
boot() {
|
||||
rc_procd boot_service "$@"
|
||||
if eval "type service_started" 2>/dev/null >/dev/null; then
|
||||
service_started
|
||||
fi
|
||||
}
|
||||
test_crontab() {
|
||||
config_load "${CONFIGURATION}"
|
||||
do_crontab
|
||||
}
|
||||
|
||||
do_crontab() {
|
||||
config_get_bool enabled $CONFIGURATION enabled 0
|
||||
config_get crontab $CONFIGURATION crontab ""
|
||||
local findstr default cronenable replace commit
|
||||
local cronreload=0
|
||||
local commit=0
|
||||
findstr="/usr/share/AdGuardHome/update_core.sh"
|
||||
default="30 3 * * * /usr/share/AdGuardHome/update_core.sh 2>&1"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//autoupdate/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
|
||||
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
|
||||
config_get lastworkdir $CONFIGURATION lastworkdir "/usr/bin/AdGuardHome"
|
||||
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||
#[ -n "$lastworkdir" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastworkdir/data/querylog.json" && [ "$lastworkdir" != "$workdir" ] && replace="${lastworkdir//\//\\/}/${workdir//\//\\/}"
|
||||
default="0 * * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//cutquerylog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
#[ "$lastworkdir" != "$workdir" ] && uci set AdGuardHome.AdGuardHome.lastworkdir="$workdir" && commit=1
|
||||
|
||||
config_get logfile $CONFIGURATION logfile ""
|
||||
config_get lastlogfile $CONFIGURATION lastlogfile ""
|
||||
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
||||
default="30 3 * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.logfile)"
|
||||
#[ -n "$lastlogfile" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastlogfile" && [ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && replace="${lastlogfile//\//\\/}/${logfile//\//\\/}"
|
||||
[ "$logfile" == "syslog" ] || [ "$logfile" == "" ] || [ "$enabled" == "0" ] || [ "${crontab//cutruntimelog/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
#[ -n "$logfile" ] && [ "$lastlogfile" != "$logfile" ] && uci set AdGuardHome.AdGuardHome.lastlogfile="$logfile" && commit=1
|
||||
|
||||
findstr="/usr/share/AdGuardHome/addhost.sh"
|
||||
default="0 * * * * /usr/share/AdGuardHome/addhost.sh"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//autohost/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
[ "$cronenable" == "0" ] && /usr/share/AdGuardHome/addhost.sh "del" "noreload" || /usr/share/AdGuardHome/addhost.sh "" "noreload"
|
||||
|
||||
findstr="/usr/share/AdGuardHome/gfw2adg.sh"
|
||||
default="30 3 * * * /usr/share/AdGuardHome/gfw2adg.sh"
|
||||
[ "$enabled" == "0" ] || [ "${crontab//autogfw/}" == "$crontab" ] && cronenable=0 || cronenable=1
|
||||
crontab_editor
|
||||
[ "$cronreload" -gt 0 ] && /etc/init.d/cron restart
|
||||
#[ "$commit" -gt 0 ] && uci commit AdGuardHome
|
||||
}
|
||||
crontab_editor() {
|
||||
#usage input:
|
||||
#findstr=
|
||||
#default=
|
||||
#cronenable=
|
||||
#replace="${last//\//\\/}/${now//\//\\/}"
|
||||
#output:cronreload:if >1 please /etc/init.d/cron restart manual
|
||||
local testline reload
|
||||
local line="$(grep "$findstr" $CRON_FILE)"
|
||||
[ -n "$replace" ] && [ -n "$line" ] && eval testline="\${line//$replace}" && [ "$testline" != "$line" ] && line="$testline" && reload="1" && replace=""
|
||||
if [ "${line:0:1}" != "#" ]; then
|
||||
if [ $cronenable -eq 1 ]; then
|
||||
[ -z "$line" ] && line="$default" && reload="1"
|
||||
if [ -n "$reload" ]; then
|
||||
sed -i "\,$findstr,d" $CRON_FILE
|
||||
echo "$line" >> $CRON_FILE
|
||||
cronreload=$((cronreload+1))
|
||||
fi
|
||||
elif [ -n "$line" ]; then
|
||||
sed -i "\,$findstr,d" $CRON_FILE
|
||||
echo "#$line" >> $CRON_FILE
|
||||
cronreload=$((cronreload+1))
|
||||
fi
|
||||
else
|
||||
if [ $cronenable -eq 1 ]; then
|
||||
sed -i "\,$findstr,d" $CRON_FILE
|
||||
echo "${line:1}" >> $CRON_FILE
|
||||
cronreload=$((cronreload+1))
|
||||
elif [ -z "$reload" ]; then
|
||||
sed -i "\,$findstr,d" $CRON_FILE
|
||||
echo "$line" >> $CRON_FILE
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null 2>&1
|
||||
delete ucitrack.@AdGuardHome[-1]
|
||||
add ucitrack AdGuardHome
|
||||
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
|
||||
commit ucitrack
|
||||
delete AdGuardHome.AdGuardHome.ucitracktest
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -1,136 +0,0 @@
|
||||
# 使用本模板,点击下方 [保存&应用] 就可以开始正常使用 AdGuardHome 服务
|
||||
# Enhanced by Hyy2001
|
||||
|
||||
bind_host: 0.0.0.0
|
||||
bind_port: 3000
|
||||
beta_bind_port: 0
|
||||
users:
|
||||
- name: root
|
||||
password: $2a$10$rYaGunOdH6N62SDycg3rQO1POzr39lXF8vHZ/28wkJq3RY69DJYT2
|
||||
auth_attempts: 5
|
||||
block_auth_min: 15
|
||||
http_proxy: ""
|
||||
language: ""
|
||||
rlimit_nofile: 0
|
||||
debug_pprof: false
|
||||
web_session_ttl: 720
|
||||
dns:
|
||||
bind_hosts:
|
||||
- 0.0.0.0
|
||||
port: 5553
|
||||
statistics_interval: 90
|
||||
querylog_enabled: true
|
||||
querylog_file_enabled: true
|
||||
querylog_interval: 1
|
||||
querylog_size_memory: 1000
|
||||
anonymize_client_ip: false
|
||||
protection_enabled: true
|
||||
blocking_mode: default
|
||||
blocking_ipv4: ""
|
||||
blocking_ipv6: ""
|
||||
blocked_response_ttl: 10
|
||||
parental_block_host: family-block.dns.adguard.com
|
||||
safebrowsing_block_host: standard-block.dns.adguard.com
|
||||
ratelimit: 0
|
||||
ratelimit_whitelist: []
|
||||
refuse_any: true
|
||||
upstream_dns:
|
||||
- https://dns.alidns.com/dns-query
|
||||
- tls://dns.alidns.com
|
||||
- 114.114.114.114
|
||||
- 223.5.5.5
|
||||
upstream_dns_file: ""
|
||||
bootstrap_dns:
|
||||
#bootstrap_dns
|
||||
all_servers: true
|
||||
fastest_addr: false
|
||||
allowed_clients: []
|
||||
disallowed_clients: []
|
||||
blocked_hosts:
|
||||
- version.bind
|
||||
- id.server
|
||||
- hostname.bind
|
||||
cache_size: 4194304
|
||||
cache_ttl_min: 0
|
||||
cache_ttl_max: 0
|
||||
bogus_nxdomain: []
|
||||
aaaa_disabled: true
|
||||
enable_dnssec: true
|
||||
edns_client_subnet: false
|
||||
max_goroutines: 300
|
||||
ipset: []
|
||||
filtering_enabled: true
|
||||
filters_update_interval: 24
|
||||
parental_enabled: false
|
||||
safesearch_enabled: false
|
||||
safebrowsing_enabled: false
|
||||
safebrowsing_cache_size: 1048576
|
||||
safesearch_cache_size: 1048576
|
||||
parental_cache_size: 1048576
|
||||
cache_time: 30
|
||||
rewrites: []
|
||||
blocked_services: []
|
||||
local_domain_name: lan
|
||||
resolve_clients: false
|
||||
local_ptr_upstreams: []
|
||||
tls:
|
||||
enabled: false
|
||||
server_name: ""
|
||||
force_https: false
|
||||
port_https: 443
|
||||
port_dns_over_tls: 853
|
||||
port_dns_over_quic: 784
|
||||
port_dnscrypt: 0
|
||||
dnscrypt_config_file: ""
|
||||
allow_unencrypted_doh: false
|
||||
strict_sni_check: false
|
||||
certificate_chain: ""
|
||||
private_key: ""
|
||||
certificate_path: ""
|
||||
private_key_path: ""
|
||||
filters:
|
||||
- enabled: true
|
||||
url: https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt
|
||||
name: AdGuard Home
|
||||
id: 1
|
||||
- enabled: true
|
||||
url: https://banbendalao.coding.net/p/adgk/d/ADgk/git/raw/master/ADgk.txt
|
||||
name: AD-gk
|
||||
id: 2
|
||||
- enabled: false
|
||||
url: https://anti-ad.net/easylist.txt
|
||||
name: anti-AD
|
||||
id: 4
|
||||
- enabled: true
|
||||
url: https://raw.githubusercontent.com/o0HalfLife0o/list/master/ad.txt
|
||||
name: HalfLife
|
||||
id: 5
|
||||
whitelist_filters: []
|
||||
user_rules:
|
||||
- '@@||iwx.mail.qq.com^$important'
|
||||
- '@@||gm.mmstat.com^$important'
|
||||
dhcp:
|
||||
enabled: false
|
||||
interface_name: ""
|
||||
dhcpv4:
|
||||
gateway_ip: ""
|
||||
subnet_mask: ""
|
||||
range_start: ""
|
||||
range_end: ""
|
||||
lease_duration: 86400
|
||||
icmp_timeout_msec: 1000
|
||||
options: []
|
||||
dhcpv6:
|
||||
range_start: ""
|
||||
lease_duration: 86400
|
||||
ra_slaac_only: false
|
||||
ra_allow_slaac: false
|
||||
clients: []
|
||||
log_compress: false
|
||||
log_localtime: false
|
||||
log_max_backups: 0
|
||||
log_max_size: 100
|
||||
log_max_age: 3
|
||||
log_file: ""
|
||||
verbose: false
|
||||
schema_version: 10
|
@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
checkmd5(){
|
||||
local nowmd5=$(md5sum /etc/hosts)
|
||||
nowmd5=${nowmd5%% *}
|
||||
local lastmd5=$(uci get AdGuardHome.AdGuardHome.hostsmd5 2>/dev/null)
|
||||
if [ "$nowmd5" != "$lastmd5" ]; then
|
||||
uci set AdGuardHome.AdGuardHome.hostsmd5="$nowmd5"
|
||||
uci commit AdGuardHome
|
||||
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||
fi
|
||||
}
|
||||
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' /etc/hosts && checkmd5 "$2" && exit 0
|
||||
/usr/bin/awk 'BEGIN{
|
||||
while ((getline < "/tmp/dhcp.leases") > 0)
|
||||
{
|
||||
a[$2]=$4;
|
||||
}
|
||||
while (("ip -6 neighbor show | grep -v fe80" | getline) > 0)
|
||||
{
|
||||
if (a[$5]) {print $1" "a[$5] >"/tmp/tmphost"; }
|
||||
}
|
||||
print "#programaddend" >"/tmp/tmphost";
|
||||
}'
|
||||
grep programaddstart /etc/hosts >/dev/null 2>&1
|
||||
if [ "$?" == "0" ]; then
|
||||
sed -i '/programaddstart/,/programaddend/c\#programaddstart' /etc/hosts
|
||||
sed -i '/programaddstart/'r/tmp/tmphost /etc/hosts
|
||||
else
|
||||
echo "#programaddstart" >>/etc/hosts
|
||||
cat /tmp/tmphost >> /etc/hosts
|
||||
fi
|
||||
rm /tmp/tmphost
|
||||
checkmd5 "$2"
|
@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
AdGuardHome_enable=$(uci get AdGuardHome.AdGuardHome.enabled)
|
||||
redirect=$(uci get AdGuardHome.AdGuardHome.redirect)
|
||||
|
||||
if [ $AdGuardHome_enable -eq 1 -a "$redirect" == "redirect" ]; then
|
||||
/etc/init.d/AdGuardHome do_redirect 1
|
||||
fi
|
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
logread -e AdGuardHome > /tmp/AdGuardHometmp.log
|
||||
logread -e AdGuardHome -f >> /tmp/AdGuardHometmp.log &
|
||||
pid=$!
|
||||
echo "1">/var/run/AdGuardHomesyslog
|
||||
while true
|
||||
do
|
||||
sleep 12
|
||||
watchdog=$(cat /var/run/AdGuardHomesyslog)
|
||||
if [ "$watchdog"x == "0"x ]; then
|
||||
kill $pid
|
||||
rm /tmp/AdGuardHometmp.log
|
||||
rm /var/run/AdGuardHomesyslog
|
||||
exit 0
|
||||
else
|
||||
echo "0">/var/run/AdGuardHomesyslog
|
||||
fi
|
||||
done
|
@ -1,86 +0,0 @@
|
||||
#!/bin/sh
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
checkmd5(){
|
||||
local nowmd5=$(md5sum /tmp/adguard.list 2>/dev/null)
|
||||
nowmd5=${nowmd5%% *}
|
||||
local lastmd5=$(uci get AdGuardHome.AdGuardHome.gfwlistmd5 2>/dev/null)
|
||||
if [ "$nowmd5" != "$lastmd5" ]; then
|
||||
uci set AdGuardHome.AdGuardHome.gfwlistmd5="$nowmd5"
|
||||
uci commit AdGuardHome
|
||||
[ "$1" == "noreload" ] || /etc/init.d/AdGuardHome reload
|
||||
fi
|
||||
}
|
||||
configpath=$(uci get AdGuardHome.AdGuardHome.configpath 2>/dev/null)
|
||||
[ "$1" == "del" ] && sed -i '/programaddstart/,/programaddend/d' $configpath && checkmd5 "$2" && exit 0
|
||||
gfwupstream=$(uci get AdGuardHome.AdGuardHome.gfwupstream 2>/dev/null)
|
||||
if [ -z $gfwupstream ]; then
|
||||
gfwupstream="tcp://208.67.220.220:5353"
|
||||
fi
|
||||
if [ ! -f "$configpath" ]; then
|
||||
echo "please make a config first"
|
||||
exit 1
|
||||
fi
|
||||
wget-ssl --no-check-certificate https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt -O- | base64 -d > /tmp/gfwlist.txt
|
||||
cat /tmp/gfwlist.txt | awk -v upst="$gfwupstream" 'BEGIN{getline;}{
|
||||
s1=substr($0,1,1);
|
||||
if (s1=="!")
|
||||
{next;}
|
||||
if (s1=="@"){
|
||||
$0=substr($0,3);
|
||||
s1=substr($0,1,1);
|
||||
white=1;}
|
||||
else{
|
||||
white=0;
|
||||
}
|
||||
|
||||
if (s1=="|")
|
||||
{s2=substr($0,2,1);
|
||||
if (s2=="|")
|
||||
{
|
||||
$0=substr($0,3);
|
||||
split($0,d,"/");
|
||||
$0=d[1];
|
||||
}else{
|
||||
split($0,d,"/");
|
||||
$0=d[3];
|
||||
}}
|
||||
else{
|
||||
split($0,d,"/");
|
||||
$0=d[1];
|
||||
}
|
||||
star=index($0,"*");
|
||||
if (star!=0)
|
||||
{
|
||||
$0=substr($0,star+1);
|
||||
dot=index($0,".");
|
||||
if (dot!=0)
|
||||
$0=substr($0,dot+1);
|
||||
else
|
||||
next;
|
||||
s1=substr($0,1,1);
|
||||
}
|
||||
if (s1==".")
|
||||
{fin=substr($0,2);}
|
||||
else{fin=$0;}
|
||||
if (index(fin,".")==0) next;
|
||||
if (index(fin,"%")!=0) next;
|
||||
if (index(fin,":")!=0) next;
|
||||
match(fin,"^[0-9\.]+")
|
||||
if (RSTART==1 && RLENGTH==length(fin)) {print "ipset add gfwlist "fin>"/tmp/doipset.sh";next;}
|
||||
if (fin=="" || finl==fin) next;
|
||||
finl=fin;
|
||||
if (white==0)
|
||||
{print(" - '\''[/"fin"/]"upst"'\''");}
|
||||
else{
|
||||
print(" - '\''[/"fin"/]#'\''");}
|
||||
}END{print(" - '\''[/programaddend/]#'\''")}' > /tmp/adguard.list
|
||||
grep programaddstart $configpath
|
||||
if [ "$?" == "0" ]; then
|
||||
sed -i '/programaddstart/,/programaddend/c\ - '\''\[\/programaddstart\/\]#'\''' $configpath
|
||||
sed -i '/programaddstart/'r/tmp/adguard.list $configpath
|
||||
else
|
||||
sed -i '1i\ - '\''[/programaddstart/]#'\''' /tmp/adguard.list
|
||||
sed -i '/upstream_dns:/'r/tmp/adguard.list $configpath
|
||||
fi
|
||||
checkmd5 "$2"
|
||||
rm -f /tmp/gfwlist.txt /tmp/adguard.list
|
@ -1,4 +0,0 @@
|
||||
https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz
|
||||
https://hub.fastgit.xyz/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz
|
||||
#https://static.adguard.com/adguardhome/release/AdGuardHome_linux_${Arch}.tar.gz
|
||||
#https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
tail -n $1 "$2" > /var/run/tailtmp
|
||||
cat /var/run/tailtmp > "$2"
|
||||
rm /var/run/tailtmp
|
@ -1,217 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
update_mode=$1
|
||||
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
|
||||
if [[ -z ${binpath} ]]; then
|
||||
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
binpath="/tmp/AdGuardHome/AdGuardHome"
|
||||
fi
|
||||
[[ ! -d ${binpath%/*} ]] && mkdir -p ${binpath%/*}
|
||||
upxflag=$(uci get AdGuardHome.AdGuardHome.upxflag 2>/dev/null)
|
||||
[[ -z ${upxflag} ]] && upxflag=off
|
||||
enabled=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
|
||||
core_version=$(uci get AdGuardHome.AdGuardHome.core_version 2>/dev/null)
|
||||
update_url=$(uci get AdGuardHome.AdGuardHome.update_url 2>/dev/null)
|
||||
|
||||
case "${core_version}" in
|
||||
beta)
|
||||
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases
|
||||
;;
|
||||
*)
|
||||
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest
|
||||
;;
|
||||
esac
|
||||
|
||||
Check_Task(){
|
||||
running_tasks="$(ps -efww | grep -v grep | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | wc -l)"
|
||||
case $1 in
|
||||
force)
|
||||
echo -e "执行: 强制更新核心"
|
||||
echo -e "清除 ${running_tasks} 个进程 ..."
|
||||
ps -efww | grep -v grep | grep -v $$ | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | xargs kill -9 2> /dev/null
|
||||
;;
|
||||
*)
|
||||
[[ ${running_tasks} -gt 2 ]] && echo -e "已经有 ${running_tasks} 个任务正在运行, 请等待其执行结束或将其强行停止!" && EXIT 2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Check_Downloader(){
|
||||
which curl > /dev/null 2>&1 && PKG="curl" && return
|
||||
echo -e "\n未安装 curl"
|
||||
which wget-ssl > /dev/null 2>&1 && PKG="wget-ssl" && return
|
||||
echo "未安装 curl 和 wget, 无法检测更新!" && EXIT 1
|
||||
}
|
||||
|
||||
Check_Updates(){
|
||||
Check_Downloader
|
||||
case "${PKG}" in
|
||||
curl)
|
||||
Downloader="curl -L -k -o"
|
||||
_Downloader="curl -s"
|
||||
;;
|
||||
wget-ssl)
|
||||
Downloader="wget-ssl --no-check-certificate -T 5 -O"
|
||||
_Downloader="wget-ssl -q -O -"
|
||||
;;
|
||||
esac
|
||||
echo "[${PKG}] 开始检查更新, 请耐心等待 ..."
|
||||
Cloud_Version="$(${_Downloader} ${core_api_url} 2>/dev/null | grep 'tag_name' | egrep -o "v[0-9].+[0-9.]" | awk 'NR==1')"
|
||||
[[ -z ${Cloud_Version} ]] && echo -e "\n检查更新失败, 请检查网络或稍后重试!" && EXIT 1
|
||||
if [[ -f ${binpath} ]]; then
|
||||
Current_Version="$(${binpath} --version 2>/dev/null | egrep -o "v[0-9].+[0-9]" | sed -r 's/(.*), c(.*)/\1/')"
|
||||
else
|
||||
Current_Version="未知"
|
||||
fi
|
||||
[[ -z ${Current_Version} ]] && Current_Version="未知"
|
||||
echo -e "\n执行文件路径: ${binpath%/*}\n\n正在检查更新, 请耐心等待 ..."
|
||||
echo -e "\n当前 AdGuardHome 版本: ${Current_Version}\n云端 AdGuardHome 版本: ${Cloud_Version}"
|
||||
if [[ ! "${Cloud_Version}" == "${Current_Version}" || "$1" == force ]]; then
|
||||
Update_Core
|
||||
else
|
||||
echo -e "\n已是最新版本, 无需更新!"
|
||||
EXIT 0
|
||||
fi
|
||||
EXIT 0
|
||||
}
|
||||
|
||||
UPX_Compress(){
|
||||
GET_Arch
|
||||
upx_name="upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz"
|
||||
echo -e "开始下载 ${upx_name} ...\n"
|
||||
$Downloader /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/${upx_name}"
|
||||
if [[ ! -e /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz ]]; then
|
||||
echo -e "\n${upx_name} 下载失败!\n"
|
||||
EXIT 1
|
||||
else
|
||||
echo -e "\n${upx_name} 下载成功!\n"
|
||||
fi
|
||||
which xz > /dev/null 2>&1 || (opkg list | grep ^xz || opkg update > /dev/null 2>&1 && opkg install xz --force-depends) || (echo "软件包 xz 安装失败!" && EXIT 1)
|
||||
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux
|
||||
echo -e "正在解压 ${upx_name} ...\n"
|
||||
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz | tar -x -C "/tmp"
|
||||
[[ ! -f /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx ]] && echo -e "\n${upx_name} 解压失败!" && EXIT 1
|
||||
}
|
||||
|
||||
Update_Core(){
|
||||
rm -r /tmp/AdGuardHome_Update > /dev/null 2>&1
|
||||
mkdir -p "/tmp/AdGuardHome_Update"
|
||||
GET_Arch
|
||||
eval link="${update_url}"
|
||||
echo -e "下载链接:${link}"
|
||||
echo -e "文件名称:${link##*/}"
|
||||
echo -e "\n开始下载 AdGuardHome 核心文件 ...\n"
|
||||
$Downloader /tmp/AdGuardHome_Update/${link##*/} ${link}
|
||||
if [[ $? != 0 ]];then
|
||||
echo -e "\nAdGuardHome 核心下载失败 ..."
|
||||
rm -r /tmp/AdGuardHome_Update
|
||||
EXIT 1
|
||||
fi
|
||||
if [[ ${link##*.} == gz ]]; then
|
||||
echo -e "\n正在解压 AdGuardHome ..."
|
||||
tar -zxf "/tmp/AdGuardHome_Update/${link##*/}" -C "/tmp/AdGuardHome_Update/"
|
||||
if [[ ! -e /tmp/AdGuardHome_Update/AdGuardHome ]]
|
||||
then
|
||||
echo "AdGuardHome 核心解压失败!"
|
||||
rm -rf "/tmp/AdGuardHome_Update" > /dev/null 2>&1
|
||||
EXIT 1
|
||||
fi
|
||||
downloadbin="/tmp/AdGuardHome_Update/AdGuardHome/AdGuardHome"
|
||||
else
|
||||
downloadbin="/tmp/AdGuardHome_Update/${link##*/}"
|
||||
fi
|
||||
chmod +x ${downloadbin}
|
||||
echo -e "\nAdGuardHome 核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
|
||||
if [[ ${upxflag} != off ]]; then
|
||||
UPX_Compress
|
||||
echo -e "使用 UPX 压缩可能会花很长时间, 期间请耐心等待!\n正在压缩 $downloadbin ..."
|
||||
/tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx $upxflag $downloadbin > /dev/null 2>&1
|
||||
echo -e "\n压缩后的核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
|
||||
else
|
||||
echo "未启用 UPX 压缩, 跳过操作..."
|
||||
fi
|
||||
/etc/init.d/AdGuardHome stop > /dev/null 2>&1
|
||||
echo -e "\n移动 AdGuardHome 核心文件到 ${binpath%/*} ..."
|
||||
mv -f ${downloadbin} ${binpath} > /dev/null 2>&1
|
||||
if [[ ! -s ${binpath} && $? != 0 ]]; then
|
||||
echo -e "AdGuardHome 核心移动失败!\n可能是设备空间不足导致, 请尝试开启 UPX 压缩, 或更改 [执行文件路径] 为 /tmp/AdGuardHome"
|
||||
EXIT 1
|
||||
fi
|
||||
rm -f /tmp/upx*.tar.xz
|
||||
rm -rf /tmp/upx*
|
||||
rm -rf /tmp/AdGuardHome_Update
|
||||
chmod +x ${binpath}
|
||||
if [[ ${enabled} == 1 ]]; then
|
||||
echo -e "\n正在重启 AdGuardHome 服务..."
|
||||
/etc/init.d/AdGuardHome restart
|
||||
fi
|
||||
echo -e "\nAdGuardHome 核心更新成功!"
|
||||
}
|
||||
|
||||
GET_Arch() {
|
||||
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
|
||||
case "${Archt}" in
|
||||
i386)
|
||||
Arch=i386
|
||||
;;
|
||||
i686)
|
||||
Arch=i386
|
||||
;;
|
||||
x86)
|
||||
Arch=amd64
|
||||
;;
|
||||
mipsel)
|
||||
Arch=mipsle_softfloat
|
||||
;;
|
||||
mips)
|
||||
Arch=mips_softfloat
|
||||
;;
|
||||
mips64el)
|
||||
Arch=mips64le_softfloat
|
||||
;;
|
||||
mips64)
|
||||
Arch=mips64_softfloat
|
||||
;;
|
||||
arm)
|
||||
Arch=arm
|
||||
;;
|
||||
armeb)
|
||||
Arch=armeb
|
||||
;;
|
||||
aarch64)
|
||||
Arch=arm64
|
||||
;;
|
||||
*)
|
||||
echo -e "\nAdGuardHome 暂不支持当前的设备架构: [${Archt}]!"
|
||||
EXIT 1
|
||||
esac
|
||||
case "${Archt}" in
|
||||
mipsel)
|
||||
Arch_upx="mipsel"
|
||||
upx_latest_ver="3.95"
|
||||
;;
|
||||
*)
|
||||
Arch_upx="${Arch}"
|
||||
upx_latest_ver="$(${_Downloader} https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null | egrep 'tag_name' | egrep '[0-9.]+' -o 2>/dev/null)"
|
||||
|
||||
esac
|
||||
echo -e "\n当前设备架构: ${Arch}\n"
|
||||
}
|
||||
|
||||
EXIT(){
|
||||
rm -rf /var/run/update_core 2>/dev/null
|
||||
[[ $1 != 0 ]] && touch /var/run/update_core_error
|
||||
exit $1
|
||||
}
|
||||
|
||||
main(){
|
||||
Check_Task ${update_mode}
|
||||
Check_Updates ${update_mode}
|
||||
}
|
||||
|
||||
trap "EXIT 1" SIGTERM SIGINT
|
||||
touch /var/run/update_core
|
||||
rm - rf /var/run/update_core_error 2>/dev/null
|
||||
|
||||
main
|
@ -1,34 +0,0 @@
|
||||
#!/bin/sh
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
count=0
|
||||
while :
|
||||
do
|
||||
ping -c 1 -W 1 -q www.baidu.com 1>/dev/null 2>&1
|
||||
if [ "$?" == 0 ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
ping -c 1 -W 1 -q 223.5.5.5 1>/dev/null 2>&1
|
||||
if [ "$?" == 0 ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
ping -c 1 -W 1 -q www.github.com 1>/dev/null 2>&1
|
||||
if [ "$?" == 0 ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
ping -c 1 -W 1 -q 8.8.8.8 1>/dev/null 2>&1
|
||||
if [ "$?" == 0 ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
sleep 5
|
||||
count=$((count+1))
|
||||
if [ $count -gt 18 ]; then
|
||||
/etc/init.d/AdGuardHome force_reload
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 0
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
configpath=$(uci get AdGuardHome.AdGuardHome.configpath)
|
||||
while :
|
||||
do
|
||||
sleep 10
|
||||
if [ -f "$configpath" ]; then
|
||||
/etc/init.d/AdGuardHome do_redirect 1
|
||||
break
|
||||
fi
|
||||
done
|
||||
return 0
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"luci-app-adguardhome": {
|
||||
"description": "Grant UCI access for luci-app-adguardhome",
|
||||
"read": {
|
||||
"uci": [ "AdGuardHome" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "AdGuardHome" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
!function(n){"object"==typeof exports&&"object"==typeof module?n(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],n):n(CodeMirror)}(function(n){"use strict";function e(e,o,i,t){if(i&&i.call){var l=i;i=null}else l=r(e,i,"rangeFinder");"number"==typeof o&&(o=n.Pos(o,0));var f=r(e,i,"minFoldSize");function d(n){var r=l(e,o);if(!r||r.to.line-r.from.line<f)return null;for(var i=e.findMarksAt(r.from),d=0;d<i.length;++d)if(i[d].__isFold&&"fold"!==t){if(!n)return null;r.cleared=!0,i[d].clear()}return r}var u=d(!0);if(r(e,i,"scanUp"))for(;!u&&o.line>e.firstLine();)o=n.Pos(o.line-1,0),u=d(!1);if(u&&!u.cleared&&"unfold"!==t){var a=function(n,e){var o=r(n,e,"widget");if("string"==typeof o){var i=document.createTextNode(o);(o=document.createElement("span")).appendChild(i),o.className="CodeMirror-foldmarker"}else o&&(o=o.cloneNode(!0));return o}(e,i);n.on(a,"mousedown",function(e){c.clear(),n.e_preventDefault(e)});var c=e.markText(u.from,u.to,{replacedWith:a,clearOnEnter:r(e,i,"clearOnEnter"),__isFold:!0});c.on("clear",function(o,r){n.signal(e,"unfold",e,o,r)}),n.signal(e,"fold",e,u.from,u.to)}}n.newFoldFunction=function(n,o){return function(r,i){e(r,i,{rangeFinder:n,widget:o})}},n.defineExtension("foldCode",function(n,o,r){e(this,n,o,r)}),n.defineExtension("isFolded",function(n){for(var e=this.findMarksAt(n),o=0;o<e.length;++o)if(e[o].__isFold)return!0}),n.commands.toggleFold=function(n){n.foldCode(n.getCursor())},n.commands.fold=function(n){n.foldCode(n.getCursor(),null,"fold")},n.commands.unfold=function(n){n.foldCode(n.getCursor(),null,"unfold")},n.commands.foldAll=function(e){e.operation(function(){for(var o=e.firstLine(),r=e.lastLine();o<=r;o++)e.foldCode(n.Pos(o,0),null,"fold")})},n.commands.unfoldAll=function(e){e.operation(function(){for(var o=e.firstLine(),r=e.lastLine();o<=r;o++)e.foldCode(n.Pos(o,0),null,"unfold")})},n.registerHelper("fold","combine",function(){var n=Array.prototype.slice.call(arguments,0);return function(e,o){for(var r=0;r<n.length;++r){var i=n[r](e,o);if(i)return i}}}),n.registerHelper("fold","auto",function(n,e){for(var o=n.getHelpers(e,"fold"),r=0;r<o.length;r++){var i=o[r](n,e);if(i)return i}});var o={rangeFinder:n.fold.auto,widget:"↔",minFoldSize:0,scanUp:!1,clearOnEnter:!0};function r(n,e,r){if(e&&void 0!==e[r])return e[r];var i=n.options.foldOptions;return i&&void 0!==i[r]?i[r]:o[r]}n.defineOption("foldOptions",null),n.defineExtension("foldOption",function(n,e){return r(this,n,e)})});
|
@ -1 +0,0 @@
|
||||
.CodeMirror-foldmarker{color:blue;text-shadow:#b9f 1px 1px 2px,#b9f -1px -1px 2px,#b9f 1px -1px 2px,#b9f -1px 1px 2px;font-family:arial;line-height:.3;cursor:pointer}.CodeMirror-foldgutter{width:.7em}.CodeMirror-foldgutter-open,.CodeMirror-foldgutter-folded{cursor:pointer}.CodeMirror-foldgutter-open:after{content:"\25BE"}.CodeMirror-foldgutter-folded:after{content:"\25B8"}
|
@ -1 +0,0 @@
|
||||
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("./foldcode")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","./foldcode"],t):t(CodeMirror)}(function(t){"use strict";t.defineOption("foldGutter",!1,function(o,e,r){r&&r!=t.Init&&(o.clearGutter(o.state.foldGutter.options.gutter),o.state.foldGutter=null,o.off("gutterClick",a),o.off("changes",d),o.off("viewportChange",u),o.off("fold",l),o.off("unfold",l),o.off("swapDoc",d)),e&&(o.state.foldGutter=new function(t){this.options=t,this.from=this.to=0}(function(t){!0===t&&(t={});null==t.gutter&&(t.gutter="CodeMirror-foldgutter");null==t.indicatorOpen&&(t.indicatorOpen="CodeMirror-foldgutter-open");null==t.indicatorFolded&&(t.indicatorFolded="CodeMirror-foldgutter-folded");return t}(e)),f(o),o.on("gutterClick",a),o.on("changes",d),o.on("viewportChange",u),o.on("fold",l),o.on("unfold",l),o.on("swapDoc",d))});var o=t.Pos;function e(t,e){for(var r=t.findMarks(o(e,0),o(e+1,0)),n=0;n<r.length;++n)if(r[n].__isFold){var i=r[n].find(-1);if(i&&i.line===e)return r[n]}}function r(t){if("string"==typeof t){var o=document.createElement("div");return o.className=t+" CodeMirror-guttermarker-subtle",o}return t.cloneNode(!0)}function n(t,n,f){var a=t.state.foldGutter.options,d=n-1,u=t.foldOption(a,"minFoldSize"),l=t.foldOption(a,"rangeFinder"),c="string"==typeof a.indicatorFolded&&i(a.indicatorFolded),s="string"==typeof a.indicatorOpen&&i(a.indicatorOpen);t.eachLine(n,f,function(n){++d;var i=null,f=n.gutterMarkers;if(f&&(f=f[a.gutter]),e(t,d)){if(c&&f&&c.test(f.className))return;i=r(a.indicatorFolded)}else{var p=o(d,0),m=l&&l(t,p);if(m&&m.to.line-m.from.line>=u){if(s&&f&&s.test(f.className))return;i=r(a.indicatorOpen)}}(i||f)&&t.setGutterMarker(n,a.gutter,i)})}function i(t){return new RegExp("(^|\\s)"+t+"(?:$|\\s)\\s*")}function f(t){var o=t.getViewport(),e=t.state.foldGutter;e&&(t.operation(function(){n(t,o.from,o.to)}),e.from=o.from,e.to=o.to)}function a(t,r,n){var i=t.state.foldGutter;if(i){var f=i.options;if(n==f.gutter){var a=e(t,r);a?a.clear():t.foldCode(o(r,0),f)}}}function d(t){var o=t.state.foldGutter;if(o){var e=o.options;o.from=o.to=0,clearTimeout(o.changeUpdate),o.changeUpdate=setTimeout(function(){f(t)},e.foldOnChangeTimeSpan||600)}}function u(t){var o=t.state.foldGutter;if(o){var e=o.options;clearTimeout(o.changeUpdate),o.changeUpdate=setTimeout(function(){var e=t.getViewport();o.from==o.to||e.from-o.to>20||o.from-e.to>20?f(t):t.operation(function(){e.from<o.from&&(n(t,e.from,o.from),o.from=e.from),e.to>o.to&&(n(t,o.to,e.to),o.to=e.to)})},e.updateViewportTimeSpan||400)}}function l(t,o){var e=t.state.foldGutter;if(e){var r=o.line;r>=e.from&&r<e.to&&n(t,r,r+1)}}});
|
@ -1 +0,0 @@
|
||||
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";function n(n,t){var i=n.getLine(t),o=i.search(/\S/);return-1==o||/\bcomment\b/.test(n.getTokenTypeAt(e.Pos(t,o+1)))?-1:e.countColumn(i,null,n.getOption("tabSize"))}e.registerHelper("fold","indent",function(t,i){var o=n(t,i.line);if(!(o<0)){for(var r=null,l=i.line+1,f=t.lastLine();l<=f;++l){var u=n(t,l);if(-1==u);else{if(!(u>o))break;r=l}}return r?{from:e.Pos(i.line,t.getLine(i.line).length),to:e.Pos(r,t.getLine(r).length)}:void 0}})});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(e){"use strict";e.defineMode("yaml",function(){var e=new RegExp("\\b(("+["true","false","on","off","yes","no"].join(")|(")+"))$","i");return{token:function(i,t){var r=i.peek(),n=t.escaped;if(t.escaped=!1,"#"==r&&(0==i.pos||/\s/.test(i.string.charAt(i.pos-1))))return i.skipToEnd(),"comment";if(i.match(/^('([^']|\\.)*'?|"([^"]|\\.)*"?)/))return"string";if(t.literal&&i.indentation()>t.keyCol)return i.skipToEnd(),"string";if(t.literal&&(t.literal=!1),i.sol()){if(t.keyCol=0,t.pair=!1,t.pairStart=!1,i.match(/---/))return"def";if(i.match(/\.\.\./))return"def";if(i.match(/\s*-\s+/))return"meta"}if(i.match(/^(\{|\}|\[|\])/))return"{"==r?t.inlinePairs++:"}"==r?t.inlinePairs--:"["==r?t.inlineList++:t.inlineList--,"meta";if(t.inlineList>0&&!n&&","==r)return i.next(),"meta";if(t.inlinePairs>0&&!n&&","==r)return t.keyCol=0,t.pair=!1,t.pairStart=!1,i.next(),"meta";if(t.pairStart){if(i.match(/^\s*(\||\>)\s*/))return t.literal=!0,"meta";if(i.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i))return"variable-2";if(0==t.inlinePairs&&i.match(/^\s*-?[0-9\.\,]+\s?$/))return"number";if(t.inlinePairs>0&&i.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/))return"number";if(i.match(e))return"keyword"}return!t.pair&&i.match(/^\s*(?:[,\[\]{}&*!|>'"%@`][^\s'":]|[^,\[\]{}#&*!|>'"%@`])[^#]*?(?=\s*:($|\s))/)?(t.pair=!0,t.keyCol=i.indentation(),"atom"):t.pair&&i.match(/^:\s*/)?(t.pairStart=!0,"meta"):(t.pairStart=!1,t.escaped="\\"==r,i.next(),null)},startState:function(){return{pair:!1,pairStart:!1,keyCol:0,inlinePairs:0,inlineList:0,literal:!1,escaped:!1}},lineComment:"#",fold:"indent"}}),e.defineMIME("text/x-yaml","yaml"),e.defineMIME("text/yaml","yaml")});
|
@ -1 +0,0 @@
|
||||
.cm-s-dracula.CodeMirror,.cm-s-dracula .CodeMirror-gutters{background-color:#282a36 !important;color:#f8f8f2 !important;border:0}.cm-s-dracula .CodeMirror-gutters{color:#282a36}.cm-s-dracula .CodeMirror-cursor{border-left:solid thin #f8f8f0}.cm-s-dracula .CodeMirror-linenumber{color:#6d8a88}.cm-s-dracula .CodeMirror-selected{background:rgba(255,255,255,0.10)}.cm-s-dracula .CodeMirror-line::selection,.cm-s-dracula .CodeMirror-line>span::selection,.cm-s-dracula .CodeMirror-line>span>span::selection{background:rgba(255,255,255,0.10)}.cm-s-dracula .CodeMirror-line::-moz-selection,.cm-s-dracula .CodeMirror-line>span::-moz-selection,.cm-s-dracula .CodeMirror-line>span>span::-moz-selection{background:rgba(255,255,255,0.10)}.cm-s-dracula span.cm-comment{color:#6272a4}.cm-s-dracula span.cm-string,.cm-s-dracula span.cm-string-2{color:#f1fa8c}.cm-s-dracula span.cm-number{color:#bd93f9}.cm-s-dracula span.cm-variable{color:#50fa7b}.cm-s-dracula span.cm-variable-2{color:white}.cm-s-dracula span.cm-def{color:#50fa7b}.cm-s-dracula span.cm-operator{color:#ff79c6}.cm-s-dracula span.cm-keyword{color:#ff79c6}.cm-s-dracula span.cm-atom{color:#bd93f9}.cm-s-dracula span.cm-meta{color:#f8f8f2}.cm-s-dracula span.cm-tag{color:#ff79c6}.cm-s-dracula span.cm-attribute{color:#50fa7b}.cm-s-dracula span.cm-qualifier{color:#50fa7b}.cm-s-dracula span.cm-property{color:#66d9ef}.cm-s-dracula span.cm-builtin{color:#50fa7b}.cm-s-dracula span.cm-variable-3,.cm-s-dracula span.cm-type{color:#ffb86c}.cm-s-dracula .CodeMirror-activeline-background{background:rgba(255,255,255,0.1)}.cm-s-dracula .CodeMirror-matchingbracket{text-decoration:underline;color:white !important}
|
File diff suppressed because one or more lines are too long
15
luci-app-autoupdate/Makefile
Executable file
15
luci-app-autoupdate/Makefile
Executable file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2020-2022 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-autoupdate
|
||||
PKG_VERSION:=2.8
|
||||
PKG_RELEASE:=2
|
||||
|
||||
LUCI_TITLE:=LuCI Support for autoupdate
|
||||
LUCI_DEPENDS:=+autoupdate
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
3
luci-app-autoupdate/README.md
Executable file
3
luci-app-autoupdate/README.md
Executable file
@ -0,0 +1,3 @@
|
||||
# luci-app-autoupdate
|
||||
|
||||
此项目需要搭配 [AutoBuild-Actions](https://github.com/Hyy2001X/AutoBuild-Actions) 使用
|
17
luci-app-autoupdate/luasrc/controller/autoupdate.lua
Executable file
17
luci-app-autoupdate/luasrc/controller/autoupdate.lua
Executable file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.autoupdate",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/autoupdate") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "system", "autoupdate"}, alias("admin", "system", "autoupdate", "main"), _("AutoUpdate"), 99).dependent = true
|
||||
entry({"admin", "system", "autoupdate", "main"}, cbi("autoupdate/main"), _("Scheduled Upgrade"), 10).leaf = true
|
||||
entry({"admin", "system", "autoupdate", "manual"}, cbi("autoupdate/manual"), _("Manually Upgrade"), 20).leaf = true
|
||||
entry({"admin", "system", "autoupdate", "log"}, form("autoupdate/log"), _("Upgrade Log"), 30).leaf = true
|
||||
entry({"admin", "system", "autoupdate", "print_log"}, call("print_log")).leaf = true
|
||||
end
|
||||
|
||||
local logfile = luci.sys.exec("autoupdate --env Log_Full")
|
||||
function print_log()
|
||||
luci.http.write(luci.sys.exec("tail -n 50 " .. logfile .. " 2> /dev/null"))
|
||||
end
|
6
luci-app-autoupdate/luasrc/model/cbi/autoupdate/log.lua
Executable file
6
luci-app-autoupdate/luasrc/model/cbi/autoupdate/log.lua
Executable file
@ -0,0 +1,6 @@
|
||||
log = SimpleForm("autoupdate")
|
||||
log.reset = false
|
||||
log.submit = false
|
||||
log:append(Template("autoupdate/autoupdate_log"))
|
||||
|
||||
return log
|
80
luci-app-autoupdate/luasrc/model/cbi/autoupdate/main.lua
Executable file
80
luci-app-autoupdate/luasrc/model/cbi/autoupdate/main.lua
Executable file
@ -0,0 +1,80 @@
|
||||
m = Map("autoupdate", translate("AutoUpdate"),
|
||||
translate("AutoUpdate LUCI supports scheduled upgrade & one-click firmware upgrade")
|
||||
.. [[<br /><br /><a href="https://github.com/Hyy2001X/AutoBuild-Actions">]]
|
||||
.. translate("Powered by AutoBuild-Actions")
|
||||
.. [[</a>]]
|
||||
)
|
||||
|
||||
s = m:section(TypedSection, "autoupdate")
|
||||
s.anonymous = true
|
||||
|
||||
local default_url = luci.sys.exec("autoupdate --env Github")
|
||||
local default_flag = luci.sys.exec("autoupdate --env TARGET_FLAG")
|
||||
local default_logpath = luci.sys.exec("autoupdate --env Log_Path")
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"), translate("Automatically update firmware during the specified time when Enabled"))
|
||||
enable.default = 0
|
||||
enable.optional = false
|
||||
|
||||
proxy = s:option(Flag, "proxy", translate("Preference Mirror Speedup"), translate("Preference Mirror for speeding up downloads while upgrading (For Mainland)"))
|
||||
proxy.default = 1
|
||||
proxy:depends("enable", "1")
|
||||
proxy.optional = false
|
||||
|
||||
proxy_type = s:option(ListValue, "proxy_type", translate("Mirror Station"))
|
||||
proxy_type.default = "A"
|
||||
proxy_type:value("A", translate("Automatic selection (Recommend)"))
|
||||
proxy_type:value("G", translate("GitHub Proxy - Ghproxy (Maybe faster)"))
|
||||
proxy_type:value("F", translate("FastGit UK"))
|
||||
proxy_type:depends("proxy", "1")
|
||||
proxy_type.optional = false
|
||||
|
||||
advanced = s:option(Flag, "advanced", translate("Advanced Settings"))
|
||||
advanced.default = 0
|
||||
advanced:depends("enable", "1")
|
||||
|
||||
advanced_settings = s:option(MultiValue, "advanced_settings", translate("Advanced Settings"), translate("Supported Multi Selection"))
|
||||
advanced_settings:value("--skip-verify", translate("Skip SHA256 Verify"))
|
||||
advanced_settings:value("-F", translate("Force Flash Firmware"))
|
||||
advanced_settings:value("--decompress", translate("Decompress [img.gz] Firmware"))
|
||||
advanced_settings:value("-n", translate("Upgrade without keeping config"))
|
||||
advanced_settings:depends("advanced", "1")
|
||||
advanced.description = translate("Please don't select it unless you know what you're doing!")
|
||||
|
||||
week = s:option(ListValue, "week", translate("Update Day"), translate("Recommend to set the AUTOUPDATE time to an uncommon time"))
|
||||
week:value(7, translate("Everyday"))
|
||||
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:value(0, translate("Sunday"))
|
||||
week.default = 0
|
||||
week:depends("enable", "1")
|
||||
|
||||
hour = s:option(Value, "hour", translate("Hour"))
|
||||
hour.datatype = "range(0,23)"
|
||||
hour.rmempty = true
|
||||
hour.default = 0
|
||||
hour:depends("enable", "1")
|
||||
|
||||
minute = s:option(Value, "minute", translate("Minute"))
|
||||
minute.datatype = "range(0,59)"
|
||||
minute.rmempty = true
|
||||
minute.default = 30
|
||||
minute:depends("enable", "1")
|
||||
|
||||
github = s:option(Value, "github", translate("Github Url"), translate("For detecting cloud version and downloading firmware"))
|
||||
github.default = default_url
|
||||
github.rmempty = false
|
||||
|
||||
flag = s:option(Value, "flag", translate("Firmware Flag"))
|
||||
flag.default = default_flag
|
||||
flag.rmempty = false
|
||||
|
||||
logpath = s:option(Value, "logpath", translate("Log Path"))
|
||||
logpath.default = default_logpath
|
||||
logpath.rmempty = false
|
||||
|
||||
return m
|
47
luci-app-autoupdate/luasrc/model/cbi/autoupdate/manual.lua
Executable file
47
luci-app-autoupdate/luasrc/model/cbi/autoupdate/manual.lua
Executable file
@ -0,0 +1,47 @@
|
||||
m = Map("autoupdate",translate("Manually Upgrade"),translate("Manually upgrade Firmware or Script"))
|
||||
s = m:section(TypedSection,"autoupdate")
|
||||
s.anonymous = true
|
||||
|
||||
local local_version = luci.sys.exec ("autoupdate -V")
|
||||
local local_script_version = luci.sys.exec ("autoupdate -v")
|
||||
|
||||
check_updates = s:option (Button, "_check_updates", translate("Check Updates"),translate("Please wait for the page to refresh after clicking Check Updates button"))
|
||||
check_updates.inputtitle = translate ("Check Updates")
|
||||
check_updates.write = function()
|
||||
luci.sys.call ("autoupdate -V Cloud > /tmp/Cloud_Version")
|
||||
luci.sys.call ("autoupdate -v Cloud > /tmp/Cloud_Script_Version")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "system", "autoupdate", "manual"))
|
||||
end
|
||||
|
||||
local cloud_version = luci.sys.exec ("cat /tmp/Cloud_Version 2> /dev/null")
|
||||
local cloud_script_version = luci.sys.exec ("cat /tmp/Cloud_Script_Version 2> /dev/null")
|
||||
|
||||
upgrade_fw = s:option (Button, "_upgrade_fw", translate("Upgrade Firmware"),translate("Upgrade Normally (KEEP CONFIG)") .. "<br><br>当前固件版本: " .. local_version .. "<br>云端固件版本: " .. cloud_version)
|
||||
upgrade_fw.inputtitle = translate ("Do Upgrade")
|
||||
upgrade_fw.write = function()
|
||||
luci.sys.call ("autoupdate -u > /dev/null &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "system", "autoupdate", "log"))
|
||||
end
|
||||
|
||||
upgrade_fw_force = s:option (Button, "_upgrade_fw_force", translate("Upgrade Firmware"),translate("Upgrade with Force Flashing (DANGEROUS)"))
|
||||
upgrade_fw_force.inputtitle = translate ("Do Upgrade")
|
||||
upgrade_fw_force.write = function()
|
||||
luci.sys.call ("autoupdate -u -F > /dev/null &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "system", "autoupdate", "log"))
|
||||
end
|
||||
|
||||
upgrade_fw_n = s:option (Button, "_upgrade_fw_n", translate("Upgrade Firmware"),translate("Upgrade without keeping System-Config"))
|
||||
upgrade_fw_n.inputtitle = translate ("Do Upgrade")
|
||||
upgrade_fw_n.write = function()
|
||||
luci.sys.call ("autoupdate -u -n > /dev/null &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "system", "autoupdate", "log"))
|
||||
end
|
||||
|
||||
upgrade_script = s:option (Button, "_upgrade_script", translate("Upgrade Script"),translate("Using the latest Script may solve some compatibility problems") .. "<br><br>当前脚本版本: " .. local_script_version .. "<br>云端脚本版本: " .. cloud_script_version)
|
||||
upgrade_script.inputtitle = translate ("Do Upgrade")
|
||||
upgrade_script.write = function()
|
||||
luci.sys.call ("autoupdate -x -P > /dev/null &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "system", "autoupdate", "log"))
|
||||
end
|
||||
|
||||
return m
|
20
luci-app-autoupdate/luasrc/view/autoupdate/autoupdate_log.htm
Executable file
20
luci-app-autoupdate/luasrc/view/autoupdate/autoupdate_log.htm
Executable file
@ -0,0 +1,20 @@
|
||||
<% local module = require "luci.dispatcher" -%>
|
||||
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clearlog(btn) {
|
||||
}
|
||||
XHR.poll(2, '<%=module.build_url("admin/system/autoupdate/print_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<fieldset class="cbi-section" id="_log_fieldset" >
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: 100%;margin-top: 10px;" data-update="change" rows="30" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
104
luci-app-autoupdate/po/zh-cn/autoupdate.po
Executable file
104
luci-app-autoupdate/po/zh-cn/autoupdate.po
Executable file
@ -0,0 +1,104 @@
|
||||
msgid "AutoUpdate"
|
||||
msgstr "固件更新"
|
||||
|
||||
msgid "AutoUpdate LUCI supports scheduled upgrade & one-click firmware upgrade"
|
||||
msgstr "固件更新 LUCI 支持定时更新固件 & 一键更新固件"
|
||||
|
||||
msgid "Scheduled Upgrade"
|
||||
msgstr "定时更新"
|
||||
|
||||
msgid "Manually Upgrade"
|
||||
msgstr "手动更新"
|
||||
|
||||
msgid "Manually upgrade Firmware or Script"
|
||||
msgstr "手动更新固件或脚本"
|
||||
|
||||
msgid "Upgrade Log"
|
||||
msgstr "更新日志"
|
||||
|
||||
msgid "Preference Mirror Speedup"
|
||||
msgstr "镜像加速"
|
||||
|
||||
msgid "Mirror Station"
|
||||
msgstr "镜像站"
|
||||
|
||||
msgid "Automatic selection (Recommend)"
|
||||
msgstr "自动选择 (推荐)"
|
||||
|
||||
msgid "GitHub Proxy - Ghproxy (Maybe faster)"
|
||||
msgstr "GitHub Proxy - Ghproxy (也许更快)"
|
||||
|
||||
msgid "FastGit UK"
|
||||
msgstr "FastGit UK"
|
||||
|
||||
msgid "Preference Mirror for speeding up downloads while upgrading (For Mainland)"
|
||||
msgstr "定时更新固件时优先启用镜像加速 (适用与被墙地区)"
|
||||
|
||||
msgid "Advanced Settings"
|
||||
msgstr "高级设置"
|
||||
|
||||
msgid "Supported Multi Selection"
|
||||
msgstr "支持同时勾选多个选项"
|
||||
|
||||
msgid "Skip SHA256 Verify"
|
||||
msgstr "跳过固件 SHA256 校验"
|
||||
|
||||
msgid "Force Flash Firmware"
|
||||
msgstr "强制刷写固件"
|
||||
|
||||
msgid "Decompress [img.gz] Firmware"
|
||||
msgstr "解压 [img.gz] 格式固件"
|
||||
|
||||
msgid "Upgrade without keeping config"
|
||||
msgstr "不保留配置"
|
||||
|
||||
msgid "Please don't select it unless you know what you're doing!"
|
||||
msgstr "请勿随意勾选除非你知道自己在做什么!"
|
||||
|
||||
msgid "Recommend to set the AUTOUPDATE time to an uncommon time"
|
||||
msgstr "建议设置定时更新时间为设备不常用的时间"
|
||||
|
||||
msgid "Update Day"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Github Url"
|
||||
msgstr "Github 地址"
|
||||
|
||||
msgid "For detecting cloud version and downloading firmware"
|
||||
msgstr "用于检测固件版本更新以及下载固件的地址"
|
||||
|
||||
msgid "Firmware Flag"
|
||||
msgstr "固件标签"
|
||||
|
||||
msgid "Log Path"
|
||||
msgstr "日志路径"
|
||||
|
||||
msgid "Do Upgrade"
|
||||
msgstr "执行更新"
|
||||
|
||||
msgid "Upgrade Firmware"
|
||||
msgstr "更新固件"
|
||||
|
||||
msgid "Automatically update firmware during the specified time when Enabled"
|
||||
msgstr "启用后,将在指定时间段自动检查并更新固件"
|
||||
|
||||
msgid "Upgrade without keeping System-Config"
|
||||
msgstr "更新固件 (不保留配置)"
|
||||
|
||||
msgid "Upgrade with Force Flashing (DANGEROUS)"
|
||||
msgstr "更新固件且强制刷入固件 (危险)"
|
||||
|
||||
msgid "Upgrade Normally (KEEP CONFIG)"
|
||||
msgstr "更新固件 (保留配置)"
|
||||
|
||||
msgid "Using the latest Script may solve some compatibility problems"
|
||||
msgstr "使用最新脚本也许能解决一些兼容性问题"
|
||||
|
||||
msgid "Upgrade Script"
|
||||
msgstr "更新脚本"
|
||||
|
||||
msgid "Check Updates"
|
||||
msgstr "检查更新"
|
||||
|
||||
msgid "Please wait for the page to refresh after clicking Check Updates button"
|
||||
msgstr "点击检查更新按钮后请等待页面自动刷新"
|
101
luci-app-autoupdate/po/zh_Hans/autoupdate.po
Executable file
101
luci-app-autoupdate/po/zh_Hans/autoupdate.po
Executable file
@ -0,0 +1,101 @@
|
||||
msgid "AutoUpdate"
|
||||
msgstr "固件更新"
|
||||
|
||||
msgid "AutoUpdate LUCI supports scheduled upgrade & one-click firmware upgrade"
|
||||
msgstr "固件更新 LUCI 支持定时更新固件 & 一键更新固件"
|
||||
|
||||
msgid "Scheduled Upgrade"
|
||||
msgstr "定时更新"
|
||||
|
||||
msgid "Manually Upgrade"
|
||||
msgstr "手动更新"
|
||||
|
||||
msgid "Manually upgrade Firmware or Script"
|
||||
msgstr "手动更新固件或脚本"
|
||||
|
||||
msgid "Upgrade Log"
|
||||
msgstr "更新日志"
|
||||
|
||||
msgid "Preference Mirror Speedup"
|
||||
msgstr "镜像加速"
|
||||
|
||||
msgid "Mirror Station"
|
||||
msgstr "镜像站"
|
||||
|
||||
msgid "Automatic selection (Recommend)"
|
||||
msgstr "自动选择 (推荐)"
|
||||
|
||||
msgid "GitHub Proxy - Ghproxy (Maybe faster)"
|
||||
msgstr "GitHub Proxy - Ghproxy (也许更快)"
|
||||
|
||||
msgid "FastGit UK"
|
||||
msgstr "FastGit UK"
|
||||
|
||||
msgid "Preference Mirror for speeding up downloads while upgrading (For Mainland)"
|
||||
msgstr "定时更新固件时优先启用镜像加速 (适用与被墙地区)"
|
||||
|
||||
msgid "Advanced Settings"
|
||||
msgstr "高级设置"
|
||||
|
||||
msgid "Supported Multi Selection"
|
||||
msgstr "支持同时勾选多个选项"
|
||||
|
||||
msgid "Skip SHA256 Verify"
|
||||
msgstr "跳过固件 SHA256 校验"
|
||||
|
||||
msgid "Force Flash Firmware"
|
||||
msgstr "强制刷写固件"
|
||||
|
||||
msgid "Decompress [img.gz] Firmware"
|
||||
msgstr "解压 [img.gz] 格式固件"
|
||||
|
||||
msgid "Upgrade without keeping config"
|
||||
msgstr "不保留配置"
|
||||
|
||||
msgid "Please don't select it unless you know what you're doing!"
|
||||
msgstr "请勿随意勾选除非你知道自己在做什么!"
|
||||
|
||||
msgid "Recommend to set the AUTOUPDATE time to an uncommon time"
|
||||
msgstr "建议设置定时更新时间为设备不常用的时间"
|
||||
|
||||
msgid "Update Day"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Github Url"
|
||||
msgstr "Github 地址"
|
||||
|
||||
msgid "For detecting cloud version and downloading firmware"
|
||||
msgstr "用于检测固件版本更新以及下载固件的地址"
|
||||
|
||||
msgid "Firmware Flag"
|
||||
msgstr "固件标签"
|
||||
|
||||
msgid "Do Upgrade"
|
||||
msgstr "执行更新"
|
||||
|
||||
msgid "Upgrade Firmware"
|
||||
msgstr "更新固件"
|
||||
|
||||
msgid "Automatically update firmware during the specified time when Enabled"
|
||||
msgstr "启用后,将在指定时间段自动检查并更新固件"
|
||||
|
||||
msgid "Upgrade without keeping System-Config"
|
||||
msgstr "更新固件 (不保留配置)"
|
||||
|
||||
msgid "Upgrade with Force Flashing (DANGEROUS)"
|
||||
msgstr "更新固件且强制刷入固件 (危险)"
|
||||
|
||||
msgid "Upgrade Normally (KEEP CONFIG)"
|
||||
msgstr "更新固件 (保留配置)"
|
||||
|
||||
msgid "Using the latest Script may solve some compatibility problems"
|
||||
msgstr "使用最新脚本也许能解决一些兼容性问题"
|
||||
|
||||
msgid "Upgrade Script"
|
||||
msgstr "更新脚本"
|
||||
|
||||
msgid "Check Updates"
|
||||
msgstr "检查更新"
|
||||
|
||||
msgid "Please wait for the page to refresh after clicking Check Updates button"
|
||||
msgstr "点击检查更新按钮后请等待页面自动刷新"
|
8
luci-app-autoupdate/root/etc/autoupdate/custom
Executable file
8
luci-app-autoupdate/root/etc/autoupdate/custom
Executable file
@ -0,0 +1,8 @@
|
||||
## 请在下方输入你的自定义变量,一行填写一个变量
|
||||
## 该文件将在运行 autoupdate 脚本时被读取, 且该文件中的内容优先级高于 default
|
||||
#
|
||||
## 示例(添加时不含注释):
|
||||
# Author=Hyy2001
|
||||
# TARGET_PROFILE=x86_64
|
||||
# Github=https://github.com/Hyy2001X/AutoBuild-Actions
|
||||
#
|
2
luci-app-autoupdate/root/etc/config/autoupdate
Executable file
2
luci-app-autoupdate/root/etc/config/autoupdate
Executable file
@ -0,0 +1,2 @@
|
||||
config autoupdate
|
||||
option enable '0'
|
61
luci-app-autoupdate/root/etc/init.d/autoupdate
Executable file
61
luci-app-autoupdate/root/etc/init.d/autoupdate
Executable file
@ -0,0 +1,61 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
LOGGER="logger -t [AutoUpdate]"
|
||||
|
||||
Script_File="$(command -v autoupdate)"
|
||||
Script_Cmd="$Script_File -u"
|
||||
|
||||
start() {
|
||||
local basic_list="enable proxy proxy_type advanced_settings github flag logpath week minute hour"
|
||||
for i in $(echo $basic_list);do
|
||||
local eval $i="$(uci_get_by_type autoupdate 0 $i)"
|
||||
done;unset i
|
||||
if [ ! "${Script_File}" ]
|
||||
then
|
||||
${LOGGER} "Unable to access autoupdate,exit ..."
|
||||
stop
|
||||
exit 1
|
||||
else
|
||||
chmod 777 ${Script_File} 2> /dev/null
|
||||
fi
|
||||
if [ "$enable" == 1 ]
|
||||
then
|
||||
[ "$week" == 7 ] && week='*'
|
||||
[ "$proxy" == 1 ] && Script_Cmd="$Script_Cmd -P $proxy_type"
|
||||
Script_Cmd="$Script_Cmd $advanced_settings"
|
||||
${LOGGER} "Creating corn_task [$minute $hour * * $week $Script_Cmd] ..."
|
||||
echo "$minute $hour * * $week $Script_Cmd ## AutoUpdate crontab" >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart
|
||||
else
|
||||
${LOGGER} "AutoUpdate Service is disabled ..."
|
||||
stop
|
||||
fi
|
||||
${LOGGER} "Setting Github URL to $github ..."
|
||||
${LOGGER} "Setting Flag to $flag ..."
|
||||
${LOGGER} "Setting Log Path to $logpath ..."
|
||||
$Script_File -C $github > /dev/null 2>&1
|
||||
$Script_File --flag $flag > /dev/null 2>&1
|
||||
$Script_File --log -path $logpath > /dev/null 2>&1
|
||||
}
|
||||
|
||||
stop() {
|
||||
${LOGGER} "Removing all corn tasks ..."
|
||||
sed -i '/## AutoUpdate crontab/d' /etc/crontabs/root 2> /dev/null
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
disable() {
|
||||
${LOGGER} "Closing AutoUpdate Service ..."
|
||||
uci set autoupdate.@autoupdate[0].enable="0" 2> /dev/null
|
||||
stop
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "autoupdate"
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get autoupdate.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
10
luci-app-autoupdate/root/etc/uci-defaults/luci-autoupdate
Executable file
10
luci-app-autoupdate/root/etc/uci-defaults/luci-autoupdate
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@autoupdate[-1]
|
||||
add ucitrack autoupdate
|
||||
set ucitrack.@autoupdate[-1].init=autoupdate
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-autoupdate": {
|
||||
"description": "Grant UCI access for luci-app-autoupdate",
|
||||
"read": {
|
||||
"uci": [ "autoupdate" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "autoupdate" ]
|
||||
}
|
||||
}
|
||||
}
|
13
luci-app-iperf3-server/Makefile
Executable file
13
luci-app-iperf3-server/Makefile
Executable file
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2020-2021 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for iPerf3
|
||||
LUCI_DEPENDS:=+iperf3
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=3
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
3
luci-app-iperf3-server/README.md
Executable file
3
luci-app-iperf3-server/README.md
Executable file
@ -0,0 +1,3 @@
|
||||
# luci-app-iperf3-server
|
||||
|
||||
一个简单的 iPerf3 服务端
|
17
luci-app-iperf3-server/luasrc/controller/iperf3-server.lua
Executable file
17
luci-app-iperf3-server/luasrc/controller/iperf3-server.lua
Executable file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.iperf3-server",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/iperf3-server") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "iperf3-server"}, cbi("iperf3-server"), _("iPerf3 Server"),99)
|
||||
entry({"admin", "services", "iperf3-server", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pgrep iperf3 > /dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
36
luci-app-iperf3-server/luasrc/model/cbi/iperf3-server.lua
Executable file
36
luci-app-iperf3-server/luasrc/model/cbi/iperf3-server.lua
Executable file
@ -0,0 +1,36 @@
|
||||
m = Map("iperf3-server", translate("iPerf3 Server"), translate("iPerf3 - The ultimate speed test tool for TCP, UDP and SCTP"))
|
||||
|
||||
m:section(SimpleSection).template = "iperf3-server/iperf3-server_status"
|
||||
|
||||
s = m:section(TypedSection, "iperf3-server", "")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
main_enable = s:option(Flag, "main_enable", translate("Enable"), translate("Enable iPerf3 Servers"))
|
||||
main_enable.default = "0"
|
||||
main_enable.rmempty = false
|
||||
|
||||
s = m:section(TypedSection, "servers", translate("Server Settings"), translate("Set up Multi-iPerf3 Servers"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
enable_server = s:option(Flag, "enable_server", translate("Enable"))
|
||||
enable_server.default = "1"
|
||||
enable_server.rmempty = false
|
||||
|
||||
port = s:option(Value, "port", translate("Port"))
|
||||
port.datatype = "port"
|
||||
port.default = "5201"
|
||||
port.rmempty = false
|
||||
|
||||
delay = s:option(Value, "delay", translate("Start delay (Seconds)"))
|
||||
delay.default = "0"
|
||||
delay.datatype = "uinteger"
|
||||
delay.rmempty = false
|
||||
|
||||
extra_options = s:option(Value, "extra_options", translate("Extra Options"))
|
||||
extra_options.rmempty = true
|
||||
extra_options.password= false
|
||||
|
||||
return m
|
22
luci-app-iperf3-server/luasrc/view/iperf3-server/iperf3-server_status.htm
Executable file
22
luci-app-iperf3-server/luasrc/view/iperf3-server/iperf3-server_status.htm
Executable file
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[iperf3-server]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('iperf3-server_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>iPerf3 Server <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>iPerf3 Server <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="iperf3-server_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
26
luci-app-iperf3-server/po/zh-cn/iperf3-server.po
Executable file
26
luci-app-iperf3-server/po/zh-cn/iperf3-server.po
Executable file
@ -0,0 +1,26 @@
|
||||
msgid "iPerf3 - The ultimate speed test tool for TCP, UDP and SCTP"
|
||||
msgstr "iPerf3 是一款集 TCP UDP 和 SCTP 于的一身的终极速度测试工具"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "iPerf3 Server"
|
||||
msgstr "iPerf3 服务器"
|
||||
|
||||
msgid "Enable iPerf3 Servers"
|
||||
msgstr "启用 iPerf3 服务器"
|
||||
|
||||
msgid "Server Settings"
|
||||
msgstr "服务端设置"
|
||||
|
||||
msgid "Set up Multi-iPerf3 Servers"
|
||||
msgstr "设置多个 iPerf3 服务端"
|
||||
|
||||
msgid "Start delay"
|
||||
msgstr "启动延迟 (秒)"
|
||||
|
||||
msgid "iPerf3 Server listening port"
|
||||
msgstr "iPerf3 服务端监听端口"
|
||||
|
||||
msgid "Extra Options"
|
||||
msgstr "额外参数"
|
26
luci-app-iperf3-server/po/zh_Hans/iperf3-server.po
Executable file
26
luci-app-iperf3-server/po/zh_Hans/iperf3-server.po
Executable file
@ -0,0 +1,26 @@
|
||||
msgid "iPerf3 - The ultimate speed test tool for TCP, UDP and SCTP"
|
||||
msgstr "iPerf3 是一款集 TCP UDP 和 SCTP 于的一身的终极速度测试工具"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "iPerf3 Server"
|
||||
msgstr "iPerf3 服务器"
|
||||
|
||||
msgid "Enable iPerf3 Servers"
|
||||
msgstr "启用 iPerf3 服务器"
|
||||
|
||||
msgid "Server Settings"
|
||||
msgstr "服务端设置"
|
||||
|
||||
msgid "Set up Multi-iPerf3 Servers"
|
||||
msgstr "设置多个 iPerf3 服务端"
|
||||
|
||||
msgid "Start delay"
|
||||
msgstr "启动延迟 (秒)"
|
||||
|
||||
msgid "iPerf3 Server listening port"
|
||||
msgstr "iPerf3 服务端监听端口"
|
||||
|
||||
msgid "Extra Options"
|
||||
msgstr "额外参数"
|
4
luci-app-iperf3-server/root/etc/config/iperf3-server
Executable file
4
luci-app-iperf3-server/root/etc/config/iperf3-server
Executable file
@ -0,0 +1,4 @@
|
||||
|
||||
config iperf3-server
|
||||
option enable '0'
|
||||
option port '5201'
|
57
luci-app-iperf3-server/root/etc/init.d/iperf3-server
Executable file
57
luci-app-iperf3-server/root/etc/init.d/iperf3-server
Executable file
@ -0,0 +1,57 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
LOGGER="logger -t [iPerf3-Server]"
|
||||
|
||||
start_service() {
|
||||
stop_service
|
||||
local basic_list="main_enable"
|
||||
local server_list="port delay extra_options enable_server"
|
||||
for i in $(echo $basic_list)
|
||||
do
|
||||
local eval $i="$(uci_get_by_type iperf3-server 0 $i)"
|
||||
done ; unset i
|
||||
if [ "$main_enable" == 1 ]
|
||||
then
|
||||
server_number=$(uci show iperf3-server 2> /dev/null | egrep '@servers\[[0-9]\]+=servers' | wc -l)
|
||||
# server_number=$(uci show iperf3-server 2> /dev/null | egrep -o '@servers\[[0-9]\]+=servers' | awk 'END {print}' | egrep -o "[0-9]")
|
||||
for u in $(seq 0 $((${server_number} - 1)))
|
||||
do
|
||||
{
|
||||
for i in $server_list
|
||||
do
|
||||
eval ${i}=$(uci_get_by_type servers $u $i)
|
||||
done ; unset i
|
||||
if [ "$enable_server" == 1 ]
|
||||
then
|
||||
sleep $delay
|
||||
$LOGGER "Starting iPerf3 Server [$u] with Port [$port] ..."
|
||||
# $(command -v iperf3) -s -D -p $port $extra_options
|
||||
procd_open_instance
|
||||
procd_set_param command sleep $delay ; $(command -v iperf3) -s -D -p $port $extra_options
|
||||
procd_set_param respawn 3000 3 10
|
||||
procd_close_instance
|
||||
fi
|
||||
unset enable_server delay
|
||||
} &
|
||||
done ; unset u
|
||||
else
|
||||
$LOGGER "iPerf3 Server is disabled ..."
|
||||
stop_service
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
$LOGGER "Stopping iPerf3 Server ..."
|
||||
ps -efww | grep 'iperf3 -s -D' | grep -v 'grep' | awk '{print $1}' | xargs kill -9
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "iperf3-server"
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get iperf3-server.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
10
luci-app-iperf3-server/root/etc/uci-defaults/iperf3-server
Executable file
10
luci-app-iperf3-server/root/etc/uci-defaults/iperf3-server
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@iperf3-server[-1]
|
||||
add ucitrack iperf3-server
|
||||
set ucitrack.@iperf3-server[-1].init=iperf3-server
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-iperf3-server": {
|
||||
"description": "Grant UCI access for luci-app-iperf3-server",
|
||||
"read": {
|
||||
"uci": [ "iperf3-server" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "iperf3-server" ]
|
||||
}
|
||||
}
|
||||
}
|
15
luci-app-natter/Makefile
Executable file
15
luci-app-natter/Makefile
Executable file
@ -0,0 +1,15 @@
|
||||
# Copyright (C) 2020-2022 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-natter
|
||||
PKG_VERSION:=1.1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
LUCI_TITLE:=LuCI Support for Natter
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+natter
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
3
luci-app-natter/README.md
Normal file
3
luci-app-natter/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# luci-app-natter
|
||||
|
||||
项目地址: https://github.com/MikeWang000000/Natter
|
21
luci-app-natter/luasrc/controller/natter.lua
Executable file
21
luci-app-natter/luasrc/controller/natter.lua
Executable file
@ -0,0 +1,21 @@
|
||||
module("luci.controller.natter",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/natter") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "network", "natter"}, alias("admin", "network", "natter", "base"), _("Natter"), 99).dependent = true
|
||||
entry({"admin", "network", "natter", "base"}, cbi("natter/base"), _("Base Settings"), 10).leaf = true
|
||||
entry({"admin", "network", "natter", "ports"}, cbi("natter/ports")).leaf = true
|
||||
entry({"admin", "network", "natter", "log"}, form("natter/log"), _("Log"), 20).leaf = true
|
||||
entry({"admin", "network", "natter", "print_log"}, call("print_log")).leaf = true
|
||||
entry({"admin", "network", "natter", "del_log"}, call("del_log")).leaf = true
|
||||
end
|
||||
|
||||
function print_log()
|
||||
luci.http.write(luci.sys.exec("sh /usr/share/luci-app-natter/log.sh print"))
|
||||
end
|
||||
|
||||
function del_log()
|
||||
luci.http.write(luci.sys.exec("sh /usr/share/luci-app-natter/log.sh del"))
|
||||
end
|
87
luci-app-natter/luasrc/model/cbi/natter/base.lua
Executable file
87
luci-app-natter/luasrc/model/cbi/natter/base.lua
Executable file
@ -0,0 +1,87 @@
|
||||
m = Map("natter", translate("Natter"), translate("Open Port under FullCone NAT (NAT 1)"))
|
||||
s = m:section(TypedSection, "base")
|
||||
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
local function check_file(e)
|
||||
return luci.sys.exec('ls "%s" 2> /dev/null' % e) ~= "" and true or false
|
||||
end
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.default = 0
|
||||
|
||||
enable_fullcone_nat = s:option(Flag, "enable_fullcone_nat", translate("FullCone NAT"))
|
||||
enable_fullcone_nat.default = 0
|
||||
|
||||
if check_file("/tmp/natter_nat_type") then
|
||||
natter_nat_type_tcp = luci.sys.exec ("grep TCP /tmp/natter_nat_type")
|
||||
natter_nat_type_udp = luci.sys.exec ("grep UDP /tmp/natter_nat_type")
|
||||
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"), translate("") .. "<br><br>" .. natter_nat_type_tcp .. "<br><br>" .. natter_nat_type_udp)
|
||||
else
|
||||
nat_check = s:option (Button, "nat_check", translate("Check NAT Status"))
|
||||
end
|
||||
|
||||
nat_check.inputtitle = translate("Exec")
|
||||
nat_check.write = function()
|
||||
luci.sys.call ("sh /usr/share/luci-app-natter/natcheck.sh > /tmp/natter_nat_type")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "network", "natter", "base"))
|
||||
end
|
||||
|
||||
local_ip = s:option(Value, "local_ip", translate("Local IP Address"), translate("Natter Listening Address"))
|
||||
local_ip.default = "0.0.0.0"
|
||||
local_ip.placeholder = "0.0.0.0"
|
||||
local_ip.datatype = "host"
|
||||
local_ip.rmempty = false
|
||||
|
||||
log_path = s:option(Value, "log_path", translate("Log Path"), translate("Directory to save natter logs"))
|
||||
log_path.default = "/tmp/natter"
|
||||
log_path.placeholder = "/tmp/natter"
|
||||
log_path.rmempty = false
|
||||
|
||||
keep_alive_server = s:option(Value, "keep_alive_server", translate("Keep Alive Server"), translate("Please ensure that the address can be connected by Natter"))
|
||||
keep_alive_server.rmempty = false
|
||||
|
||||
tcp_stun_server = s:option(DynamicList, "tcp_stun_server", translate("TCP STUN Server"), translate("Please DO NOT handle the IP address/domain name/port of the TCP/UDP STUN server (3478) while running proxy"))
|
||||
udp_stun_server = s:option(DynamicList, "udp_stun_server", translate("UDP STUN Server"))
|
||||
udp_stun_server.rmempty = false
|
||||
|
||||
s = m:section(TypedSection, "ports", translate("Port Settings"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = luci.dispatcher.build_url("admin", "network", "natter", "ports", "%s")
|
||||
function s.create(...)
|
||||
local sid = TypedSection.create(...)
|
||||
if sid then
|
||||
luci.http.redirect(s.extedit % sid)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
enable_port = s:option(Flag, "enable_port", translate("Enable"))
|
||||
enable_port.default = 1
|
||||
enable_port.width = "5%"
|
||||
|
||||
id = s:option(DummyValue, "id", translate("ID"))
|
||||
id.width = "8%"
|
||||
|
||||
remarks = s:option(DummyValue, "remarks", translate("Remarks"))
|
||||
remarks.width = "10%"
|
||||
|
||||
forward_mode = s:option(DummyValue, "forward_mode", translate("Forward Mode"))
|
||||
forward_mode.width = "8%"
|
||||
|
||||
external_port = s:option(DummyValue, "external_port", translate("External Port"))
|
||||
external_port.width = "12%"
|
||||
|
||||
enable_forward = s:option(Flag, "enable_forward", translate("Forward"))
|
||||
enable_forward.default = 0
|
||||
|
||||
internal_ip = s:option(DummyValue, "internal_ip", translate("Internal IP Address"))
|
||||
internal_ip.width = "12%"
|
||||
|
||||
internal_port = s:option(DummyValue, "internal_port", translate("Internal Port"))
|
||||
internal_port.width = "12%"
|
||||
|
||||
return m
|
6
luci-app-natter/luasrc/model/cbi/natter/log.lua
Executable file
6
luci-app-natter/luasrc/model/cbi/natter/log.lua
Executable file
@ -0,0 +1,6 @@
|
||||
log = SimpleForm("natter")
|
||||
log.reset = false
|
||||
log.submit = false
|
||||
log:append(Template("natter/natter_log"))
|
||||
|
||||
return log
|
65
luci-app-natter/luasrc/model/cbi/natter/ports.lua
Executable file
65
luci-app-natter/luasrc/model/cbi/natter/ports.lua
Executable file
@ -0,0 +1,65 @@
|
||||
m = Map("natter", translate("Port Settings"))
|
||||
m.redirect = luci.dispatcher.build_url("admin", "network", "natter")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "ports", "")
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
||||
enable_port = s:option(Flag, "enable_port", translate("Enable"))
|
||||
|
||||
local rand_id = luci.sys.exec("cut -d '-' -f1 /proc/sys/kernel/random/uuid 2> /dev/null")
|
||||
id = s:option(Value, "id", translate("ID"), translate("Just keep default, or ensure uniqueness"))
|
||||
id.default = rand_id
|
||||
|
||||
remarks = s:option(Value, "remarks", translate("Remarks"))
|
||||
remarks.rmempty = false
|
||||
|
||||
forward_mode = s:option(ListValue, "forward_mode", translate("Forward Mode"))
|
||||
forward_mode:value('1', translate("1 - Natter"))
|
||||
forward_mode:value('2', translate("2 - Firewall"))
|
||||
forward_mode.default = 2
|
||||
|
||||
external_port = s:option(Value, "external_port", translate("External Port"), translate("Specify the port opened by Natter"))
|
||||
external_port.datatype = "port"
|
||||
external_port:depends({forward_mode = "2"})
|
||||
|
||||
port_type = s:option(ListValue, "port_type", translate("Port Type"))
|
||||
port_type:value("udp", translate("UDP"))
|
||||
port_type:value("tcp", translate("TCP"))
|
||||
port_type:value("both", translate("TCP + UDP"))
|
||||
port_type.default = both
|
||||
port_type.rempty = false
|
||||
|
||||
enable_forward = s:option(Flag, "enable_forward", translate("Enable Port Forward"), translate("Forward opened port to internal host"))
|
||||
enable_forward.default = 1
|
||||
enable_forward.rempty = false
|
||||
|
||||
internal_ip = s:option(Value, "internal_ip", translate("Internal IP address"), translate("Internal Host IP address"))
|
||||
internal_ip.datatype = "ipmask4"
|
||||
internal_ip:depends({enable_forward = "1"})
|
||||
luci.sys.net.ipv4_hints(
|
||||
function(ip, name)
|
||||
internal_ip:value(ip, "%s (%s)" %{ ip, name })
|
||||
end)
|
||||
|
||||
internal_port = s:option(Value, "internal_port", translate("Internal Port"), translate("Internal Host Port"))
|
||||
internal_port.datatype = "port"
|
||||
internal_port:depends({enable_forward = "1"})
|
||||
|
||||
delay = s:option(Value, "delay", translate("Start delay (Seconds)"))
|
||||
delay.default = 0
|
||||
delay.datatype = "uinteger"
|
||||
delay.rmempty = false
|
||||
|
||||
log_level = s:option(ListValue, "log_level", translate("Log Level"))
|
||||
log_level:value('debug', translate("Debug"))
|
||||
log_level:value('info', translate("Info"))
|
||||
log_level:value('warning', translate("Warning"))
|
||||
log_level:value('error', translate("Error"))
|
||||
|
||||
--[[
|
||||
hook = s:option(Value, "hook", translate("Hook"))
|
||||
hook.rmempty = true
|
||||
--]]
|
||||
|
||||
return m
|
29
luci-app-natter/luasrc/view/natter/natter_log.htm
Executable file
29
luci-app-natter/luasrc/view/natter/natter_log.htm
Executable file
@ -0,0 +1,29 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function del_log(btn) {
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin/network/natter/del_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = "";
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin/network/natter/print_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
log_textarea.innerHTML = x.responseText;
|
||||
log_textarea.scrollTop = log_textarea.scrollHeight;
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<fieldset class="cbi-section" id="_log_fieldset" >
|
||||
<input class="cbi-button cbi-input-remove" type="button" onclick="del_log()" value="<%:Delete Logs%>" />
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: 100%;margin-top: 10px;" data-update="change" rows="30" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
114
luci-app-natter/po/zh-cn/natter.po
Executable file
114
luci-app-natter/po/zh-cn/natter.po
Executable file
@ -0,0 +1,114 @@
|
||||
msgid "Natter"
|
||||
msgstr "Natter"
|
||||
|
||||
msgid "Open Port under FullCone NAT (NAT 1)"
|
||||
msgstr "帮助 Full cone NAT (NAT 1) 用户打开公网端口"
|
||||
|
||||
msgid "Log Path"
|
||||
msgstr "日志路径"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志等级"
|
||||
|
||||
msgid "Base Settings"
|
||||
msgstr "基础设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "IP Address"
|
||||
msgstr "IP 地址"
|
||||
|
||||
msgid "Start delay (Seconds)"
|
||||
msgstr "启动延迟 (秒)"
|
||||
|
||||
msgid "Start delay"
|
||||
msgstr "启动延迟"
|
||||
|
||||
msgid "Port Settings"
|
||||
msgstr "端口设置"
|
||||
|
||||
msgid "TCP STUN Server"
|
||||
msgstr "TCP STUN 服务器"
|
||||
|
||||
msgid "UDP STUN Server"
|
||||
msgstr "UDP STUN 服务器"
|
||||
|
||||
msgid "Keep Alive Server"
|
||||
msgstr "Keep Alive 服务器"
|
||||
|
||||
msgid "Directory to save natter logs"
|
||||
msgstr "Natter 运行日志保存路径 (文件夹)"
|
||||
|
||||
msgid "ID"
|
||||
msgstr "标识"
|
||||
|
||||
msgid "Just keep default, or ensure uniqueness"
|
||||
msgstr "保持默认即可, 修改时请确保标识的唯一性"
|
||||
|
||||
msgid "Remarks"
|
||||
msgstr "备注"
|
||||
|
||||
msgid "Internal Port"
|
||||
msgstr "内部端口"
|
||||
|
||||
msgid "Internal Host IP address"
|
||||
msgstr "内部主机的 IP 地址"
|
||||
|
||||
msgid "Internal Host Port"
|
||||
msgstr "内部主机的端口"
|
||||
|
||||
msgid "External Port"
|
||||
msgstr "外部端口"
|
||||
|
||||
msgid "Specify the port opened by Natter"
|
||||
msgstr "指定 Natter 打开的端口"
|
||||
|
||||
msgid "Enable Port Forward"
|
||||
msgstr "启用端口转发"
|
||||
|
||||
msgid "Forward opened port to internal host"
|
||||
msgstr "将打开的端口转发至内部主机"
|
||||
|
||||
msgid "Port Type"
|
||||
msgstr "端口类型"
|
||||
|
||||
msgid "FullCone NAT"
|
||||
msgstr "FullCone NAT"
|
||||
|
||||
msgid "Please DO NOT handle the IP address/domain name/port of the TCP/UDP STUN server (3478) while running proxy"
|
||||
msgstr "请不要使用任何代理软件代理 TCP/UDP STUN 服务器的IP 地址/域名/端口 (3478)"
|
||||
|
||||
msgid "Local IP Address"
|
||||
msgstr "本地 IP 地址"
|
||||
|
||||
msgid "Natter Listening Address"
|
||||
msgstr "Natter 监听地址"
|
||||
|
||||
msgid "Please ensure that the address can be connected by Natter"
|
||||
msgstr "请确保 Keep Alive 服务器地址能被 Natter 连接"
|
||||
|
||||
msgid "Internal IP Address"
|
||||
msgstr "内部 IP 地址"
|
||||
|
||||
msgid "Forward Mode"
|
||||
msgstr "转发策略"
|
||||
|
||||
msgid "1 - Natter"
|
||||
msgstr "1 - Natter 内置"
|
||||
|
||||
msgid "2 - Firewall"
|
||||
msgstr "2 - 防火墙"
|
||||
|
||||
msgid "Delete Logs"
|
||||
msgstr "清除日志"
|
||||
|
||||
msgid "<%:Delete Logs%>"
|
||||
msgstr "清除日志"
|
||||
|
||||
msgid "Check NAT Status"
|
||||
msgstr "NAT 类型检测"
|
||||
|
||||
msgid "Exec"
|
||||
msgstr "执行"
|
||||
|
1
luci-app-natter/po/zh_Hans
Symbolic link
1
luci-app-natter/po/zh_Hans
Symbolic link
@ -0,0 +1 @@
|
||||
zh-cn
|
15
luci-app-natter/root/etc/config/natter
Executable file
15
luci-app-natter/root/etc/config/natter
Executable file
@ -0,0 +1,15 @@
|
||||
config base
|
||||
option enable '0'
|
||||
option keep_alive_server "www.baidu.com"
|
||||
list tcp_stun_server 'stun.nextcloud.com'
|
||||
list tcp_stun_server 'fwa.lifesizecloud.com'
|
||||
list tcp_stun_server 'stun.isp.net.au'
|
||||
list tcp_stun_server 'stun.freeswitch.org'
|
||||
list tcp_stun_server 'stun.voip.blackberry.com'
|
||||
list tcp_stun_server 'stun.stunprotocol.org'
|
||||
list tcp_stun_server 'stun.sipnet.com'
|
||||
list tcp_stun_server 'stun.radiojar.com'
|
||||
list tcp_stun_server 'stun.sonetel.com'
|
||||
list tcp_stun_server 'stun.voipgate.com'
|
||||
list udp_stun_server 'stun.miwifi.com'
|
||||
list udp_stun_server 'stun.qq.com'
|
235
luci-app-natter/root/etc/init.d/natter
Executable file
235
luci-app-natter/root/etc/init.d/natter
Executable file
@ -0,0 +1,235 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=98
|
||||
USE_PROCD=0
|
||||
|
||||
start_service() {
|
||||
local basic_list="enable enable_fullcone_nat log_path tcp_stun_server udp_stun_server keep_alive_url local_ip"
|
||||
local port_list="enable_port id remarks port enable_forward \
|
||||
forward_mode external_port port_type delay log_level \
|
||||
internal_ip internal_port hook"
|
||||
for i in $basic_list
|
||||
do
|
||||
local eval $i="$(uci_get_by_type base 0 $i)"
|
||||
done ; unset i
|
||||
if [ "$enable_fullcone_nat" == 1 ]
|
||||
then
|
||||
echo "Starting Natter ..."
|
||||
if [ "$(uci get firewall.@defaults[0].fullcone > /dev/null ; echo $?)" == 0 ]
|
||||
then
|
||||
if [ "$(uci get firewall.@defaults[0].fullcone)" == 0 ]
|
||||
then
|
||||
echo "Starting FullCone NAT ..."
|
||||
uci set firewall.@defaults[0].fullcone="1"
|
||||
uci commit firewall
|
||||
else
|
||||
echo "FullCone NAT was already started ..."
|
||||
fi
|
||||
else
|
||||
echo "Failed to start FullCone NAT ..."
|
||||
uci set natter.@base[0].enable_fullcone_nat="0"
|
||||
uci commit natter
|
||||
fi
|
||||
fi
|
||||
if [ "$enable" == 1 ]
|
||||
then
|
||||
include_file=/var/etc/natter.include
|
||||
echo "
|
||||
#!/bin/sh
|
||||
iptables -N natter 2> /dev/null
|
||||
iptables -I INPUT -j natter 2> /dev/null
|
||||
" \
|
||||
> $include_file
|
||||
mkdir -p ${log_path}
|
||||
iptables_remove_rule
|
||||
mkdir -p /var/etc/natter
|
||||
for u in $(seq 0 $(($(uci show natter 2> /dev/null | egrep '@ports\[[0-9]\]+=ports' | wc -l) - 1)))
|
||||
do
|
||||
for i in $port_list
|
||||
do
|
||||
local eval $i="$(uci_get_by_type ports $u $i)"
|
||||
echo "$i : $(uci_get_by_type ports $u $i)"
|
||||
done ; unset i
|
||||
|
||||
[ "$enable_port" != 1 ] && continue
|
||||
|
||||
case $port_type in
|
||||
tcp | udp)
|
||||
eval external_${port_type}="$local_ip:$external_port"
|
||||
eval internal_${port_type}="$internal_ip:$internal_port"
|
||||
iptables_type=$port_type
|
||||
;;
|
||||
both)
|
||||
external_tcp="$local_ip:$external_port"
|
||||
external_udp="$local_ip:$external_port"
|
||||
internal_tcp="$internal_ip:$internal_port"
|
||||
internal_udp="$internal_ip:$internal_port"
|
||||
iptables_type="tcp udp"
|
||||
;;
|
||||
esac
|
||||
|
||||
log_file=${log_path}/natter-${id}-${remarks}.log
|
||||
json_file=/var/etc/natter/natter-${id}-${remarks}.json
|
||||
status_file=${log_path}/natter-${id}-${remarks}.json
|
||||
|
||||
echo "{
|
||||
\"logging\": {
|
||||
\"level\": \"$log_level\",
|
||||
\"log_file\": \"${log_file}\"
|
||||
},
|
||||
\"status_report\": {
|
||||
\"hook\": \"$hook\",
|
||||
\"status_file\": \"${status_file}\"
|
||||
},
|
||||
$(
|
||||
case ${forward_mode} in
|
||||
1)
|
||||
echo "
|
||||
\"open_port\": {
|
||||
\"tcp\": [
|
||||
|
||||
],
|
||||
\"udp\": [
|
||||
|
||||
]
|
||||
},"
|
||||
echo "
|
||||
\"forward_port\": {
|
||||
\"tcp\": [
|
||||
$([ "$internal_tcp" ] && echo \"${internal_tcp}\")
|
||||
],
|
||||
\"udp\": [
|
||||
$([ "$internal_udp" ] && echo \"${internal_udp}\")
|
||||
]
|
||||
},"
|
||||
;;
|
||||
2)
|
||||
echo "
|
||||
\"open_port\": {
|
||||
\"tcp\": [
|
||||
$([ "$external_tcp" ] && echo \"${external_tcp}\")
|
||||
],
|
||||
\"udp\": [
|
||||
$([ "$external_udp" ] && echo \"${external_udp}\")
|
||||
]
|
||||
},"
|
||||
echo "
|
||||
\"forward_port\": {
|
||||
\"tcp\": [
|
||||
|
||||
],
|
||||
\"udp\": [
|
||||
|
||||
]
|
||||
},"
|
||||
;;
|
||||
esac
|
||||
)
|
||||
\"stun_server\": {
|
||||
\"tcp\": $(
|
||||
printf "["
|
||||
j=1 ; for i in $tcp_stun_server
|
||||
do
|
||||
[[ "$j" == 1 ]] && unset j || printf ", "
|
||||
printf '"%s"' $i
|
||||
done ; unset i j
|
||||
printf "],")
|
||||
\"udp\": $(
|
||||
printf "["
|
||||
j=1 ; for i in $udp_stun_server
|
||||
do
|
||||
[[ "$j" == 1 ]] && unset j || printf ", "
|
||||
printf '"%s"' $i
|
||||
done ; unset i j
|
||||
printf "]")
|
||||
},
|
||||
\"keep_alive\": \"$keep_alive_url\"
|
||||
}" \
|
||||
> $json_file
|
||||
echo "json File: $json_file"
|
||||
echo "log File: $log_file"
|
||||
echo "status File: $status_file"
|
||||
sleep $delay
|
||||
for i in $(ps -efww | egrep 'natter.py' | grep -v grep | grep -v $$ | grep "$id" | awk '{print $1}')
|
||||
do
|
||||
kill -9 "$i" 2> /dev/null
|
||||
done
|
||||
$(command -v python) /usr/share/natter/natter.py -c $json_file &
|
||||
if [ "$enable_forward" == 1 ]
|
||||
then
|
||||
case $forward_mode in
|
||||
1)
|
||||
:
|
||||
;;
|
||||
2)
|
||||
iptables -N natter 2> /dev/null
|
||||
iptables -I INPUT -j natter 2> /dev/null
|
||||
for i in $iptables_type
|
||||
do
|
||||
# iptables -A natter \
|
||||
-p $i -m $i --dport $external_port \
|
||||
-m comment --comment "nt-op-$id-$remarks" \
|
||||
-j ACCEPT
|
||||
# echo "iptables -A natter -p $i -m $i --dport $external_port -m comment --comment \"nt-op-$id-$remarks\" -j ACCEPT" >> ${include_file}
|
||||
iptables -t nat -A PREROUTING \
|
||||
-p $i -m $i --dport $external_port \
|
||||
-m comment --comment "nt-dnat-$id-$remarks" \
|
||||
-j DNAT \
|
||||
--to-destination $internal_ip:$internal_port
|
||||
echo "iptables -t nat -A PREROUTING -p $i -m $i --dport $external_port -m comment --comment \"nt-dnat-$id-$remarks\" -j DNAT --to-destination $internal_ip:$internal_port" >> ${include_file}
|
||||
done ; unset i
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
for i in $port_list
|
||||
do
|
||||
unset $(echo $i)
|
||||
done ; unset i
|
||||
unset iptables_type internal_tcp internal_udp external_tcp external_udp
|
||||
done ; unset u
|
||||
else
|
||||
echo "Natter is disabled ..."
|
||||
stop_service
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
echo "Stopping Natter ..."
|
||||
for i in $(ps -efww | egrep 'natter.py' | grep -v grep | grep -v $$ | awk '{print $1}')
|
||||
do
|
||||
kill -9 "$i" 2> /dev/null
|
||||
done
|
||||
iptables_remove_rule
|
||||
rm /var/etc/natter.include 2> /dev/null
|
||||
rm -r /var/etc/natter 2> /dev/null
|
||||
rm -r /tmp/natter 2> /dev/null
|
||||
}
|
||||
|
||||
iptables_remove_rule() {
|
||||
echo "Removing iptable rules ..."
|
||||
iptables -D INPUT -j natter 2> /dev/null
|
||||
iptables -F natter 2> /dev/null
|
||||
iptables -X natter 2> /dev/null
|
||||
iptables-save | grep -v 'nt-dnat' | iptables-restore
|
||||
}
|
||||
|
||||
stop() {
|
||||
stop_service
|
||||
}
|
||||
|
||||
start() {
|
||||
start_service
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "natter"
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get natter.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
17
luci-app-natter/root/etc/uci-defaults/luci-natter
Executable file
17
luci-app-natter/root/etc/uci-defaults/luci-natter
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@natter[-1]
|
||||
add ucitrack natter
|
||||
set ucitrack.@natter[-1].init=natter
|
||||
commit ucitrack
|
||||
|
||||
delete firewall.natter
|
||||
set firewall.natter=include
|
||||
set firewall.natter.type=script
|
||||
set firewall.natter.path=/var/etc/natter.include
|
||||
set firewall.natter.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
exit 0
|
19
luci-app-natter/root/usr/share/luci-app-natter/log.sh
Executable file
19
luci-app-natter/root/usr/share/luci-app-natter/log.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
log_path=$(uci get natter.@base[0].log_path 2> /dev/null)
|
||||
|
||||
for i in $(ls -1 ${log_path} | grep natter | grep .log)
|
||||
do
|
||||
case $1 in
|
||||
print)
|
||||
echo -e "\n======> $i <======"
|
||||
tail -n 30 ${log_path}/$i 2> /dev/null
|
||||
echo -e "======> END of $i <======"
|
||||
;;
|
||||
del)
|
||||
echo > ${log_path}/$i
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
18
luci-app-natter/root/usr/share/luci-app-natter/natcheck.sh
Executable file
18
luci-app-natter/root/usr/share/luci-app-natter/natcheck.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check=$(python3 /usr/share/natter/natter.py --check-nat 2>&1 | grep -v "Checking" | grep 'NAT Type for')
|
||||
|
||||
script_file='/usr/share/natter/natter.py'
|
||||
tmp_path=$(uci get natter.@base[0].log_path)
|
||||
[ ! "$tmp_path" ] && tmp_path=/tmp/natter
|
||||
|
||||
mkdir -p $tmp_path
|
||||
python3 $script_file --check-nat 2>&1 | grep -v "Checking" | grep 'NAT Type for' > $tmp_path/natter_nat_type.tmp
|
||||
TCP=$(awk -F '[:]+' '/TCP/{print $2}' $tmp_path/natter_nat_type.tmp | sed 's/\[//g;s/\]//g')
|
||||
UDP=$(awk -F '[:]+' '/UDP/{print $2}' $tmp_path/natter_nat_type.tmp | sed 's/\[//g;s/\]//g')
|
||||
rm -f $tmp_path/natter_nat_type.tmp
|
||||
[ ! "$TCP" ] && TCP="未知"
|
||||
[ ! "$UDP" ] && UDP="未知"
|
||||
|
||||
echo "TCP:$TCP"
|
||||
echo "UDP:$UDP"
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-natter": {
|
||||
"description": "Grant UCI access for luci-app-natter",
|
||||
"read": {
|
||||
"uci": [ "natter" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "natter" ]
|
||||
}
|
||||
}
|
||||
}
|
14
luci-app-npc/Makefile
Executable file
14
luci-app-npc/Makefile
Executable file
@ -0,0 +1,14 @@
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
# Copyright (C) 2020-2021 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for NPS Client(NPC)
|
||||
LUCI_DEPENDS:=+npc
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=2
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
11
luci-app-npc/README.md
Executable file
11
luci-app-npc/README.md
Executable file
@ -0,0 +1,11 @@
|
||||
# luci-app-npc
|
||||
|
||||
## 修改内容
|
||||
|
||||
- 解除原有服务端仅 IPv4 地址的限制
|
||||
|
||||
- 添加[速度限制] [流量限制] [最大连接数] 等多个选项
|
||||
|
||||
## Based on
|
||||
|
||||
- [lede](https://github.com/coolsnowwolf/lede/tree/master/package/lean/luci-app-nps)
|
17
luci-app-npc/luasrc/controller/npc.lua
Executable file
17
luci-app-npc/luasrc/controller/npc.lua
Executable file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.npc",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/npc") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "npc"}, cbi("npc"), _("NPS Client"), 99).dependent = true
|
||||
entry({"admin", "services", "npc", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pgrep npc > /dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
50
luci-app-npc/luasrc/model/cbi/npc.lua
Executable file
50
luci-app-npc/luasrc/model/cbi/npc.lua
Executable file
@ -0,0 +1,50 @@
|
||||
m = Map("npc", translate("NPS Client"), translate("Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."))
|
||||
|
||||
m:section(SimpleSection).template = "npc/npc_status"
|
||||
|
||||
s = m:section(TypedSection,"npc")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
enable.default = "0"
|
||||
|
||||
server = s:option(Value, "server_addr", translate("Server Address"), translate("IPv4 address or Domain Name"))
|
||||
server.rmempty = false
|
||||
|
||||
port = s:option(Value, "server_port", translate("Port"))
|
||||
port.datatype = "port"
|
||||
port.default = "8024"
|
||||
port.rmempty = false
|
||||
|
||||
vkey = s:option(Value, "vkey", translate("vkey"))
|
||||
vkey.password = true
|
||||
vkey.rmempty = false
|
||||
|
||||
protocol = s:option(ListValue, "protocol", translate("Protocol Type"))
|
||||
protocol.default = "tcp"
|
||||
protocol:value("tcp", translate("TCP Protocol"))
|
||||
protocol:value("kcp", translate("KCP Protocol"))
|
||||
|
||||
max_conn = s:option(Value, "max_conn", translate("Max Connection Limit"), translate("Maximum number of connections (Not necessary)"))
|
||||
max_conn.optional = true
|
||||
max_conn.rmempty = true
|
||||
|
||||
rate_limit = s:option(Value, "rate_limit", translate("Rate Limit"), translate("Client rate limit (Not necessary)"))
|
||||
rate_limit.optional = true
|
||||
rate_limit.rmempty = true
|
||||
|
||||
flow_limit = s:option(Value, "flow_limit", translate("Flow Limit"), translate("Client flow limit (Not necessary)"))
|
||||
flow_limit.optional = true
|
||||
flow_limit.rmempty = true
|
||||
|
||||
compress = s:option(Flag, "compress", translate("Enable Compression"), translate("The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."))
|
||||
compress.default = "0"
|
||||
compress.rmempty = false
|
||||
|
||||
crypt = s:option(Flag, "crypt", translate("Enable Encryption"), translate("Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."))
|
||||
crypt.default = "0"
|
||||
crypt.rmempty = false
|
||||
|
||||
return m
|
22
luci-app-npc/luasrc/view/npc/npc_status.htm
Executable file
22
luci-app-npc/luasrc/view/npc/npc_status.htm
Executable file
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[npc]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('npc_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>NPS Client <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>NPS Client <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="npc_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
56
luci-app-npc/po/zh-cn/npc.po
Executable file
56
luci-app-npc/po/zh-cn/npc.po
Executable file
@ -0,0 +1,56 @@
|
||||
msgid "NPS Client"
|
||||
msgstr "NPS 内网穿透客户端"
|
||||
|
||||
msgid "Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
|
||||
msgstr "NPS 是一种快速反向代理,可帮助您将 NAT 或防火墙后的本地服务器公开到 Internet"
|
||||
|
||||
msgid "IPv4 address or Domain Name"
|
||||
msgstr "服务器域名或 IPv4 地址"
|
||||
|
||||
msgid "vkey"
|
||||
msgstr "唯一验证密钥(vkey)"
|
||||
|
||||
msgid "Enable Compression"
|
||||
msgstr "压缩传输"
|
||||
|
||||
msgid "Enable Encryption"
|
||||
msgstr "加密传输"
|
||||
|
||||
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
|
||||
msgstr "启用压缩传输内容会加快流量转发速度,但是会额外消耗 CPU 资源"
|
||||
|
||||
msgid "Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."
|
||||
msgstr "启用加密传输客户端与服务端之间的通信内容,会有效防止流量被拦截"
|
||||
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Protocol Type"
|
||||
msgstr "协议类型"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "TCP Protocol"
|
||||
msgstr "TCP"
|
||||
|
||||
msgid "KCP Protocol"
|
||||
msgstr "KCP"
|
||||
|
||||
msgid "Max Connection Limit"
|
||||
msgstr "连接数限制"
|
||||
|
||||
msgid "Maximum number of connections (Not necessary)"
|
||||
msgstr "最大连接数限制 (可选,非必须)"
|
||||
|
||||
msgid "Rate Limit"
|
||||
msgstr "速度限制"
|
||||
|
||||
msgid "Client rate limit (Not necessary)"
|
||||
msgstr "客户端速度限制 (可选,非必须)"
|
||||
|
||||
msgid "Flow Limit"
|
||||
msgstr "流量限制"
|
||||
|
||||
msgid "Client flow limit (Not necessary)"
|
||||
msgstr "客户端流量限制 (可选,非必须)"
|
56
luci-app-npc/po/zh_Hans/npc.po
Executable file
56
luci-app-npc/po/zh_Hans/npc.po
Executable file
@ -0,0 +1,56 @@
|
||||
msgid "NPS Client"
|
||||
msgstr "NPS 内网穿透客户端"
|
||||
|
||||
msgid "Nps is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet."
|
||||
msgstr "NPS 是一种快速反向代理,可帮助您将 NAT 或防火墙后的本地服务器公开到 Internet"
|
||||
|
||||
msgid "IPv4 address or Domain Name"
|
||||
msgstr "服务器域名或 IPv4 地址"
|
||||
|
||||
msgid "vkey"
|
||||
msgstr "唯一验证密钥(vkey)"
|
||||
|
||||
msgid "Enable Compression"
|
||||
msgstr "压缩传输"
|
||||
|
||||
msgid "Enable Encryption"
|
||||
msgstr "加密传输"
|
||||
|
||||
msgid "The contents will be compressed to speed up the traffic forwarding speed, but this will consume some additional cpu resources."
|
||||
msgstr "启用压缩传输内容会加快流量转发速度,但是会额外消耗 CPU 资源"
|
||||
|
||||
msgid "Encrypted the communication between Npc and Nps, will effectively prevent the traffic intercepted."
|
||||
msgstr "启用加密传输客户端与服务端之间的通信内容,会有效防止流量被拦截"
|
||||
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Protocol Type"
|
||||
msgstr "协议类型"
|
||||
|
||||
msgid "Server Address"
|
||||
msgstr "服务端地址"
|
||||
|
||||
msgid "TCP Protocol"
|
||||
msgstr "TCP"
|
||||
|
||||
msgid "KCP Protocol"
|
||||
msgstr "KCP"
|
||||
|
||||
msgid "Max Connection Limit"
|
||||
msgstr "连接数限制"
|
||||
|
||||
msgid "Maximum number of connections (Not necessary)"
|
||||
msgstr "最大连接数限制 (可选,非必须)"
|
||||
|
||||
msgid "Rate Limit"
|
||||
msgstr "速度限制"
|
||||
|
||||
msgid "Client rate limit (Not necessary)"
|
||||
msgstr "客户端速度限制 (可选,非必须)"
|
||||
|
||||
msgid "Flow Limit"
|
||||
msgstr "流量限制"
|
||||
|
||||
msgid "Client flow limit (Not necessary)"
|
||||
msgstr "客户端流量限制 (可选,非必须)"
|
6
luci-app-npc/root/etc/config/npc
Executable file
6
luci-app-npc/root/etc/config/npc
Executable file
@ -0,0 +1,6 @@
|
||||
|
||||
config npc
|
||||
option enable '0'
|
||||
option server_addr '1.2.3.4'
|
||||
option vkey 'abcdefg'
|
||||
|
67
luci-app-npc/root/etc/init.d/npc
Executable file
67
luci-app-npc/root/etc/init.d/npc
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=95
|
||||
USE_PROCD=1
|
||||
LOGGER="logger -t [NPC]"
|
||||
|
||||
npc_Path="$(command -v npc)"
|
||||
conf_Path="/tmp/etc/npc.conf"
|
||||
|
||||
start_service() {
|
||||
local basic_list="enable server_addr server_port protocol vkey max_conn rate_limit flow_limit compress crypt"
|
||||
for i in $(echo $basic_list);do
|
||||
local eval $i="$(uci_get_by_type npc 0 $i)"
|
||||
done;unset i
|
||||
|
||||
[ -s "$conf_Path" ] && rm -f $conf_Path
|
||||
echo "[common]" > $conf_Path || {
|
||||
${LOGGER} "Failed to create config,exit ..."
|
||||
exit 1
|
||||
}
|
||||
echo "server_addr=${server_addr}:${server_port}" >> $conf_Path
|
||||
echo "conn_type=${protocol}" >> $conf_Path
|
||||
echo "vkey=${vkey}" >> $conf_Path
|
||||
echo "auto_reconnection=true" >> $conf_Path
|
||||
[ -n "$max_conn" ] && echo "max_conn=${max_conn}" >> $conf_Path
|
||||
[ -n "$rate_limit" ] && echo "rate_limit=${rate_limit}" >> $conf_Path
|
||||
[ -n "$flow_limit" ] && echo "flow_limit=${flow_limit}" >> $conf_Path
|
||||
conf_write_bool compress $compress
|
||||
conf_write_bool crypt $crypt
|
||||
|
||||
if [ "$enable" = 1 ]
|
||||
then
|
||||
${LOGGER} "Starting NPS Client(NPC) ..."
|
||||
procd_open_instance
|
||||
procd_set_param command $npc_Path -config=$conf_Path
|
||||
procd_set_param respawn
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
else
|
||||
${LOGGER} "NPS Client(NPC) Service is now disabled ..."
|
||||
fi
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
$LOGGER "Stopping NPS Client(NPC) ..."
|
||||
rm -f $conf_Path
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "npc"
|
||||
}
|
||||
|
||||
conf_write_bool() {
|
||||
if [ "$2" == 0 ]
|
||||
then
|
||||
echo "$1=false" >> $conf_Path
|
||||
else
|
||||
echo "$1=true" >> $conf_Path
|
||||
fi
|
||||
return
|
||||
}
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get npc.@$1[$2].$3 2>/dev/null)
|
||||
echo ${ret:=$4}
|
||||
}
|
11
luci-app-npc/root/etc/uci-defaults/luci-npc
Executable file
11
luci-app-npc/root/etc/uci-defaults/luci-npc
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@npc[-1]
|
||||
add ucitrack npc
|
||||
set ucitrack.@npc[-1].init=npc
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
11
luci-app-npc/root/usr/share/rpcd/acl.d/luci-app-npc.json
Normal file
11
luci-app-npc/root/usr/share/rpcd/acl.d/luci-app-npc.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-npc": {
|
||||
"description": "Grant UCI access for luci-app-npc",
|
||||
"read": {
|
||||
"uci": [ "npc" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "npc" ]
|
||||
}
|
||||
}
|
||||
}
|
13
luci-app-shutdown/Makefile
Executable file
13
luci-app-shutdown/Makefile
Executable file
@ -0,0 +1,13 @@
|
||||
# Copyright (C) 2020-2021 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI Support for Shutdown Target
|
||||
PKG_NAME:=luci-app-shutdown
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
3
luci-app-shutdown/README.md
Executable file
3
luci-app-shutdown/README.md
Executable file
@ -0,0 +1,3 @@
|
||||
## luci-app-shutdown
|
||||
|
||||
一键关闭/重启设备
|
5
luci-app-shutdown/luasrc/controller/shutdown.lua
Executable file
5
luci-app-shutdown/luasrc/controller/shutdown.lua
Executable file
@ -0,0 +1,5 @@
|
||||
module("luci.controller.shutdown",package.seeall)
|
||||
|
||||
function index()
|
||||
entry({"admin", "system", "shutdown"}, cbi("shutdown"), _("Shutdown"),99)
|
||||
end
|
23
luci-app-shutdown/luasrc/model/cbi/shutdown.lua
Executable file
23
luci-app-shutdown/luasrc/model/cbi/shutdown.lua
Executable file
@ -0,0 +1,23 @@
|
||||
require("luci.sys")
|
||||
|
||||
m = SimpleForm("shutdown", translate("Shutdown/Reboot"),
|
||||
translate("Shut down / restart the system on your device"))
|
||||
|
||||
s = m:section(SimpleSection)
|
||||
|
||||
button_shutdown = s:option (Button, "button_shutdown", translate("Shutdown"), translatef("Please wait for the device to shut down"))
|
||||
button_shutdown.inputtitle = translate ("Do shutdown")
|
||||
button_shutdown.write = function()
|
||||
luci.sys.call("sync && poweroff > /dev/null")
|
||||
end
|
||||
|
||||
button_reboot = s:option (Button, "button_reboot", translate("Reboot"), translatef("Please wait a minutes until the device restart"))
|
||||
button_reboot.inputtitle = translate ("Do reboot")
|
||||
button_reboot.write = function()
|
||||
luci.sys.call("sync && reboot > /dev/null")
|
||||
end
|
||||
|
||||
m.reset = false
|
||||
m.submit = false
|
||||
|
||||
return m
|
23
luci-app-shutdown/po/zh-cn/shutdown.po
Executable file
23
luci-app-shutdown/po/zh-cn/shutdown.po
Executable file
@ -0,0 +1,23 @@
|
||||
msgid "Shutdown"
|
||||
msgstr "关机"
|
||||
|
||||
msgid "Do shutdown"
|
||||
msgstr "执行关机"
|
||||
|
||||
msgid "Do reboot"
|
||||
msgstr "执行重启"
|
||||
|
||||
msgid "Reboot"
|
||||
msgstr "重启"
|
||||
|
||||
msgid "Shutdown/Reboot"
|
||||
msgstr "关机/重启"
|
||||
|
||||
msgid "Shut down / restart the system on your device"
|
||||
msgstr "一键关闭/重启您设备上的系统"
|
||||
|
||||
msgid "Please wait a minutes until the device restart"
|
||||
msgstr "点击后请耐心等待 1-2 分钟直至设备重启成功"
|
||||
|
||||
msgid "Please wait for the device to shut down"
|
||||
msgstr "点击后请耐心等待设备关闭"
|
23
luci-app-shutdown/po/zh_Hans/shutdown.po
Executable file
23
luci-app-shutdown/po/zh_Hans/shutdown.po
Executable file
@ -0,0 +1,23 @@
|
||||
msgid "Shutdown"
|
||||
msgstr "关机"
|
||||
|
||||
msgid "Do shutdown"
|
||||
msgstr "执行关机"
|
||||
|
||||
msgid "Do reboot"
|
||||
msgstr "执行重启"
|
||||
|
||||
msgid "Reboot"
|
||||
msgstr "重启"
|
||||
|
||||
msgid "Shutdown/Reboot"
|
||||
msgstr "关机/重启"
|
||||
|
||||
msgid "Shut down / restart the system on your device"
|
||||
msgstr "一键关闭/重启您设备上的系统"
|
||||
|
||||
msgid "Please wait a minutes until the device restart"
|
||||
msgstr "点击后请耐心等待 1-2 分钟直至设备重启成功"
|
||||
|
||||
msgid "Please wait for the device to shut down"
|
||||
msgstr "点击后请耐心等待设备关闭"
|
25
luci-app-webd/Makefile
Executable file
25
luci-app-webd/Makefile
Executable file
@ -0,0 +1,25 @@
|
||||
# Copyright (C) 2020-2021 Hyy2001X <https://github.com/Hyy2001X>
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-webd
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=3
|
||||
|
||||
LUCI_TITLE:=LuCI support for Webd Netdisk
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
LUCI_DEPENDS:= \
|
||||
+PACKAGE_$(PKG_NAME)_INCLUDE_WEBD_BINARY:webd
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
|
||||
config PACKAGE_$(PKG_NAME)_INCLUDE_WEBD_BINARY
|
||||
bool "Include webd Binary"
|
||||
default y
|
||||
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
3
luci-app-webd/README.md
Normal file
3
luci-app-webd/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# luci-app-webd
|
||||
|
||||
项目地址: https://webd.cf/
|
17
luci-app-webd/luasrc/controller/webd.lua
Executable file
17
luci-app-webd/luasrc/controller/webd.lua
Executable file
@ -0,0 +1,17 @@
|
||||
module("luci.controller.webd",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/webd") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "nas", "webd"}, cbi("webd"), _("Webd Netdisk"),99)
|
||||
entry({"admin", "nas", "webd", "status"}, call("act_status")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pgrep webd > /dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
82
luci-app-webd/luasrc/model/cbi/webd.lua
Executable file
82
luci-app-webd/luasrc/model/cbi/webd.lua
Executable file
@ -0,0 +1,82 @@
|
||||
m = Map("webd", translate("Webd Netdisk"),
|
||||
translate("Webd - A lightweight self hosted netdisk")
|
||||
.. [[ <a href="https://webd.cf/">]]
|
||||
.. translate("Official Website")
|
||||
.. [[</a>]]
|
||||
)
|
||||
|
||||
m:section(SimpleSection).template = "webd/webd_status"
|
||||
|
||||
s = m:section(TypedSection, "webd", translate("Basic Settings"), translate("Set the basic settings of Webd Netdisk"))
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "enable", translate("Enable"))
|
||||
enable.default = 0
|
||||
|
||||
port = s:option(Value, "webd_port", translate("Listening Port"))
|
||||
port.datatype = "port"
|
||||
port.default = "9212"
|
||||
port.rmempty = false
|
||||
|
||||
enable_ipv6 = s:option(Flag, "enable_ipv6", translate("Listen IPv6"), translatef("Listen both IPv4 and IPv6 Address"))
|
||||
enable_ipv6.default = 0
|
||||
|
||||
root = s:option(Value, "webd_root", translate("Local Directory"), translatef("Directory of Webd Netdisk"))
|
||||
root.default = "/mnt"
|
||||
root.rmempty = false
|
||||
|
||||
enable_recyclebin = s:option(Flag, "enable_recyclebin", translate("Recycle Bin"), translatef("Automatically create recycle bin directory"))
|
||||
enable_recyclebin.default = 1
|
||||
|
||||
enable_anonymous = s:option(Flag, "enable_anonymous", translate("Enable Anonymous Access"), translatef("Anonymous access is allowed when enabled (Not Safe)"))
|
||||
enable_anonymous.default = 0
|
||||
|
||||
anonymous_perm = s:option(MultiValue, "anonymous_perm", translate("Anonymous Permission"))
|
||||
anonymous_perm:value("r", translate("Read files"))
|
||||
anonymous_perm:value("l", translate("Obtain file list"))
|
||||
anonymous_perm:value("u", translate("Upload files"))
|
||||
anonymous_perm:value("m", translate("Remove files"))
|
||||
anonymous_perm:value("S", translate("Show hidden files"))
|
||||
anonymous_perm:value("T", translate("Play media"))
|
||||
anonymous_perm:depends("enable_anonymous", "1")
|
||||
anonymous_perm.description = translate("At least one permission must be choosed to allow anonymous access")
|
||||
|
||||
webd_bin = s:option(Value, "webd_bin", translate("Binary Path"), translatef("Webd Netdisk binary Path"))
|
||||
webd_bin.default = "/usr/bin/webd"
|
||||
webd_bin.rmempty = false
|
||||
|
||||
webd_conf = s:option(Value, "webd_conf", translate("Config Path"), translatef("Webd Netdisk config Path"))
|
||||
webd_conf.default = "/etc/webd.conf"
|
||||
webd_conf.rmempty = false
|
||||
|
||||
s = m:section(TypedSection, "users", translate("User Settings"), translate("Set the username, password and permissions. Maximum for 2 accounts"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
username = s:option(Value, "username", translate("Username"))
|
||||
username.rmempty = false
|
||||
|
||||
password = s:option(Value, "password", translate("Password"))
|
||||
password.rmempty = false
|
||||
password.password=false
|
||||
|
||||
enable_read = s:option(Flag, "enable_read", translate("Read files"))
|
||||
enable_read.default = 1
|
||||
|
||||
enable_read_list = s:option(Flag, "enable_read_list", translate("Obtain file list"))
|
||||
enable_read_list.default = 1
|
||||
|
||||
enable_upload = s:option(Flag, "enable_upload", translate("Upload files"))
|
||||
enable_upload.default = 1
|
||||
|
||||
enable_move = s:option(Flag, "enable_move", translate("Remove files"))
|
||||
enable_move.default = 1
|
||||
|
||||
enable_showhide = s:option(Flag, "enable_showhide", translate("Show hidden files"))
|
||||
enable_showhide.default = 0
|
||||
|
||||
enable_play = s:option(Flag, "enable_play", translate("Play media"))
|
||||
enable_play.default = 1
|
||||
|
||||
return m
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user