mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-07-27 10:31:38 +08:00
⛅ Sync 2026-04-13 03:35:37
This commit is contained in:
parent
b2bbe88a56
commit
2e34347b01
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-autorepeater
|
||||
PKG_VERSION:=0.2.3
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
@ -68,6 +68,26 @@ endef
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
( . /etc/uci-defaults/luci-autorepeater ) && rm -f /etc/uci-defaults/luci-autorepeater
|
||||
chmod 755 /etc/init.d/autorepeater >/dev/null 2>&1
|
||||
/etc/init.d/autorepeater enable >/dev/null 2>&1
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete firewall.autorepeater
|
||||
set firewall.autorepeater=include
|
||||
set firewall.autorepeater.type=script
|
||||
set firewall.autorepeater.path=/var/etc/autorepeater.include
|
||||
set firewall.autorepeater.reload=0
|
||||
commit firewall
|
||||
EOF
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
||||
$(INSTALL_DATA) ./files/luci/controller/autorepeater.lua $(1)/usr/lib/lua/luci/controller/
|
||||
|
||||
@ -10,11 +10,11 @@ LUCI_TITLE:=chongyoung
|
||||
LUCI_DEPENDS:=
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=4.2.0
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
|
||||
define Package/luci-app-chongyoung-lua/postinst
|
||||
#!/bin/sh
|
||||
chmod +x $(1)/etc/init.d/*
|
||||
chmod +x $${IPKG_INSTROOT}/etc/init.d/*
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-coredns
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI Support for coredns
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+luci-compat +curl
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/coredns
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/preinst
|
||||
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
chmod +x $${IPKG_INSTROOT}/etc/init.d/coredns
|
||||
chmod +x $${IPKG_INSTROOT}/usr/share/coredns/*.sh
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/prerm
|
||||
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postrm
|
||||
#!/bin/sh
|
||||
rm -rf /usr/lib/lua/luci/i18n/coredns.zh-cn.lmo
|
||||
rm -rf /usr/share/coredns
|
||||
rm -rf /tmp/coredns.log
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@ -1,62 +0,0 @@
|
||||
local sys = require "luci.sys"
|
||||
local http = require "luci.http"
|
||||
local api = require "luci.coredns.api"
|
||||
|
||||
module("luci.controller.coredns", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/coredns") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "coredns"}, alias("admin", "services", "coredns", "basic"), _("CoreDNS"), 30)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-coredns" }
|
||||
|
||||
entry({"admin", "services", "coredns", "basic"}, cbi("coredns/basic"), _("Basic Setting"), 1).leaf = true
|
||||
entry({"admin", "services", "coredns", "status"}, call("coredns_status")).leaf = true
|
||||
entry({"admin", "services", "coredns", "rule_list"}, cbi("coredns/rule_list"), _("Redir Rule"), 2).leaf = true
|
||||
entry({"admin", "services", "coredns", "rule_url_config"}, cbi("coredns/rule_url_config")).leaf = true
|
||||
entry({"admin", "services", "coredns", "rule_file_config"}, cbi("coredns/rule_file_config")).leaf = true
|
||||
entry({"admin", "services", "coredns", "rule_file_content"}, cbi("coredns/rule_file_content",{hideapplybtn=true, hidesavebtn=true, hideresetbtn=true})).leaf = true
|
||||
entry({"admin", "services", "coredns", "auto_update"}, cbi("coredns/auto_update"), _("Auto Update"), 3).leaf = true
|
||||
entry({"admin", "services", "coredns", "rule_refresh"}, call("rule_refresh")).leaf = true
|
||||
entry({"admin", "services", "coredns", "coredns_upload"}, form("coredns/coredns_upload"), _("Core Update"), 4).leaf = true
|
||||
entry({"admin", "services", "coredns", "log"}, cbi("coredns/log"), _("Logs"), 5).leaf = true
|
||||
entry({"admin", "services", "coredns", "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "services", "coredns", "clear_log"}, call("clear_log")).leaf = true
|
||||
end
|
||||
|
||||
function coredns_status()
|
||||
local e = {}
|
||||
e.running = sys.call("pgrep -f coredns >/dev/null") == 0
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
end
|
||||
|
||||
function get_log()
|
||||
-- http.write(sys.exec("cat $(/usr/share/coredns/coredns.sh logfile)"))
|
||||
-- http.write(sys.exec("cat /tmp/coredns.log"))
|
||||
http.write(sys.exec("cat $(uci -q get coredns.global.logfile)"))
|
||||
end
|
||||
|
||||
function clear_log()
|
||||
-- sys.call("cat /dev/null > /tmp/coredns.log")
|
||||
sys.call("/usr/share/coredns/clear_log.sh")
|
||||
end
|
||||
|
||||
function rule_refresh()
|
||||
local e = {}
|
||||
e.updating = sys.call("lua /usr/share/coredns/update_rule.lua > /dev/null") == 0
|
||||
-- luci.http.redirect(api.url("log"))
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
-- function flush_cache()
|
||||
-- local e = {}
|
||||
-- e.flushing = sys.call("/usr/share/coredns/clear_cache.sh >/dev/null") == 0
|
||||
-- http.prepare_content("application/json")
|
||||
-- http.write_json(e)
|
||||
-- end
|
||||
@ -1,350 +0,0 @@
|
||||
module("luci.coredns.api", package.seeall)
|
||||
bin = require "nixio".bin
|
||||
fs = require "nixio.fs"
|
||||
sys = require "luci.sys"
|
||||
uci = require"luci.model.uci".cursor()
|
||||
util = require "luci.util"
|
||||
datatypes = require "luci.cbi.datatypes"
|
||||
jsonc = require "luci.jsonc"
|
||||
i18n = require "luci.i18n"
|
||||
|
||||
appname = "coredns"
|
||||
curl_args = {"-skfL", "--connect-timeout 3", "--retry 3", "-m 60"}
|
||||
command_timeout = 300
|
||||
LEDE_BOARD = nil
|
||||
DISTRIB_TARGET = nil
|
||||
|
||||
-- LOG_FILE = "/tmp/coredns.log"
|
||||
LOG_FILE = uci:get("coredns","global","logfile")
|
||||
-- print(LOG_FILE)
|
||||
|
||||
function log(...)
|
||||
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
|
||||
local f, err = io.open(LOG_FILE, "a")
|
||||
if f and err == nil then
|
||||
f:write(result .. "\n")
|
||||
f:close()
|
||||
end
|
||||
end
|
||||
|
||||
function exec_call(cmd)
|
||||
local process = io.popen(cmd .. '; echo -e "\n$?"')
|
||||
local lines = {}
|
||||
local result = ""
|
||||
local return_code
|
||||
for line in process:lines() do
|
||||
lines[#lines + 1] = line
|
||||
end
|
||||
process:close()
|
||||
if #lines > 0 then
|
||||
return_code = lines[#lines]
|
||||
for i = 1, #lines - 1 do
|
||||
result = result .. lines[i] .. ((i == #lines - 1) and "" or "\n")
|
||||
end
|
||||
end
|
||||
return tonumber(return_code), trim(result)
|
||||
end
|
||||
|
||||
function curl_base(url, file, args)
|
||||
if not args then args = {} end
|
||||
if file then
|
||||
args[#args + 1] = "-o " .. file
|
||||
end
|
||||
local cmd = string.format('curl %s "%s"', table_join(args), url)
|
||||
return exec_call(cmd)
|
||||
end
|
||||
|
||||
function curl_logic(url, file, args)
|
||||
-- local return_code, result = curl_proxy(url, file, args)
|
||||
-- if not return_code or return_code ~= 0 then
|
||||
return_code, result = curl_base(url, file, args)
|
||||
-- end
|
||||
return return_code, result
|
||||
end
|
||||
|
||||
function table_join(t, s)
|
||||
if not s then
|
||||
s = " "
|
||||
end
|
||||
local str = ""
|
||||
for index, value in ipairs(t) do
|
||||
str = str .. t[index] .. (index == #t and "" or s)
|
||||
end
|
||||
return str
|
||||
end
|
||||
|
||||
function url(...)
|
||||
local url = string.format("admin/services/%s", appname)
|
||||
local args = { ... }
|
||||
for i, v in pairs(args) do
|
||||
if v ~= "" then
|
||||
url = url .. "/" .. v
|
||||
end
|
||||
end
|
||||
return require "luci.dispatcher".build_url(url)
|
||||
end
|
||||
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
function is_exist(table, value)
|
||||
for index, k in ipairs(table) do
|
||||
if k == value then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function repeat_exist(table, value)
|
||||
local count = 0
|
||||
for index, k in ipairs(table) do
|
||||
if k:find("-") and k == value then
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
if count > 1 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function get_args(arg)
|
||||
local var = {}
|
||||
for i, arg_k in pairs(arg) do
|
||||
if i > 0 then
|
||||
local v = arg[i + 1]
|
||||
if v then
|
||||
if repeat_exist(arg, v) == false then
|
||||
var[arg_k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return var
|
||||
end
|
||||
|
||||
function get_function_args(arg)
|
||||
local var = nil
|
||||
if arg and #arg > 1 then
|
||||
local param = {}
|
||||
for i = 2, #arg do
|
||||
param[#param + 1] = arg[i]
|
||||
end
|
||||
var = get_args(param)
|
||||
end
|
||||
return var
|
||||
end
|
||||
|
||||
function strToTable(str)
|
||||
if str == nil or type(str) ~= "string" then
|
||||
return {}
|
||||
end
|
||||
|
||||
return loadstring("return " .. str)()
|
||||
end
|
||||
|
||||
function is_ip(val)
|
||||
if is_ipv6(val) then
|
||||
val = get_ipv6_only(val)
|
||||
end
|
||||
return datatypes.ipaddr(val)
|
||||
end
|
||||
|
||||
function is_ipv6(val)
|
||||
local str = val
|
||||
local address = val:match('%[(.*)%]')
|
||||
if address then
|
||||
str = address
|
||||
end
|
||||
if datatypes.ip6addr(str) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function is_ipv6addrport(val)
|
||||
if is_ipv6(val) then
|
||||
local address, port = val:match('%[(.*)%]:([^:]+)$')
|
||||
if port then
|
||||
return datatypes.port(port)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function get_ipv6_only(val)
|
||||
local result = ""
|
||||
if is_ipv6(val) then
|
||||
result = val
|
||||
if val:match('%[(.*)%]') then
|
||||
result = val:match('%[(.*)%]')
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function get_ipv6_full(val)
|
||||
local result = ""
|
||||
if is_ipv6(val) then
|
||||
result = val
|
||||
if not val:match('%[(.*)%]') then
|
||||
result = "[" .. result .. "]"
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
function get_ip_type(val)
|
||||
if is_ipv6(val) then
|
||||
return "6"
|
||||
elseif datatypes.ip4addr(val) then
|
||||
return "4"
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
function is_mac(val)
|
||||
return datatypes.macaddr(val)
|
||||
end
|
||||
|
||||
function ip_or_mac(val)
|
||||
if val then
|
||||
if get_ip_type(val) == "4" then
|
||||
return "ip"
|
||||
end
|
||||
if is_mac(val) then
|
||||
return "mac"
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
function iprange(val)
|
||||
if val then
|
||||
local ipStart, ipEnd = val:match("^([^/]+)-([^/]+)$")
|
||||
if (ipStart and datatypes.ip4addr(ipStart)) and (ipEnd and datatypes.ip4addr(ipEnd)) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function get_domain_from_url(url)
|
||||
local domain = string.match(url, "//([^/]+)")
|
||||
if domain then
|
||||
return domain
|
||||
end
|
||||
return url
|
||||
end
|
||||
|
||||
function gen_uuid(format)
|
||||
local uuid = sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)")
|
||||
if format == nil then
|
||||
uuid = string.gsub(uuid, "-", "")
|
||||
end
|
||||
return uuid
|
||||
end
|
||||
|
||||
function gen_short_uuid()
|
||||
return sys.exec("echo -n $(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 8)")
|
||||
end
|
||||
|
||||
function uci_get_type(type, config, default)
|
||||
local value = uci:get_first(appname, type, config, default) or sys.exec("echo -n $(uci -q get " .. appname .. ".@" .. type .."[0]." .. config .. ")")
|
||||
if (value == nil or value == "") and (default and default ~= "") then
|
||||
value = default
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
function uci_get_type_id(id, config, default)
|
||||
local value = uci:get(appname, id, config, default) or sys.exec("echo -n $(uci -q get " .. appname .. "." .. id .. "." .. config .. ")")
|
||||
if (value == nil or value == "") and (default and default ~= "") then
|
||||
value = default
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
function chmod_755(file)
|
||||
if file and file ~= "" then
|
||||
if not fs.access(file, "rwx", "rx", "rx") then
|
||||
fs.chmod(file, 755)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function is_finded(e)
|
||||
return luci.sys.exec('type -t -p "/usr/share/coredns" "%s"' % {e}) ~= "" and true or false
|
||||
end
|
||||
|
||||
function is_file(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -f "%s" ] && echo -n 1' % path) == "1" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function is_dir(path)
|
||||
if path and #path > 1 then
|
||||
if sys.exec('[ -d "%s" ] && echo -n 1' % path) == "1" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function get_final_dir(path)
|
||||
if is_dir(path) then
|
||||
return path
|
||||
else
|
||||
return get_final_dir(fs.dirname(path))
|
||||
end
|
||||
end
|
||||
|
||||
function get_free_space(dir)
|
||||
if dir == nil then dir = "/" end
|
||||
if sys.call("df -k " .. dir .. " >/dev/null 2>&1") == 0 then
|
||||
return tonumber(sys.exec("echo -n $(df -k " .. dir .. " | awk 'NR>1' | awk '{print $4}')"))
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function get_file_space(file)
|
||||
if file == nil then return 0 end
|
||||
if fs.access(file) then
|
||||
return tonumber(sys.exec("echo -n $(du -k " .. file .. " | awk '{print $1}')"))
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
function auto_get_arch()
|
||||
local arch = nixio.uname().machine or ""
|
||||
if fs.access("/usr/lib/os-release") then
|
||||
LEDE_BOARD = sys.exec("echo -n $(grep 'LEDE_BOARD' /usr/lib/os-release | awk -F '[\\042\\047]' '{print $2}')")
|
||||
end
|
||||
if fs.access("/etc/openwrt_release") then
|
||||
DISTRIB_TARGET = sys.exec("echo -n $(grep 'DISTRIB_TARGET' /etc/openwrt_release | awk -F '[\\042\\047]' '{print $2}')")
|
||||
end
|
||||
|
||||
if arch == "mips" then
|
||||
if LEDE_BOARD and LEDE_BOARD ~= "" then
|
||||
if string.match(LEDE_BOARD, "ramips") == "ramips" then
|
||||
arch = "ramips"
|
||||
else
|
||||
arch = sys.exec("echo '" .. LEDE_BOARD .. "' | grep -oE 'ramips|ar71xx'")
|
||||
end
|
||||
elseif DISTRIB_TARGET and DISTRIB_TARGET ~= "" then
|
||||
if string.match(DISTRIB_TARGET, "ramips") == "ramips" then
|
||||
arch = "ramips"
|
||||
else
|
||||
arch = sys.exec("echo '" .. DISTRIB_TARGET .. "' | grep -oE 'ramips|ar71xx'")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return util.trim(arch)
|
||||
end
|
||||
@ -1,45 +0,0 @@
|
||||
m = Map("coredns")
|
||||
|
||||
s = m:section(TypedSection, "coredns_rule_update", translate("Redir Rule"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "rule_auto_update", translate("Enable Auto Update"))
|
||||
enable.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "rule_update_week_time", translate("Update Cycle"))
|
||||
o:value("*", translate("Every Day"))
|
||||
o:value("1", translate("Every Monday"))
|
||||
o:value("2", translate("Every Tuesday"))
|
||||
o:value("3", translate("Every Wednesday"))
|
||||
o:value("4", translate("Every Thursday"))
|
||||
o:value("5", translate("Every Friday"))
|
||||
o:value("6", translate("Every Saturday"))
|
||||
o:value("7", translate("Every Sunday"))
|
||||
o.default = "*"
|
||||
|
||||
update_time = s:option(ListValue, "rule_update_day_time", translate("Update Time"))
|
||||
for t = 0, 23 do
|
||||
update_time:value(t, t..":00")
|
||||
end
|
||||
update_time.default = 0
|
||||
|
||||
data_update = s:option(Button, "rule_update", translate("Rule Update"))
|
||||
data_update.rawhtml = true
|
||||
data_update.template = "coredns/rule_update"
|
||||
|
||||
|
||||
s = m:section(TypedSection, "coredns_clear_log", translate("Clear Logs"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "log_auto_clear", translate("Enable Auto Clear"))
|
||||
enable.rmempty = false
|
||||
|
||||
clear_hour = s:option(ListValue, "log_clear_hour", translate("Clear Cycle"))
|
||||
for t = 1, 24 do
|
||||
clear_hour:value(t, translate("Every") .. " " .. t .. " " .. translate("hours"))
|
||||
end
|
||||
clear_hour.default = 12
|
||||
|
||||
return m
|
||||
@ -1,124 +0,0 @@
|
||||
local api = require "luci.coredns.api"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
if fs.access("/usr/share/coredns/coredns") then
|
||||
coredns_version = sys.exec("/usr/share/coredns/coredns -version")
|
||||
else
|
||||
coredns_version = translate("Unknown Version, Pleaes upload a valid CoreDNS program.")
|
||||
end
|
||||
|
||||
m = Map("coredns")
|
||||
m.title = "CoreDNS"
|
||||
m.description = coredns_version
|
||||
|
||||
m:section(SimpleSection).template = "coredns/coredns_status"
|
||||
|
||||
s = m:section(TypedSection, "coredns", translate("Basic Options"), translate("Please refer to") .. " <a href='https://coredns.io/' target='_blank'>https://coredns.io/</a>.")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enabled"))
|
||||
|
||||
o = s:option(ListValue, "configfile", translate("Config File"))
|
||||
o:value("/usr/share/coredns/Corefile", translate("Default Config"))
|
||||
o:value("/usr/share/coredns/Corefile_custom", translate("Custom Config"))
|
||||
o.default = "/usr/share/coredns/Corefile"
|
||||
|
||||
o = s:option(Value, "listen_port", translate("Listen port"))
|
||||
o.datatype = "and(port,min(1))"
|
||||
o.default = 5336
|
||||
|
||||
o = s:option(Flag, "redirect", translate("DNSMASQ Forward"), translate("Forward Dnsmasq Domain Name resolution requests to CoreDNS"))
|
||||
o.default = false
|
||||
|
||||
o = s:option(Flag, "enabled_log", translate("Enable Log"))
|
||||
o.default = true
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(Flag, "enabled_cache", translate("Enable Cache"), translate("Please do NOT enable cache when working with OpenClash, AdguardHome"))
|
||||
o.default = false
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(Flag, "disable_ipv6", translate("Disable IPv6"))
|
||||
o.default = false
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(DynamicList, "dns", translate("Default DNS"), translate("Upstream DNS server"))
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
o:value("tls://149.112.112.112", "149.112.112.112 (Quad9 DNS)")
|
||||
o:value("tls://45.11.45.11", "45.11.45.11 (DNS.SB)")
|
||||
o:value("tls://208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||
o:value("tls://208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||
o:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare DNS)")
|
||||
o:value("tls://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||
o:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
||||
o:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||
o:value("tls://9.9.9.9", "9.9.9.9 (Quad9 DNS)")
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
o.default = "119.29.29.29"
|
||||
|
||||
o = s:option(ListValue, "policy", translate("Policy"))
|
||||
o:value("random", translate("Randomly select a healthy upstream host"))
|
||||
o:value("round_robin", translate("Select a healthy upstream host in round robin order"))
|
||||
o:value("sequential", translate("Select a healthy upstream host in sequential order"))
|
||||
o.default = "random"
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(DynamicList, "bootstrap_dns", translate("Bootstrap DNS servers"), translate("Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"))
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "path_reload", translate("Path Reload"),translate("changes the reload interval between each path in FROM, Default is 2s, minimal is 1s"))
|
||||
o.default = "2s"
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(Value, "expire", translate("Expire"), translate("will expire (cached) connections after this time interval, Default is 15s, minimal is 1s"))
|
||||
o.default = "15s"
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(Value, "max_fails", translate("Max Fails"), translate("is the maximum number of consecutive health checking failures that are needed before considering an upstream as down. 0 to disable this feature(which the upstream will never be marked as down), Default is 3"))
|
||||
o.default = "3"
|
||||
o.datatype = "range(0, 10)"
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
o = s:option(Value, "health_check", translate("Health Check"), translate("configure the behaviour of health checking of the upstream hosts, Default is 2s, minimal is 1s"))
|
||||
|
||||
o.default = "2s"
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile")
|
||||
|
||||
-- o = s:option(Button, "_reload", translate("Reload Service"), translate("Reload service to take effect of new configuration"))
|
||||
-- o.write = function()
|
||||
-- sys.exec("/etc/init.d/coredns reload")
|
||||
-- end
|
||||
-- o:depends("configfile", "/usr/share/coredns/Corefile_custom")
|
||||
|
||||
o = s:option(TextValue, "manual-config")
|
||||
o.description = translate("Edit the custom Corefile in above textarea as you own need")
|
||||
o.template = "cbi/tvalue"
|
||||
o.rows = 25
|
||||
o:depends("configfile", "/usr/share/coredns/Corefile_custom")
|
||||
|
||||
function o.cfgvalue(self, section)
|
||||
return fs.readfile("/usr/share/coredns/Corefile_custom")
|
||||
end
|
||||
|
||||
function o.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
fs.writefile("/usr/share/coredns/Corefile_custom", value)
|
||||
end
|
||||
|
||||
return m
|
||||
@ -1,79 +0,0 @@
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
local http = require "luci.http"
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
|
||||
if fs.access("/usr/share/coredns/coredns") then
|
||||
coredns_version = sys.exec("/usr/share/coredns/coredns -version")
|
||||
coredns_plugins = sys.exec("/usr/share/coredns/coredns -plugins")
|
||||
else
|
||||
coredns_version = translate("Unknown Version, Pleaes upload a valid CoreDNS program.")
|
||||
coredns_plugins = translate("Cannot get plugins list, please check if coredns program was uploaded correctly")
|
||||
end
|
||||
|
||||
ful = SimpleForm("coredns", 'CoreDNS', coredns_version)
|
||||
ful.reset = false
|
||||
ful.submit = false
|
||||
|
||||
sul =ful:section(SimpleSection, translate("Upload"))
|
||||
o = sul:option(FileUpload, "")
|
||||
o.template = "coredns/upload"
|
||||
um = sul:option(DummyValue, "", nil)
|
||||
um.template = "coredns/dvalue"
|
||||
|
||||
local dir, fd, clash
|
||||
dir = "/usr/share/coredns/"
|
||||
tmp_dir="/tmp/coredns/bin/"
|
||||
-- fs.mkdir(tmp_dir)
|
||||
os.execute(string.format("rm -rf %s >/dev/null 2>&1", tmp_dir))
|
||||
os.execute(string.format("mkdir -p %s >/dev/null 2>&1", tmp_dir))
|
||||
|
||||
http.setfilehandler(
|
||||
function(meta, chunk, eof)
|
||||
if not fd then
|
||||
if not meta then return end
|
||||
fd = nixio.open(tmp_dir .. meta.file, "w")
|
||||
if not fd then
|
||||
um.value = translate("Create upload file error")
|
||||
return
|
||||
end
|
||||
end
|
||||
if chunk and fd then
|
||||
fd:write(chunk)
|
||||
end
|
||||
if eof and fd then
|
||||
fd:close()
|
||||
fd = nil
|
||||
if string.lower(string.sub(meta.file, -7, -1)) == ".tar.gz" then
|
||||
os.execute(string.format("tar -C '/tmp/coredns' -xzf %s >/dev/null 2>&1", (tmp_dir .. meta.file)))
|
||||
fs.unlink(tmp_dir .. meta.file)
|
||||
os.execute(string.format("mv $(echo \"/tmp/coredns/bin/$(ls /tmp/coredns/bin/)\") '/usr/share/coredns/coredns' >/dev/null 2>&1"))
|
||||
elseif string.lower(string.sub(meta.file, -3, -1)) == ".gz" then
|
||||
os.execute(string.format("mv %s '/tmp/coredns/bin/coredns.gz' >/dev/null 2>&1", (tmp_dir .. meta.file)))
|
||||
os.execute("gzip -fd '/tmp/coredns/bin/coredns.gz' >/dev/null 2>&1")
|
||||
fs.unlink("/tmp/coredns/bin/coredns.gz")
|
||||
else
|
||||
os.execute(string.format("mv $(echo \"/tmp/coredns/bin/$(ls /tmp/coredns/bin/)\") '/usr/share/coredns/coredns' >/dev/null 2>&1"))
|
||||
end
|
||||
os.execute("chmod 4755 /usr/share/coredns/coredns >/dev/null 2>&1")
|
||||
os.execute(string.format("rm -rf %s >/dev/null 2>&1", tmp_dir))
|
||||
um.value = translate("Please refresh this page, the upload file has already been saved to") .. ' "/usr/share/coredns/coredns"'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
if http.formvalue("upload") then
|
||||
local f = http.formvalue("ulfile")
|
||||
if #f <= 0 then
|
||||
um.value = translate("No Specify Upload File")
|
||||
end
|
||||
end
|
||||
|
||||
-- ful:section(SimpleSection).template = "coredns/coredns_status"
|
||||
|
||||
s = ful:section(SimpleSection, translate("Plugins"))
|
||||
o = s:option(TextValue, "", "")
|
||||
o.default=coredns_plugins
|
||||
o.readonly=true
|
||||
|
||||
return ful
|
||||
@ -1,6 +0,0 @@
|
||||
m = Map("coredns")
|
||||
m.pageaction = false
|
||||
|
||||
m:append(Template("coredns/coredns_log"))
|
||||
|
||||
return m
|
||||
@ -1,110 +0,0 @@
|
||||
local api = require "luci.coredns.api"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
m = Map("coredns")
|
||||
m.redirect = api.url("rule_list")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "","DNS " .. translate("Redir Rule") .. " - " .. translate("File"))
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
||||
o = s:option(Value, "name", translate("Name"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
|
||||
o = s:option(Value, "file", translate("File"), translate("Path") .. ":/usr/share/coredns/")
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = arg[1] .. ".conf"
|
||||
|
||||
o = s:option(TextValue, "manual-input", translate("Domain List"))
|
||||
local str = translate("Please refer to") .. "<a href='https://github.com/leiless/dnsredir' target='_blank'>https://github.com/leiless/dnsredir</a>"
|
||||
str = str .. "<br> - " .. translate("DOMAIN, which the whole line is the domain name")
|
||||
str = str .. "<br> - " .. translate("server=/DOMAIN/DNS, which is the format of dnsmasq config file, note that only the DOMAIN will be honored, other fields will be simply discarded")
|
||||
str = str .. "<br> - " .. translate("Text after # character will be treated as comment")
|
||||
str = str .. "<br> - " .. translate("Unparsable lines(including whitespace-only line) are therefore just ignored")
|
||||
o.description = translate(str)
|
||||
o.template = "cbi/tvalue"
|
||||
o.rows = 10
|
||||
function o.cfgvalue(self, section)
|
||||
local file = m:get(section,"file");
|
||||
if(file == nil) then
|
||||
return "";
|
||||
else
|
||||
return fs.readfile("/usr/share/coredns/" .. file)
|
||||
end
|
||||
-- local file = "/etc/coredns/" .. m:get(section,"file")
|
||||
-- return "";
|
||||
-- return sys.call("/usr/share/coredns/coredns.sh checkfile " .. file )
|
||||
-- if (sys.call("/usr/share/coredns/coredns.sh checkfile " .. file ) == 1) then
|
||||
-- return ""
|
||||
-- else
|
||||
-- return fs.readfile(file)
|
||||
-- end
|
||||
end
|
||||
|
||||
function o.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
fs.writefile("/usr/share/coredns/" .. m:get(section,"file"), value)
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "dns", translate("DNS"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
o:value("tls://149.112.112.112", "149.112.112.112 (Quad9 DNS)")
|
||||
o:value("tls://45.11.45.11", "45.11.45.11 (DNS.SB)")
|
||||
o:value("tls://208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||
o:value("tls://208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||
o:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare DNS)")
|
||||
o:value("tls://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||
o:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
||||
o:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||
o:value("tls://9.9.9.9", "9.9.9.9 (Quad9 DNS)")
|
||||
o.default="119.29.29.29"
|
||||
|
||||
o = s:option(ListValue, "policy", translate("Policy"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o:value("random", translate("Randomly select a healthy upstream host"))
|
||||
o:value("round_robin", translate("Select a healthy upstream host in round robin order"))
|
||||
o:value("sequential", translate("Select a healthy upstream host in sequential order"))
|
||||
o.default = "random"
|
||||
|
||||
o = s:option(DynamicList, "bootstrap_dns", translate("Bootstrap DNS servers"), translate("Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"))
|
||||
o.rmempty = true
|
||||
-- o.optional = true
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
|
||||
o = s:option(Value, "path_reload", translate("Path Reload"),translate("changes the reload interval between each path in FROM, Default is 2s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "2s"
|
||||
|
||||
o = s:option(Value, "expire", translate("Expire"), translate("will expire (cached) connections after this time interval, Default is 15s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "15s"
|
||||
|
||||
o = s:option(Value, "max_fails", translate("Max Fails"), translate("is the maximum number of consecutive health checking failures that are needed before considering an upstream as down. 0 to disable this feature(which the upstream will never be marked as down), Default is 3"))
|
||||
o.default = "3"
|
||||
|
||||
o = s:option(Value, "health_check", translate("Health Check"), translate("configure the behaviour of health checking of the upstream hosts, Default is 2s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "2s"
|
||||
|
||||
return m
|
||||
@ -1,31 +0,0 @@
|
||||
local api = require "luci.coredns.api"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
m = Map("coredns")
|
||||
m.redirect = api.url("rule_list")
|
||||
m.readonly = true
|
||||
-- m.pageaction = false
|
||||
|
||||
local name = m:get(arg[1],"name")
|
||||
local file = m:get(arg[1],"file")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "", name)
|
||||
s.description = "/usr/share/coredns/" .. file
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
||||
o = s:option(TextValue, "manual-input",nil)
|
||||
o.template = "cbi/tvalue"
|
||||
-- o.description = translate("Path") .. ":/usr/share/coredns/" .. file
|
||||
o.rows = 25
|
||||
function o.cfgvalue(self, section)
|
||||
local file = m:get(section,"file");
|
||||
if(file == nil) then
|
||||
return "";
|
||||
else
|
||||
return fs.readfile("/usr/share/coredns/" .. file)
|
||||
end
|
||||
end
|
||||
|
||||
return m
|
||||
@ -1,117 +0,0 @@
|
||||
local api = require "luci.coredns.api"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
m = Map("coredns")
|
||||
m.title = "DNS " .. translate("Redir Rule")
|
||||
m.description = translate("Please refer to") .. " <a href='https://github.com/leiless/dnsredir' target='_blank'>https://github.com/leiless/dnsredir</a>"
|
||||
|
||||
-- s = m:section(TypedSection, "coredns_rule_update", translate("Rules Update"))
|
||||
-- s.anonymous = true
|
||||
|
||||
-- -- o = s:option(Button, "_update", translate("Manual subscription All"))
|
||||
-- o = s:option(Button, "_update", translate("Manual subscription All"))
|
||||
-- o.inputstyle = "apply"
|
||||
-- function o.write(t, n)
|
||||
-- luci.sys.call("lua /usr/share/coredns/update_rule.lua > /dev/null 2>&1 &")
|
||||
-- luci.http.redirect(api.url("log"))
|
||||
-- end
|
||||
|
||||
s = m:section(TypedSection, "coredns_rule_file", "DNS " .. translate("Redir Rule") .. " - " .. translate("File"))
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s.sortable = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = api.url("rule_file_config", "%s")
|
||||
function s.create(e, t)
|
||||
local id = TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(id))
|
||||
end
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enable"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(DummyValue, "name", translate("Name"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "file", translate("File"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "dns", translate("DNS"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "bootstrap_dns", translate("Bootstrap DNS"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(Button, "_view", translate("View"))
|
||||
o.inputstyle = "reset"
|
||||
function o.write(t, n)
|
||||
luci.http.redirect(api.url("rule_file_content/" .. n))
|
||||
end
|
||||
|
||||
s = m:section(TypedSection, "coredns_rule_url", "DNS " .. translate("Redir Rule") .. " - " .. translate("Subscribe"))
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s.sortable = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = api.url("rule_url_config", "%s")
|
||||
function s.create(e, t)
|
||||
local id = TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(id))
|
||||
end
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enable"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(DummyValue, "name", translate("Name"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "url", translate("Subscribe URL"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "dns", translate("DNS"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(DummyValue, "bootstrap_dns", translate("Bootstrap DNS"))
|
||||
o.width = "auto"
|
||||
o.rawhtml = true
|
||||
|
||||
o = s:option(Button, "_update", translate("Update"))
|
||||
o.inputstyle = "apply"
|
||||
function o.write(t, n)
|
||||
luci.sys.call("lua /usr/share/coredns/update_rule.lua " .. n .. " > /dev/null 2>&1 &")
|
||||
luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
o = s:option(Button, "_view", translate("View"))
|
||||
o.inputstyle = "reset"
|
||||
function o.write(t, n)
|
||||
luci.http.redirect(api.url("rule_file_content/" .. n))
|
||||
end
|
||||
|
||||
s = m:section(TypedSection, "coredns", "Hosts " .. translate("File"), translate("The hosts file has a top prority over DNS"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(TextValue, "hosts")
|
||||
o.template = "cbi/tvalue"
|
||||
o.rows = 5
|
||||
o.description = translate("Path") .. ":/usr/share/coredns/hosts"
|
||||
|
||||
function o.cfgvalue(self, section)
|
||||
return fs.readfile("/usr/share/coredns/hosts")
|
||||
end
|
||||
|
||||
function o.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
fs.writefile("/usr/share/coredns/hosts", value)
|
||||
end
|
||||
|
||||
return m
|
||||
@ -1,102 +0,0 @@
|
||||
local api = require "luci.coredns.api"
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
m = Map("coredns")
|
||||
m.redirect = api.url("rule_list")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "","DNS " .. translate("Redir Rule") .. " - " .. translate("Subscribe"))
|
||||
s.addremove = false
|
||||
s.dynamic = false
|
||||
|
||||
o = s:option(Value, "name", translate("Name"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
|
||||
o = s:option(Value, "url", translate("Subscribe URL"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
local str = translate("Please refer to") .. "<a href='https://github.com/leiless/dnsredir' target='_blank'>https://github.com/leiless/dnsredir</a>"
|
||||
str = str .. "<br> - " .. translate("DOMAIN, which the whole line is the domain name")
|
||||
str = str .. "<br> - " .. translate("server=/DOMAIN/DNS, which is the format of dnsmasq config file, note that only the DOMAIN will be honored, other fields will be simply discarded")
|
||||
str = str .. "<br> - " .. translate("Text after # character will be treated as comment")
|
||||
str = str .. "<br> - " .. translate("Unparsable lines(including whitespace-only line) are therefore just ignored")
|
||||
o.description = translate(str)
|
||||
|
||||
function o.validate(self, value)
|
||||
result = string.match(value, '[a-z]*://[^ >,;]*')
|
||||
if result == true then
|
||||
return true;
|
||||
else
|
||||
return nil, translate("Please input a valid Subscribe URL!")
|
||||
end
|
||||
end
|
||||
|
||||
o = s:option(Value, "file", translate("File"), translate("Path") .. ":/usr/share/coredns/")
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = arg[1] .. ".conf"
|
||||
function o.write(self, section, value)
|
||||
luci.sys.call("lua /usr/share/coredns/update_rule.lua " .. arg[1] .. " > /dev/null 2>&1 &")
|
||||
-- luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
o = s:option(DynamicList, "dns", translate("DNS"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
o:value("tls://149.112.112.112", "149.112.112.112 (Quad9 DNS)")
|
||||
o:value("tls://45.11.45.11", "45.11.45.11 (DNS.SB)")
|
||||
o:value("tls://208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||
o:value("tls://208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||
o:value("tls://1.1.1.1", "1.1.1.1 (CloudFlare DNS)")
|
||||
o:value("tls://1.0.0.1", "1.0.0.1 (CloudFlare DNS)")
|
||||
o:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
||||
o:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||
o:value("tls://9.9.9.9", "9.9.9.9 (Quad9 DNS)")
|
||||
o.default="119.29.29.29"
|
||||
|
||||
o = s:option(ListValue, "policy", translate("Policy"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o:value("random", translate("Randomly select a healthy upstream host"))
|
||||
o:value("round_robin", translate("Select a healthy upstream host in round robin order"))
|
||||
o:value("sequential", translate("Select a healthy upstream host in sequential order"))
|
||||
o.default = "random"
|
||||
|
||||
o = s:option(DynamicList, "bootstrap_dns", translate("Bootstrap DNS servers"), translate("Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"))
|
||||
o.rmempty = true
|
||||
-- o.optional = true
|
||||
o:value("119.29.29.29", "119.29.29.29 (DNSPod Primary)")
|
||||
o:value("119.28.28.28", "119.28.28.28 (DNSPod Secondary)")
|
||||
o:value("223.5.5.5", "223.5.5.5 (AliDNS Primary)")
|
||||
o:value("223.6.6.6", "223.6.6.6 (AliDNS Secondary)")
|
||||
o:value("114.114.114.114", "114.114.114.114 (114DNS Primary)")
|
||||
o:value("114.114.115.115", "114.114.115.115 (114DNS Secondary)")
|
||||
o:value("180.76.76.76", "180.76.76.76 (Baidu DNS)")
|
||||
|
||||
o = s:option(Value, "path_reload", translate("Path Reload"),translate("changes the reload interval between each path in FROM, Default is 2s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "2s"
|
||||
|
||||
o = s:option(Value, "expire", translate("Expire"), translate("will expire (cached) connections after this time interval, Default is 15s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "15s"
|
||||
|
||||
o = s:option(Value, "max_fails", translate("Max Fails"), translate("is the maximum number of consecutive health checking failures that are needed before considering an upstream as down. 0 to disable this feature(which the upstream will never be marked as down), Default is 3"))
|
||||
o.default = "3"
|
||||
|
||||
o = s:option(Value, "health_check", translate("Health Check"), translate("configure the behaviour of health checking of the upstream hosts, Default is 2s, minimal is 1s"))
|
||||
o.rmempty = false
|
||||
o.optional = false
|
||||
o.default = "2s"
|
||||
|
||||
return m
|
||||
@ -1,29 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clear_log(btn) {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[coredns]], [[clear_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;
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(1, '<%=url([[admin]], [[services]], [[coredns]], [[get_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="clear_log()" value="<%:Clear Logs%>" style="margin-left: 10px; margin-top: 10px;">
|
||||
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 645px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
|
||||
</fieldset>
|
||||
@ -1,28 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[coredns]], [[plugins]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('coredns_plugins');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = data;
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>
|
||||
.mar-10 {
|
||||
margin-left: 50px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="coredns_plugins">
|
||||
<em><%:Collecting data%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@ -1,28 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[coredns]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('coredns_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b style=color:green>CoreDNS <%:RUNNING%></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b style=color:red>CoreDNS <%:NOT RUNNING%></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>
|
||||
.mar-10 {
|
||||
margin-left: 50px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="coredns_status">
|
||||
<em><%:Collecting data%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@ -1,15 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<div style="text-align: center; margin:0 auto; display: block; width: 100%; height: 50px; text-overflow: ellipsis;">
|
||||
<div>
|
||||
<b style="color:red"><%:The plugins dnsredir & cache are required at least%>!</b>
|
||||
<br>
|
||||
<%:CoreDNS program can be download from%> <a href="https://github.com/missdeer/coredns_custom_build" target="_blank">https://github.com/missdeer/coredns_custom_build</a>.
|
||||
</div>
|
||||
<div style="color: green; transform:translateY(100%);">
|
||||
<%
|
||||
local val = self:cfgvalue(section) or self.default or ""
|
||||
write(pcdata(val))
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
<%+cbi/valuefooter%>
|
||||
@ -1,35 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function update_data(btn, dataname)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Updating%> ';
|
||||
st=dataname;
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "coredns", "rule_refresh")%>',
|
||||
{ set:st },
|
||||
function(x,data)
|
||||
{
|
||||
var tb = document.getElementById(dataname+'-status');
|
||||
if (tb)
|
||||
{
|
||||
switch (data.updating)
|
||||
{
|
||||
case true:
|
||||
tb.innerHTML = "<font color='green'>" + "<%:Update success%>" + "</font>";
|
||||
break;
|
||||
case false:
|
||||
tb.innerHTML = "<font color='red'>" + "<%:Update failed, Please check the network status%>" + "</font>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Check And Update%>';
|
||||
}
|
||||
);
|
||||
location.href="log";
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return update_data(this,'<%=self.option%>')" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
<%+cbi/valuefooter%>
|
||||
@ -1,7 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<div style="text-align: center; margin:0 auto; display:block; white-space: nowrap;">
|
||||
<!-- <label class="cbi-value" for="ulfile"><%:CoreDNS Program:%></label> -->
|
||||
<input class="cbi-input-file" type="file" id="ulfile" name="ulfile" />
|
||||
<input type="submit" class="btn cbi-button cbi-input-reload" name="upload" value="<%:Upload%>" />
|
||||
</div>
|
||||
<%+cbi/valuefooter%>
|
||||
@ -1,254 +0,0 @@
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Redir Rule"
|
||||
msgstr "转发规则"
|
||||
|
||||
msgid "Auto Update"
|
||||
msgstr "自动更新"
|
||||
|
||||
msgid "Rule Update"
|
||||
msgstr "规则更新"
|
||||
|
||||
msgid "Core Update"
|
||||
msgstr "程序更新"
|
||||
|
||||
msgid "Please refer to"
|
||||
msgstr "请参考"
|
||||
|
||||
msgid "Unknown Version, Pleaes upload a valid CoreDNS program"
|
||||
msgstr "未知版本,请上传一个可用的CoreDNS程序"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Collecting data"
|
||||
msgstr "获取数据中"
|
||||
|
||||
msgid "Basic Options"
|
||||
msgstr "基本选项"
|
||||
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
msgid "DNSMASQ Forward"
|
||||
msgstr "DNS 转发"
|
||||
|
||||
msgid "Forward Dnsmasq Domain Name resolution requests to CoreDNS"
|
||||
msgstr "将 Dnsmasq 域名解析请求转发到 CoreDNS 服务器"
|
||||
|
||||
msgid "Reload Service"
|
||||
msgstr "重载服务"
|
||||
|
||||
msgid "Reload service to take effect of new configuration"
|
||||
msgstr "重载 CoreDNS 服务生效配置文件"
|
||||
|
||||
msgid "Edit the custom Corefile in above textarea as you own need"
|
||||
msgstr "请在上面的文本框中编写完整的CoreDNS配置文件"
|
||||
|
||||
msgid "Enable Cache"
|
||||
msgstr "启用缓存"
|
||||
|
||||
msgid "Enable Log"
|
||||
msgstr "启用日志"
|
||||
|
||||
msgid "Please do NOT enable cache when working with OpenClash, AdguardHome"
|
||||
msgstr "当和OpenClash, AdguardHome配合使用时请不要启用缓存"
|
||||
|
||||
msgid "Default DNS"
|
||||
msgstr "默认DNS"
|
||||
|
||||
msgid "Upstream DNS server"
|
||||
msgstr "此DNS服务器将会被设置为默认的DNS上游服务器,优先级低于转发规则中指定的DNS服务器"
|
||||
|
||||
msgid "Randomly select a healthy upstream host"
|
||||
msgstr "随机选择一个可用的DNS服务器"
|
||||
|
||||
msgid "Select a healthy upstream host in round robin order"
|
||||
msgstr "循环选择一个可用的DNS服务器"
|
||||
|
||||
msgid "Select a healthy upstream host in sequential order"
|
||||
msgstr "按顺序选择一个可用的DNS服务器"
|
||||
|
||||
msgid "Bootstrap DNS servers"
|
||||
msgstr "Bootstrap DNS 服务器"
|
||||
|
||||
msgid "Bootstrap DNS servers are used to resolve IP addresses of the DoH/DoT resolvers you specify as upstreams"
|
||||
msgstr "Bootstrap DNS 服务器用于解析您指定为上游的 DoH / DoT 解析器的 IP 地址"
|
||||
|
||||
msgid "Subscribe"
|
||||
msgstr "订阅"
|
||||
|
||||
msgid "Subscribe URL"
|
||||
msgstr "订阅地址(URL)"
|
||||
|
||||
msgid "Manual subscription"
|
||||
msgstr "手工订阅"
|
||||
|
||||
msgid "Refresh"
|
||||
msgstr "刷新"
|
||||
|
||||
msgid "Update"
|
||||
msgstr "更新"
|
||||
|
||||
msgid "View"
|
||||
msgstr "查看"
|
||||
|
||||
msgid "Domain List"
|
||||
msgstr "域名列表"
|
||||
|
||||
msgid "DOMAIN, which the whole line is the domain name"
|
||||
msgstr "DOMAIN, 整行填写完整的域名"
|
||||
|
||||
msgid "server=/DOMAIN/DNS, which is the format of dnsmasq config file, note that only the DOMAIN will be honored, other fields will be simply discarded"
|
||||
msgstr "server=/DOMAIN/DNS, 按照Dnsmasq的域名转发规则填写,仅域名将会被使用"
|
||||
|
||||
msgid "Text after # character will be treated as comment"
|
||||
msgstr "#开头的行为注释行不起作用"
|
||||
|
||||
msgid "Unparsable lines(including whitespace-only line) are therefore just ignored"
|
||||
msgstr "不符合规则的行(例如空行)将会被忽略"
|
||||
|
||||
msgid "Disable IPv6"
|
||||
msgstr "禁用IPv6 DNS解析"
|
||||
|
||||
msgid "Path Reload"
|
||||
msgstr "文件扫描时间间隔"
|
||||
|
||||
msgid "changes the reload interval between each path in FROM, Default is 2s, minimal is 1s"
|
||||
msgstr "规则文件的扫描时间间隔,默认值是2s,最小值是1s"
|
||||
|
||||
msgid "Expire"
|
||||
msgstr "连接保持时间"
|
||||
|
||||
msgid "will expire (cached) connections after this time interval, Default is 15s, minimal is 1s"
|
||||
msgstr "在这个时间之后连接将会过期,默认值是15s,最小值是1s"
|
||||
|
||||
msgid "Max Fails"
|
||||
msgstr "最大失败次数"
|
||||
|
||||
msgid "is the maximum number of consecutive health checking failures that are needed before considering an upstream as down. 0 to disable this feature(which the upstream will never be marked as down), Default is 3"
|
||||
msgstr "DNS服务器失败次数超过这个数值之后这个DNS服务器将会被禁用,设置为0表示禁用这个功能(即是永远不会禁用DNS服务器),默认值是3"
|
||||
|
||||
msgid "Health Check"
|
||||
msgstr "DNS健康检测周期"
|
||||
|
||||
msgid "configure the behaviour of health checking of the upstream hosts, Default is 2s, minimal is 1s"
|
||||
msgstr "DNS服务器健康检测周期,默认值是2s,最小值是1s"
|
||||
|
||||
msgid "Please input a valid Subscribe URL!"
|
||||
msgstr "请输入有效的订阅URL地址"
|
||||
|
||||
msgid "Path"
|
||||
msgstr "路径"
|
||||
|
||||
msgid "The hosts file has a top prority over DNS"
|
||||
msgstr "hosts文件拥有DNS解析的最高优先级"
|
||||
|
||||
msgid "Update DNS Redir Rules Subscribe"
|
||||
msgstr "更新转发规则的订阅"
|
||||
|
||||
msgid "Update Time"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Update Cycle"
|
||||
msgstr "更新周期"
|
||||
|
||||
msgid "Clear Cycle"
|
||||
msgstr "清空周期"
|
||||
|
||||
msgid "Every"
|
||||
msgstr "每"
|
||||
|
||||
msgid "hours"
|
||||
msgstr "小时"
|
||||
|
||||
msgid "Every Day"
|
||||
msgstr "每天"
|
||||
|
||||
msgid "Every Monday"
|
||||
msgstr "每周一"
|
||||
|
||||
msgid "Every Tuesday"
|
||||
msgstr "每周二"
|
||||
|
||||
msgid "Every Wednesday"
|
||||
msgstr "每周三"
|
||||
|
||||
msgid "Every Thursday"
|
||||
msgstr "每周四"
|
||||
|
||||
msgid "Every Friday"
|
||||
msgstr "每周五"
|
||||
|
||||
msgid "Every Saturday"
|
||||
msgstr "每周六"
|
||||
|
||||
msgid "Every Sunday"
|
||||
msgstr "每周日"
|
||||
|
||||
msgid "Check And Update"
|
||||
msgstr "检查并更新"
|
||||
|
||||
msgid "Enable Auto Update"
|
||||
msgstr "启用自动更新"
|
||||
|
||||
msgid "Enable Auto Clear"
|
||||
msgstr "启用自动清空"
|
||||
|
||||
msgid "Updating"
|
||||
msgstr "正在更新"
|
||||
|
||||
msgid "Update success"
|
||||
msgstr "更新成功"
|
||||
|
||||
msgid "Update failed, Please check the network status"
|
||||
msgstr "更新失败,请检查网络状态"
|
||||
|
||||
msgid "Config File"
|
||||
msgstr "配置文件"
|
||||
|
||||
msgid "Default Config"
|
||||
msgstr "内置预设"
|
||||
|
||||
msgid "Custom Config"
|
||||
msgstr "自定义"
|
||||
|
||||
msgid "Log File"
|
||||
msgstr "日志文件"
|
||||
|
||||
msgid "Logs"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Clear Logs"
|
||||
msgstr "清空日志"
|
||||
|
||||
msgid "Upload"
|
||||
msgstr "上传"
|
||||
|
||||
msgid "CoreDNS program can be download from"
|
||||
msgstr "CoreDNS 程序下载地址:"
|
||||
|
||||
msgid "The plugins dnsredir & cache are required at least"
|
||||
msgstr "请务必上传内置dnsredir & cache插件的CoreDNS程序"
|
||||
|
||||
msgid "Plugins"
|
||||
msgstr "插件列表"
|
||||
|
||||
msgid "Cannot get plugins list, please check if coredns program was uploaded correctly"
|
||||
msgstr "无法获取插件列表,请上传一个可用的CoreDNS程序"
|
||||
|
||||
msgid "Create upload file error"
|
||||
msgstr "创建上传文件失败"
|
||||
|
||||
msgid "Please refresh this page, the upload file has already been saved to"
|
||||
msgstr "请手工刷新此页面,上传的文件已经保存到"
|
||||
|
||||
msgid "No Specify Upload File"
|
||||
msgstr "未指定上传文件"
|
||||
@ -1 +0,0 @@
|
||||
zh-cn
|
||||
@ -1,79 +0,0 @@
|
||||
config global 'global'
|
||||
option logfile '/tmp/coredns.log'
|
||||
option binfile '/usr/share/coredns/coredns'
|
||||
option conf_folder '/usr/share/coredns/'
|
||||
|
||||
config coredns 'config'
|
||||
option enabled '0'
|
||||
option listen_port '5336'
|
||||
option redirect '0'
|
||||
option enabled_custom '0'
|
||||
option enabled_cache '0'
|
||||
option enabled_log '1'
|
||||
option configfile '/usr/share/coredns/Corefile'
|
||||
list dns '127.0.0.1:7874'
|
||||
option policy 'random'
|
||||
option path_reload '60s'
|
||||
option expire '15s'
|
||||
option max_fails '3'
|
||||
option health_check '2s'
|
||||
option disable_ipv6 '0'
|
||||
|
||||
config coredns_rule_update 'rule_update'
|
||||
option rule_auto_update '0'
|
||||
option rule_update_week_time '*'
|
||||
option rule_update_day_time '0'
|
||||
|
||||
config coredns_clear_log 'clear_log'
|
||||
option log_auto_clear '1'
|
||||
option log_clear_hour '2'
|
||||
|
||||
config coredns_rule_url
|
||||
option name '中国域名'
|
||||
option file 'accelerated-domains.china.conf'
|
||||
option url 'https://ghproxy.com/https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf'
|
||||
option enabled '0'
|
||||
list dns '119.29.29.29'
|
||||
list dns '223.5.5.5'
|
||||
option policy 'random'
|
||||
option path_reload '60s'
|
||||
option expire '15s'
|
||||
option max_fails '3'
|
||||
option health_check '2s'
|
||||
|
||||
config coredns_rule_url
|
||||
option name '苹果域名'
|
||||
option file 'apple.china.conf'
|
||||
option url 'https://ghproxy.com/https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf'
|
||||
option enabled '0'
|
||||
list dns '119.29.29.29'
|
||||
list dns '223.5.5.5'
|
||||
option policy 'random'
|
||||
option path_reload '60s'
|
||||
option expire '15s'
|
||||
option max_fails '3'
|
||||
option health_check '2s'
|
||||
|
||||
config coredns_rule_url
|
||||
option name '谷歌域名'
|
||||
option file 'google.china.conf'
|
||||
option url 'https://ghproxy.com/https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf'
|
||||
option enabled '0'
|
||||
list dns '119.29.29.29'
|
||||
list dns '223.5.5.5'
|
||||
option policy 'random'
|
||||
option path_reload '60s'
|
||||
option expire '15s'
|
||||
option max_fails '3'
|
||||
option health_check '2s'
|
||||
|
||||
config coredns_rule_file
|
||||
option name '微软域名'
|
||||
option file 'microsoft.china.conf'
|
||||
option enabled '0'
|
||||
list dns '4.2.2.2'
|
||||
option policy 'random'
|
||||
option path_reload '60s'
|
||||
option expire '15s'
|
||||
option max_fails '3'
|
||||
option health_check '2s'
|
||||
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ "$ACTION" = ifup ] && /etc/init.d/coredns restart
|
||||
@ -1,159 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2023, tracemouse
|
||||
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
PROG=/usr/share/coredns/coredns
|
||||
CONF=$(uci -q get coredns.config.configfile)
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
DEFAULT_CONF=/usr/share/coredns/Corefile
|
||||
RULE_UPDATE_SCRIPT="lua /usr/share/coredns/update_rule.lua > /dev/null"
|
||||
GEN_COREFILE_SCRIPT=/usr/share/coredns/gen_corefile.sh
|
||||
|
||||
get_config() {
|
||||
config_get enabled $1 enabled 0
|
||||
config_get enabled_custom $1 enabled_custom 0
|
||||
config_get redirect $1 redirect 0
|
||||
config_get listen_port $1 listen_port 5336
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "coredns"
|
||||
}
|
||||
|
||||
restore_setting() {
|
||||
echo "开始重置 dnsmasq 设置..." >> /tmp/coredns.log
|
||||
rm -rf /usr/share/coredns/redirect.lock
|
||||
sed -i "/list server/d" /etc/config/dhcp
|
||||
uci set dhcp.@dnsmasq[0].noresolv='0'
|
||||
uci del dhcp.@dnsmasq[0].cachesize
|
||||
uci commit dhcp
|
||||
}
|
||||
|
||||
redirect_setting() {
|
||||
echo "开始设置 dnsmasq 转发..." >> /tmp/coredns.log
|
||||
sed -i "/list server/d" /etc/config/dhcp
|
||||
uci add_list dhcp.@dnsmasq[0].server="127.0.0.1#$listen_port"
|
||||
uci set dhcp.@dnsmasq[0].rebind_protection='0'
|
||||
uci set dhcp.@dnsmasq[0].noresolv="1"
|
||||
uci set dhcp.@dnsmasq[0].cachesize='0'
|
||||
uci commit dhcp
|
||||
touch /usr/share/coredns/redirect.lock
|
||||
}
|
||||
|
||||
reload_dnsmasq() {
|
||||
echo "开始重启 dnsmasq 服务..." >> /tmp/coredns.log
|
||||
/etc/init.d/dnsmasq reload
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
echo "开始重启 coredns 服务..." >> /tmp/coredns.log
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
echo "已完成重启 coredns 服务..." >> /tmp/coredns.log
|
||||
}
|
||||
|
||||
setcron() {
|
||||
echo "设置定时脚本..." >> /tmp/coredns.log
|
||||
sed -i '/\/usr\/share\/coredns/d' $CRON_FILE 2>/dev/null
|
||||
rule_auto_update=$(uci -q get coredns.rule_update.rule_auto_update)
|
||||
rule_update_week_time=$(uci -q get coredns.rule_update.rule_update_week_time)
|
||||
rule_update_day_time=$(uci -q get coredns.rule_update.rule_update_day_time)
|
||||
|
||||
if [ "$rule_auto_update" -eq 1 ]
|
||||
then
|
||||
echo "开始设置转发规则自动更新" >> /tmp/coredns.log
|
||||
task="0 $rule_update_day_time * * $rule_update_week_time $RULE_UPDATE_SCRIPT"
|
||||
echo "添加定时规则 ${task}" >> /tmp/coredns.log
|
||||
echo "${task}" >> $CRON_FILE
|
||||
echo "已完成添加"
|
||||
else
|
||||
echo "未启用转发规则自动更新" >> /tmp/coredns.log
|
||||
fi
|
||||
|
||||
log_auto_clear=$(uci -q get coredns.clear_log.log_auto_clear)
|
||||
log_clear_hour=$(uci -q get coredns.clear_log.log_clear_hour)
|
||||
|
||||
if [ "$log_auto_clear" -eq 1 ]
|
||||
then
|
||||
echo "开始设置自动清空日志" >> /tmp/coredns.log
|
||||
task="0 */${log_clear_hour} * * * /usr/share/coredns/clear_log.sh"
|
||||
echo "添加定时规则 ${task}" >> /tmp/coredns.log
|
||||
echo "${task}" >> $CRON_FILE
|
||||
echo "已完成添加"
|
||||
else
|
||||
echo "未启用自动清空日志" >> /tmp/coredns.log
|
||||
echo "为防止占用过多内存将强制设置为每天0点清空日志" >> /tmp/coredns.log
|
||||
task="0 0 * * * /usr/share/coredns/clear_log.sh"
|
||||
echo "添加定时规则 ${task}" >> /tmp/coredns.log
|
||||
echo "${task}" >> $CRON_FILE
|
||||
echo "已完成添加"
|
||||
fi
|
||||
|
||||
echo "开始重载定时任务配置文件"
|
||||
crontab $CRON_FILE
|
||||
|
||||
echo "完成设置定时脚本" >> /tmp/coredns.log
|
||||
}
|
||||
|
||||
delcron() {
|
||||
echo "删除定时脚本..." >> /tmp/coredns.log
|
||||
sed -i '/\/usr\/share\/coredns/d' $CRON_FILE 2>/dev/null
|
||||
crontab $CRON_FILE
|
||||
}
|
||||
|
||||
start_service() {
|
||||
echo "开始启动 coredns 服务..." >> /tmp/coredns.log
|
||||
config_load "coredns"
|
||||
config_foreach get_config "coredns"
|
||||
if [ $enabled -ne 1 ]
|
||||
then
|
||||
echo "未设置启用 coredns ,服务将不会启动" >> /tmp/coredns.log
|
||||
return 1
|
||||
fi
|
||||
|
||||
delcron ; setcron
|
||||
|
||||
if [ "${CONF}" = "/usr/share/coredns/Corefile" ]
|
||||
then
|
||||
# $(GEN_COREFILE_SCRIPT)
|
||||
sh /usr/share/coredns/gen_corefile.sh
|
||||
fi
|
||||
|
||||
#LOG_FILE=$(uci -q get coredns.global.logfile)
|
||||
#rm -rf ${LOG_FILE}
|
||||
|
||||
procd_open_instance coredns
|
||||
# procd_set_param command $PROG -conf="$CONF" > /tmp/coredns.log
|
||||
# procd_set_param command $PROG -conf="$CONF"
|
||||
procd_set_param command /usr/share/coredns/start_coredns.sh
|
||||
procd_set_param user root
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
|
||||
procd_close_instance coredns
|
||||
|
||||
[ "$redirect" -ne 1 ] && [ -f "/usr/share/coredns/redirect.lock" ] && restore_setting
|
||||
[ "$redirect" -eq 1 ] && redirect_setting
|
||||
reload_dnsmasq
|
||||
echo "已完成启动 coredns 服务..." >> /tmp/coredns.log
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
echo "停止 coredns 服务..." >> /tmp/coredns.log
|
||||
# killall coredns >> /tmp/coredns.log
|
||||
pgrep -f /usr/share/coredns/coredns | xargs kill >> /tmp/coredns.log
|
||||
echo "已停止 coredns 服务..." >> /tmp/coredns.log
|
||||
|
||||
config_load "coredns"
|
||||
config_foreach get_config "coredns"
|
||||
# [ "$enabled" -eq "0" ] && [ -f "/usr/share/coredns/redirect.lock" ] && restore_setting
|
||||
[ -f "/usr/share/coredns/redirect.lock" ] && restore_setting
|
||||
# restore_setting
|
||||
reload_dnsmasq
|
||||
delcron
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-coredns.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-coredns.json << EEOF
|
||||
{
|
||||
"config": "coredns",
|
||||
"init": "coredns"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@coredns[-1]
|
||||
add ucitrack coredns
|
||||
set ucitrack.@coredns[-1].init=coredns
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -rf /tmp/luci-*
|
||||
exit 0
|
||||
@ -1,77 +0,0 @@
|
||||
(ads) {
|
||||
ads {
|
||||
default-lists
|
||||
blacklist https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt
|
||||
whitelist https://files.krnl.eu/whitelist.txt
|
||||
log
|
||||
auto-update-interval 24h
|
||||
list-store ads-cache
|
||||
}
|
||||
}
|
||||
|
||||
(dnsredir_default) {
|
||||
dnsredir . {
|
||||
expire 30s
|
||||
max_fails 3
|
||||
health_check 3s
|
||||
policy random
|
||||
spray
|
||||
|
||||
to 114.114.114.114
|
||||
#to tls://8.8.8.8@dns.google tls://8.8.4.4@dns.google
|
||||
#to tls://1.1.1.1@1dot1dot1dot1.cloudflare-dns.com tls://1.0.0.1@1dot1dot1dot1.cloudflare-dns.com
|
||||
# Global TLS server name
|
||||
# tls_servername cloudflare-dns.com
|
||||
}
|
||||
}
|
||||
|
||||
(dnsredir_1) {
|
||||
dnsredir https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf {
|
||||
#dnsredir accelerated-domains.china.conf {
|
||||
expire 30s
|
||||
max_fails 3
|
||||
health_check 3s
|
||||
policy round_robin
|
||||
path_reload 60m
|
||||
spray
|
||||
|
||||
to 119.29.29.29 114.114.114.114 223.5.5.5
|
||||
}
|
||||
}
|
||||
|
||||
(global_cache) {
|
||||
# https://coredns.io/plugins/cache/
|
||||
cache {
|
||||
# [5, 60]
|
||||
success 65536 3600 300
|
||||
# [1, 10]
|
||||
denial 8192 600 60
|
||||
prefetch 1 60m 10%
|
||||
}
|
||||
}
|
||||
|
||||
.:5366 {
|
||||
|
||||
hosts {
|
||||
fallthrough
|
||||
}
|
||||
health
|
||||
#prometheus :9153
|
||||
errors
|
||||
log
|
||||
loop
|
||||
reload 3600s
|
||||
|
||||
import global_cache
|
||||
|
||||
template ANY AAAA {
|
||||
rcode NXDOMAIN
|
||||
}
|
||||
|
||||
#import ads
|
||||
|
||||
#import dnsredir_1
|
||||
|
||||
import dnsredir_default
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,137 +0,0 @@
|
||||
server=/a1.mzstatic.com/114.114.114.114
|
||||
server=/a2.mzstatic.com/114.114.114.114
|
||||
server=/a3.mzstatic.com/114.114.114.114
|
||||
server=/a4.mzstatic.com/114.114.114.114
|
||||
server=/a5.mzstatic.com/114.114.114.114
|
||||
server=/adcdownload.apple.com.akadns.net/114.114.114.114
|
||||
server=/adcdownload.apple.com/114.114.114.114
|
||||
server=/app-site-association.cdn-apple.com/114.114.114.114
|
||||
server=/appldnld.apple.com/114.114.114.114
|
||||
server=/appldnld.g.aaplimg.com/114.114.114.114
|
||||
server=/appleid.cdn-apple.com/114.114.114.114
|
||||
server=/apps.apple.com/114.114.114.114
|
||||
server=/apps.mzstatic.com/114.114.114.114
|
||||
server=/cdn-cn1.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn-cn2.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn-cn3.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn-cn4.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn1.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn2.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn3.apple-mapkit.com/114.114.114.114
|
||||
server=/cdn4.apple-mapkit.com/114.114.114.114
|
||||
server=/cds-cdn.v.aaplimg.com/114.114.114.114
|
||||
server=/cds.apple.com.akadns.net/114.114.114.114
|
||||
server=/cds.apple.com/114.114.114.114
|
||||
server=/cdsassets.apple.com/114.114.114.114
|
||||
server=/cl1-cdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/cl1.apple.com/114.114.114.114
|
||||
server=/cl2-cn.apple.com/114.114.114.114
|
||||
server=/cl2.apple.com/114.114.114.114
|
||||
server=/cl3-cdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/cl3.apple.com/114.114.114.114
|
||||
server=/cl4-cdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/cl4-cn.apple.com/114.114.114.114
|
||||
server=/cl4.apple.com/114.114.114.114
|
||||
server=/cl5-cdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/cl5.apple.com/114.114.114.114
|
||||
server=/clientflow.apple.com.akadns.net/114.114.114.114
|
||||
server=/clientflow.apple.com/114.114.114.114
|
||||
server=/configuration.apple.com.akadns.net/114.114.114.114
|
||||
server=/configuration.apple.com/114.114.114.114
|
||||
server=/cstat.apple.com/114.114.114.114
|
||||
server=/cstat.cdn-apple.com/114.114.114.114
|
||||
server=/dd-cdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/download.developer.apple.com/114.114.114.114
|
||||
server=/gs-loc-cn.apple.com/114.114.114.114
|
||||
server=/gs-loc.apple.com/114.114.114.114
|
||||
server=/gsp10-ssl-cn.ls.apple.com/114.114.114.114
|
||||
server=/gsp13-cn.ls.apple.com/114.114.114.114
|
||||
server=/gsp4-cn.ls.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
|
||||
server=/gsp4-cn.ls.apple.com.edgekey.net/114.114.114.114
|
||||
server=/gsp4-cn.ls.apple.com/114.114.114.114
|
||||
server=/gsp5-cn.ls.apple.com/114.114.114.114
|
||||
server=/gsp85-cn-ssl.ls.apple.com/114.114.114.114
|
||||
server=/gspe19-cn-ssl.ls.apple.com/114.114.114.114
|
||||
server=/gspe19-cn.ls-apple.com.akadns.net/114.114.114.114
|
||||
server=/gspe19-cn.ls.apple.com/114.114.114.114
|
||||
server=/gspe21-ssl.ls.apple.com/114.114.114.114
|
||||
server=/gspe21.ls.apple.com/114.114.114.114
|
||||
server=/gspe35-ssl.ls.apple.com/114.114.114.114
|
||||
server=/guzzoni-apple-com.v.aaplimg.com/114.114.114.114
|
||||
server=/guzzoni.apple.com/114.114.114.114
|
||||
server=/iadsdk.apple.com/114.114.114.114
|
||||
server=/icloud-cdn.icloud.com.akadns.net/114.114.114.114
|
||||
server=/icloud.cdn-apple.com/114.114.114.114
|
||||
server=/images.apple.com.akadns.net/114.114.114.114
|
||||
server=/images.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
|
||||
server=/images.apple.com/114.114.114.114
|
||||
server=/init-p01md-lb.push-apple.com.akadns.net/114.114.114.114
|
||||
server=/init-p01md.apple.com/114.114.114.114
|
||||
server=/init-p01st-lb.push-apple.com.akadns.net/114.114.114.114
|
||||
server=/init-p01st.push.apple.com/114.114.114.114
|
||||
server=/init-s01st-lb.push-apple.com.akadns.net/114.114.114.114
|
||||
server=/init-s01st.push.apple.com/114.114.114.114
|
||||
server=/iosapps.itunes.g.aaplimg.com/114.114.114.114
|
||||
server=/ipcdn.apple.com/114.114.114.114
|
||||
server=/iphone-ld.apple.com/114.114.114.114
|
||||
server=/is1-ssl.mzstatic.com/114.114.114.114
|
||||
server=/is1.mzstatic.com/114.114.114.114
|
||||
server=/is2-ssl.mzstatic.com/114.114.114.114
|
||||
server=/is2.mzstatic.com/114.114.114.114
|
||||
server=/is3-ssl.mzstatic.com/114.114.114.114
|
||||
server=/is3.mzstatic.com/114.114.114.114
|
||||
server=/is4-ssl.mzstatic.com/114.114.114.114
|
||||
server=/is4.mzstatic.com/114.114.114.114
|
||||
server=/is5-ssl.mzstatic.com/114.114.114.114
|
||||
server=/is5.mzstatic.com/114.114.114.114
|
||||
server=/itunes-apple.com.akadns.net/114.114.114.114
|
||||
server=/itunes.apple.com/114.114.114.114
|
||||
server=/itunesconnect.apple.com/114.114.114.114
|
||||
server=/mesu-cdn.apple.com.akadns.net/114.114.114.114
|
||||
server=/mesu-china.apple.com.akadns.net/114.114.114.114
|
||||
server=/mesu.apple.com/114.114.114.114
|
||||
server=/music.apple.com/114.114.114.114
|
||||
server=/ocsp-lb.apple.com.akadns.net/114.114.114.114
|
||||
server=/ocsp.apple.com/114.114.114.114
|
||||
server=/ocsp2.apple.com/114.114.114.114
|
||||
server=/oscdn.apple.com/114.114.114.114
|
||||
server=/oscdn.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/osxapps.itunes.g.aaplimg.com/114.114.114.114
|
||||
server=/pancake.apple.com/114.114.114.114
|
||||
server=/pancake.cdn-apple.com.akadns.net/114.114.114.114
|
||||
server=/prod-support.apple-support.akadns.net/114.114.114.114
|
||||
server=/publicassets.cdn-apple.com/114.114.114.114
|
||||
server=/reserve-prime.apple.com/114.114.114.114
|
||||
server=/s.mzstatic.com/114.114.114.114
|
||||
server=/smp-device-content.apple.com/114.114.114.114
|
||||
server=/stocks-sparkline-lb.apple.com.akadns.net/114.114.114.114
|
||||
server=/stocks-sparkline.apple.com/114.114.114.114
|
||||
server=/store.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
|
||||
server=/store.apple.com.edgekey.net/114.114.114.114
|
||||
server=/store.apple.com/114.114.114.114
|
||||
server=/store.storeimages.apple.com.akadns.net/114.114.114.114
|
||||
server=/store.storeimages.cdn-apple.com/114.114.114.114
|
||||
server=/support-china.apple-support.akadns.net/114.114.114.114
|
||||
server=/support.apple.com/114.114.114.114
|
||||
server=/swallow.apple.com/114.114.114.114
|
||||
server=/swallow-apple-com.v.aaplimg.com/114.114.114.114
|
||||
server=/swcatalog-cdn.apple.com.akadns.net/114.114.114.114
|
||||
server=/swcatalog.apple.com/114.114.114.114
|
||||
server=/swcdn.apple.com/114.114.114.114
|
||||
server=/swcdn.g.aaplimg.com/114.114.114.114
|
||||
server=/swdist.apple.com.akadns.net/114.114.114.114
|
||||
server=/swdist.apple.com/114.114.114.114
|
||||
server=/swscan-cdn.apple.com.akadns.net/114.114.114.114
|
||||
server=/swscan.apple.com/114.114.114.114
|
||||
server=/updates-http.cdn-apple.com.akadns.net/114.114.114.114
|
||||
server=/updates-http.cdn-apple.com/114.114.114.114
|
||||
server=/updates.cdn-apple.com/114.114.114.114
|
||||
server=/valid.apple.com/114.114.114.114
|
||||
server=/valid.origin-apple.com.akadns.net/114.114.114.114
|
||||
server=/weather-data.apple.com.akadns.net/114.114.114.114
|
||||
server=/weather-data.apple.com/114.114.114.114
|
||||
server=/www.apple.com.edgekey.net.globalredir.akadns.net/114.114.114.114
|
||||
server=/www.apple.com.edgekey.net/114.114.114.114
|
||||
server=/www.apple.com/114.114.114.114
|
||||
server=/xp.apple.com/114.114.114.114
|
||||
@ -1,6 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
CONF_FILE=$(uci -q get coredns.config.configfile)
|
||||
LOG_FILE=$(uci -q get coredns.global.logfile)
|
||||
|
||||
cat /dev/null > $LOG_FILE
|
||||
@ -1,19 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_action=${1}
|
||||
|
||||
restart_service() {
|
||||
/etc/init.d/coredns restart
|
||||
}
|
||||
|
||||
case $script_action in
|
||||
"restart_service")
|
||||
restart_service
|
||||
;;
|
||||
"checkfile")
|
||||
[ -f ${2} ] && echo true || echo false
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
Binary file not shown.
@ -1,135 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. $IPKG_INSTROOT/lib/functions.sh
|
||||
|
||||
get_coredns() {
|
||||
config_get enabled $1 enabled 0
|
||||
config_get listen_port $1 listen_port 5336
|
||||
config_get redirect $1 redirect 0
|
||||
config_get dns $1 dns "119.29.29.29 223.5.5.5"
|
||||
config_get bootstrap_dns $1 bootstrap_dns ""
|
||||
config_get policy $1 policy "random"
|
||||
config_get enabled_cache $1 enabled_cache 0
|
||||
config_get configfile $1 configfile "/usr/share/coredns/Corefile"
|
||||
config_get path_reload $1 path_reload "2s"
|
||||
config_get expire $1 expire "15s"
|
||||
config_get max_fails $1 max_fails "3"
|
||||
config_get health_check $1 health_check "2s"
|
||||
config_get disable_ipv6 $1 disable_ipv6 "0"
|
||||
}
|
||||
|
||||
get_coredns_redir() {
|
||||
config_get name $1 name ""
|
||||
config_get file $1 file ""
|
||||
config_get enabled $1 enabled 0
|
||||
config_get dns $1 dns "119.29.29.29 223.5.5.5"
|
||||
config_get bootstrap_dns $1 bootstrap_dns ""
|
||||
config_get policy $1 policy "random"
|
||||
config_get path_reload $1 path_reload "2s"
|
||||
config_get expire $1 expire "15s"
|
||||
config_get max_fails $1 max_fails "3"
|
||||
config_get health_check $1 health_check "2s"
|
||||
|
||||
if [ $enabled -ne 0 ]
|
||||
then
|
||||
echo "dnsredir /usr/share/coredns/${file} {"
|
||||
echo " path_reload $path_reload"
|
||||
|
||||
echo " max_fails $max_fails"
|
||||
echo " health_check $health_check"
|
||||
echo " policy $policy"
|
||||
echo " spray"
|
||||
echo ""
|
||||
echo " to $dns"
|
||||
echo " expire $expire"
|
||||
[[ "$bootstrap_dns" != "" ]] && echo " bootstrap $bootstrap_dns"
|
||||
echo " no_ipv6"
|
||||
echo " }"
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
echo "开始生成 coredns 配置文件" >> /tmp/coredns.log
|
||||
|
||||
config_load "coredns"
|
||||
config_foreach get_coredns "coredns"
|
||||
|
||||
# CONF_FILE="/etc/coredns/Corefile"
|
||||
# CONF_FOLDER="/etc/coredns"
|
||||
# CONF_FILE="/usr/share/coredns/Corefile"
|
||||
# CONF_FOLDER="/usr/share/coredns"
|
||||
# CONF_FILE = "$configfile"
|
||||
CONF_FILE=$(uci -q get coredns.config.configfile)
|
||||
|
||||
echo $CONF_FILE >> /tmp/coredns.log
|
||||
|
||||
rm -rf $CONF_FILE
|
||||
# mkdir -p $CONF_FOLDER
|
||||
|
||||
touch $CONF_FILE
|
||||
|
||||
cat <<EOF >>$CONF_FILE
|
||||
(ads) {
|
||||
ads {
|
||||
default-lists
|
||||
blacklist https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt
|
||||
whitelist https://files.krnl.eu/whitelist.txt
|
||||
log
|
||||
auto-update-interval 24h
|
||||
list-store ads-cache
|
||||
}
|
||||
}
|
||||
|
||||
(dnsredir_default) {
|
||||
dnsredir . {
|
||||
path_reload $path_reload
|
||||
|
||||
max_fails $max_fails
|
||||
health_check $health_check
|
||||
policy $policy
|
||||
spray
|
||||
|
||||
to ${dns}
|
||||
`[[ "$bootstrap_dns" != "" ]] && echo "bootstrap $bootstrap_dns"`
|
||||
expire $expire
|
||||
no_ipv6
|
||||
}
|
||||
}
|
||||
|
||||
(global_cache) {
|
||||
# https://coredns.io/plugins/cache/
|
||||
cache {
|
||||
# [5, 60]
|
||||
success 65536 3600 300
|
||||
# [1, 10]
|
||||
denial 8192 600 60
|
||||
prefetch 1 60m 10%
|
||||
}
|
||||
}
|
||||
|
||||
.:${listen_port} {
|
||||
|
||||
hosts /usr/share/coredns/hosts {
|
||||
fallthrough
|
||||
}
|
||||
health
|
||||
#prometheus :9153
|
||||
errors
|
||||
log
|
||||
loop
|
||||
reload 60s
|
||||
|
||||
`[[ $disable_ipv6 -ne 0 ]] && echo "template IN AAAA ."`
|
||||
|
||||
`[ $enabled_cache -ne 0 ] && echo "import global_cache"`
|
||||
#import ads
|
||||
|
||||
`config_foreach get_coredns_redir "coredns_rule_file"`
|
||||
|
||||
`config_foreach get_coredns_redir "coredns_rule_url"`
|
||||
|
||||
import dnsredir_default
|
||||
}
|
||||
EOF
|
||||
|
||||
echo "配置文件已生成" >> /tmp/coredns.log
|
||||
@ -1,159 +0,0 @@
|
||||
server=/265.com/114.114.114.114
|
||||
server=/2mdn-cn.net/114.114.114.114
|
||||
server=/2mdn.net/114.114.114.114
|
||||
server=/accounts.googlers.com/114.114.114.114
|
||||
server=/accounts.xn--9trs65b.com/114.114.114.114
|
||||
server=/accounts.xn--ggle-55da.com/114.114.114.114
|
||||
server=/admob-cn.com/114.114.114.114
|
||||
server=/adservice.google.com/114.114.114.114
|
||||
server=/ai.ytimg.com/114.114.114.114
|
||||
server=/app-measurement-cn.com/114.114.114.114
|
||||
server=/app-measurement.com/114.114.114.114
|
||||
server=/apps5.oingo.com/114.114.114.114
|
||||
server=/avail.googleflights.net/114.114.114.114
|
||||
server=/beacons.gcp.gvt2.com/114.114.114.114
|
||||
server=/beacons.gvt2.com/114.114.114.114
|
||||
server=/beacons2.gvt2.com/114.114.114.114
|
||||
server=/beacons3.gvt2.com/114.114.114.114
|
||||
server=/borgmon.adz.google.com/114.114.114.114
|
||||
server=/c.admob.com/114.114.114.114
|
||||
server=/c.android.clients.google.com/114.114.114.114
|
||||
server=/cache-management-prod.google.com/114.114.114.114
|
||||
server=/cache.pack.google.com/114.114.114.114
|
||||
server=/checkin.gstatic.com/114.114.114.114
|
||||
server=/clickserve.cc-dt.com/114.114.114.114
|
||||
server=/clickserve.dartsearch.net/114.114.114.114
|
||||
server=/clickserver.googleads.com/114.114.114.114
|
||||
server=/clientservices.googleapis.com/114.114.114.114
|
||||
server=/cn.widevine.com/114.114.114.114
|
||||
server=/cnappinstall.googleadapis.com/114.114.114.114
|
||||
server=/connectivitycheck.gstatic.com/114.114.114.114
|
||||
server=/content.googleadapis.com/114.114.114.114
|
||||
server=/corp.google.com/114.114.114.114
|
||||
server=/corp.googleapis.com/114.114.114.114
|
||||
server=/crashlyticsreports-pa.googleapis.com/114.114.114.114
|
||||
server=/crl.pki.goog/114.114.114.114
|
||||
server=/csi.gstatic.com/114.114.114.114
|
||||
server=/dartsearch-cn.net/114.114.114.114
|
||||
server=/dg-meta.video.google.com/114.114.114.114
|
||||
server=/distribution.qatp1.net/114.114.114.114
|
||||
server=/distribution.qcpp1.net/114.114.114.114
|
||||
server=/distribution.qpdp1.net/114.114.114.114
|
||||
server=/dl.google.com/114.114.114.114
|
||||
server=/dl.l.google.com/114.114.114.114
|
||||
server=/doubleclick-cn.net/114.114.114.114
|
||||
server=/doubleclick.net/114.114.114.114
|
||||
server=/download.mlcc.google.com/114.114.114.114
|
||||
server=/download.qatp1.net/114.114.114.114
|
||||
server=/download.qcpp1.net/114.114.114.114
|
||||
server=/download.qpdp1.net/114.114.114.114
|
||||
server=/download.tensorflow.google.com/114.114.114.114
|
||||
server=/emmapplecodevice.googleapis.com/114.114.114.114
|
||||
server=/firebase-settings.crashlytics.com/114.114.114.114
|
||||
server=/fontfiles.googleadapis.com/114.114.114.114
|
||||
server=/fontfiles.googleapis.com/114.114.114.114
|
||||
server=/fonts.googleadapis.com/114.114.114.114
|
||||
server=/fonts.googleapis.com/114.114.114.114
|
||||
server=/fonts.gstatic.com/114.114.114.114
|
||||
server=/g0.gstatic.com/114.114.114.114
|
||||
server=/g1.gstatic.com/114.114.114.114
|
||||
server=/g2.gstatic.com/114.114.114.114
|
||||
server=/g3.gstatic.com/114.114.114.114
|
||||
server=/gcpnode.com/114.114.114.114
|
||||
server=/gonglchuangl.net/114.114.114.114
|
||||
server=/gongyichuangyi.net/114.114.114.114
|
||||
server=/google-analytics-cn.com/114.114.114.114
|
||||
server=/google-analytics.com/114.114.114.114
|
||||
server=/googleadservices-cn.com/114.114.114.114
|
||||
server=/googleadservices.com/114.114.114.114
|
||||
server=/googleanalytics.com/114.114.114.114
|
||||
server=/googleapis-cn.com/114.114.114.114
|
||||
server=/googleapps-cn.com/114.114.114.114
|
||||
server=/googleflights-cn.net/114.114.114.114
|
||||
server=/googleoptimize-cn.com/114.114.114.114
|
||||
server=/googleoptimize.com/114.114.114.114
|
||||
server=/googleplex.com/114.114.114.114
|
||||
server=/googlesyndication-cn.com/114.114.114.114
|
||||
server=/googlesyndication.com/114.114.114.114
|
||||
server=/googletagmanager-cn.com/114.114.114.114
|
||||
server=/googletagmanager.com/114.114.114.114
|
||||
server=/googletagservices-cn.com/114.114.114.114
|
||||
server=/googletagservices.com/114.114.114.114
|
||||
server=/googletraveladservices-cn.com/114.114.114.114
|
||||
server=/googletraveladservices.com/114.114.114.114
|
||||
server=/googlevads-cn.com/114.114.114.114
|
||||
server=/goto.google.com/114.114.114.114
|
||||
server=/gstatic-cn.com/114.114.114.114
|
||||
server=/gstaticadssl.l.google.com/114.114.114.114
|
||||
server=/gtm.oasisfeng.com/114.114.114.114
|
||||
server=/gvt1-cn.com/114.114.114.114
|
||||
server=/gvt2-cn.com/114.114.114.114
|
||||
server=/imasdk.googleapis.com/114.114.114.114
|
||||
server=/monitoring.qatp1.net/114.114.114.114
|
||||
server=/monitoring.qcpp1.net/114.114.114.114
|
||||
server=/monitoring.qpdp1.net/114.114.114.114
|
||||
server=/ocsp.pki.goog/114.114.114.114
|
||||
server=/pagead-googlehosted.l.google.com/114.114.114.114
|
||||
server=/performanceparameters.googleapis.com/114.114.114.114
|
||||
server=/pki-goog.l.google.com/114.114.114.114
|
||||
server=/play.1ucrs.com/114.114.114.114
|
||||
server=/prod-controlbe.floonet.goog/114.114.114.114
|
||||
server=/prod-databe.floonet.goog/114.114.114.114
|
||||
server=/prod.databe.floonet.goog/114.114.114.114
|
||||
server=/qagpublic.qatp1.net/114.114.114.114
|
||||
server=/qagpublic.qcpp1.net/114.114.114.114
|
||||
server=/qagpublic.qpdp1.net/114.114.114.114
|
||||
server=/qgadmin.qatp1.net/114.114.114.114
|
||||
server=/qgadmin.qcpp1.net/114.114.114.114
|
||||
server=/qgadmin.qpdp1.net/114.114.114.114
|
||||
server=/qpx.googleflights.net/114.114.114.114
|
||||
server=/qualysapi.qatp1.net/114.114.114.114
|
||||
server=/qualysapi.qcpp1.net/114.114.114.114
|
||||
server=/qualysapi.qpdp1.net/114.114.114.114
|
||||
server=/qualysguard.qatp1.net/114.114.114.114
|
||||
server=/qualysguard.qcpp1.net/114.114.114.114
|
||||
server=/qualysguard.qpdp1.net/114.114.114.114
|
||||
server=/recaptcha.net/114.114.114.114
|
||||
server=/redirector.bdn.dev/114.114.114.114
|
||||
server=/redirector.c.chat.google.com/114.114.114.114
|
||||
server=/redirector.c.mail.google.com/114.114.114.114
|
||||
server=/redirector.c.pack.google.com/114.114.114.114
|
||||
server=/redirector.c.play.google.com/114.114.114.114
|
||||
server=/redirector.c.youtubeeducation.com/114.114.114.114
|
||||
server=/redirector.gcpcdn.gvt1.com/114.114.114.114
|
||||
server=/redirector.gvt1.com/114.114.114.114
|
||||
server=/redirector.offline-maps.gvt1.com/114.114.114.114
|
||||
server=/redirector.snap.gvt1.com/114.114.114.114
|
||||
server=/redirector.xn--ngstr-lra8j.com/114.114.114.114
|
||||
server=/regioninfo-pa.googleapis.com/114.114.114.114
|
||||
server=/safebrowsing.googleapis.com/114.114.114.114
|
||||
server=/scanservice1.qatp1.net/114.114.114.114
|
||||
server=/scanservice1.qcpp1.net/114.114.114.114
|
||||
server=/scanservice1.qpdp1.net/114.114.114.114
|
||||
server=/service.urchin.com/114.114.114.114
|
||||
server=/settings.xn--9trs65b.com/114.114.114.114
|
||||
server=/ssl-google-analytics.l.google.com/114.114.114.114
|
||||
server=/ssl.gstatic.com/114.114.114.114
|
||||
server=/staging-controlbe.floonet.goog/114.114.114.114
|
||||
server=/staging-databe.floonet.goog/114.114.114.114
|
||||
server=/staging-regioninfo-pa.googleapis.com/114.114.114.114
|
||||
server=/staging.databe.floonet.goog/114.114.114.114
|
||||
server=/support.1ucrs.com/114.114.114.114
|
||||
server=/tac.googleapis.com/114.114.114.114
|
||||
server=/test.bugs-qa.chromium.org/114.114.114.114
|
||||
server=/test.gbugs-qa.chromium.org/114.114.114.114
|
||||
server=/tools.google.com/114.114.114.114
|
||||
server=/tools.l.google.com/114.114.114.114
|
||||
server=/up.corp.goog/114.114.114.114
|
||||
server=/up.gcp.googlers.com/114.114.114.114
|
||||
server=/update.crashlytics.com/114.114.114.114
|
||||
server=/update.googleapis.com/114.114.114.114
|
||||
server=/wear.googleapis.com/114.114.114.114
|
||||
server=/www-google-analytics.l.google.com/114.114.114.114
|
||||
server=/www-googletagmanager.l.google.com/114.114.114.114
|
||||
server=/www.destinationurl.com/114.114.114.114
|
||||
server=/www.googleadapis.com/114.114.114.114
|
||||
server=/www.gstatic.com/114.114.114.114
|
||||
server=/www.pxcc.com/114.114.114.114
|
||||
server=/xn--9kr7l.com/114.114.114.114
|
||||
server=/xn--flw351e.com/114.114.114.114
|
||||
@ -1,9 +0,0 @@
|
||||
127.0.0.1 localhost
|
||||
203.107.6.88 time.android.com
|
||||
108.156.91.110 api.themoviedb.org
|
||||
138.199.37.230 image.tmdb.org
|
||||
108.159.227.77 api.tmdb.org
|
||||
52.84.125.124 themoviedb.org
|
||||
52.84.125.124 www.themoviedb.org
|
||||
104.25.35.71 kodi.tv
|
||||
23.19.87.248 mirrors.kodi.tv
|
||||
@ -1,77 +0,0 @@
|
||||
1drv.com
|
||||
microsoft.com
|
||||
aadrm.com
|
||||
acompli.com
|
||||
acompli.net
|
||||
aka.ms
|
||||
akadns.net
|
||||
aspnetcdn.com
|
||||
assets-yammer.com
|
||||
azure.com
|
||||
azure.net
|
||||
azureedge.net
|
||||
azureiotcentral.com
|
||||
azurerms.com
|
||||
bing.com
|
||||
cloudapp.net
|
||||
cloudappsecurity.com
|
||||
edgesuite.net
|
||||
gfx.ms
|
||||
hotmail.com
|
||||
live.com
|
||||
live.net
|
||||
lync.com
|
||||
msappproxy.net
|
||||
msauth.net
|
||||
msauthimages.net
|
||||
msecnd.net
|
||||
msedge.net
|
||||
msft.net
|
||||
msftauth.net
|
||||
msftauthimages.net
|
||||
msftidentity.com
|
||||
msidentity.com
|
||||
msn.cn
|
||||
msn.com
|
||||
msocdn.com
|
||||
msocsp.com
|
||||
mstea.ms
|
||||
o365weve.com
|
||||
oaspapps.com
|
||||
office.com
|
||||
office.net
|
||||
office365.com
|
||||
officeppe.net
|
||||
omniroot.com
|
||||
onedrive.com
|
||||
onenote.com
|
||||
onenote.net
|
||||
onestore.ms
|
||||
outlook.com
|
||||
outlookmobile.com
|
||||
phonefactor.net
|
||||
public-trust.com
|
||||
sfbassets.com
|
||||
sfx.ms
|
||||
sharepoint.com
|
||||
sharepointonline.com
|
||||
skype.com
|
||||
skypeassets.com
|
||||
skypeforbusiness.com
|
||||
staffhub.ms
|
||||
svc.ms
|
||||
sway-cdn.com
|
||||
sway-extensions.com
|
||||
sway.com
|
||||
trafficmanager.net
|
||||
uservoice.com
|
||||
virtualearth.net
|
||||
visualstudio.com
|
||||
windows-ppe.net
|
||||
windows.com
|
||||
windows.net
|
||||
windowsazure.com
|
||||
windowsupdate.com
|
||||
wunderlist.com
|
||||
yammer.com
|
||||
yammerusercontent.com
|
||||
@ -1,22 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
CONF_FILE=$(uci -q get coredns.config.configfile)
|
||||
LOG_FILE=$(uci -q get coredns.global.logfile)
|
||||
ENABLED_LOG=$(uci -q get coredns.config.enabled_log)
|
||||
ENABLED=$(uci -q get coredns.config.enabled)
|
||||
|
||||
chmod +x /usr/share/coredns/coredns
|
||||
|
||||
# if [$ENABLED -eq 0]
|
||||
# then
|
||||
# killall coredns
|
||||
# return 1
|
||||
# fi
|
||||
echo "开始启动 coredns 程序..." >> /tmp/coredns.log
|
||||
|
||||
if [ $ENABLED_LOG -ne 0 ]
|
||||
then
|
||||
/usr/share/coredns/coredns -conf="$CONF_FILE" >> $LOG_FILE
|
||||
else
|
||||
/usr/share/coredns/coredns -conf="$CONF_FILE" >/dev/null 2>&1
|
||||
fi
|
||||
@ -1,99 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
require 'nixio'
|
||||
require 'luci.model.uci'
|
||||
require 'luci.util'
|
||||
require 'luci.jsonc'
|
||||
require 'luci.sys'
|
||||
local api = require "luci.coredns.api"
|
||||
local datatypes = require "luci.cbi.datatypes"
|
||||
local appname = 'coredns'
|
||||
local rule_file_path = '/usr/share/coredns/'
|
||||
local debug = false
|
||||
local uci = luci.model.uci.cursor()
|
||||
uci:revert(appname)
|
||||
|
||||
rule_file_path = uci:get("coredns","global","conf_folder")
|
||||
-- print(rule_file_path)
|
||||
|
||||
local log = function(...)
|
||||
if debug == true then
|
||||
local result = os.date("%Y-%m-%d %H:%M:%S: ") .. table.concat({...}, " ")
|
||||
print(result)
|
||||
-- luci.util.perror(result)
|
||||
else
|
||||
api.log(...)
|
||||
end
|
||||
end
|
||||
|
||||
local function curl(url, file, ua)
|
||||
if not ua or ua == "" then
|
||||
ua = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
|
||||
end
|
||||
local args = {
|
||||
"-skL", "--retry 3", "--connect-timeout 3", '--user-agent "' .. ua .. '"'
|
||||
}
|
||||
local return_code, result = api.curl_logic(url, file, args)
|
||||
return return_code
|
||||
end
|
||||
|
||||
local execute = function()
|
||||
do
|
||||
local rule_list = {}
|
||||
local fail_list = {}
|
||||
if arg[1] then
|
||||
string.gsub(arg[1], '[^' .. "," .. ']+', function(w)
|
||||
rule_list[#rule_list + 1] = uci:get_all(appname, w) or {}
|
||||
end)
|
||||
else
|
||||
uci:foreach(appname, "coredns_rule_url", function(o)
|
||||
-- print(o)
|
||||
rule_list[#rule_list + 1] = o
|
||||
end)
|
||||
end
|
||||
|
||||
for index, value in ipairs(rule_list) do
|
||||
local cfgid = value[".name"]
|
||||
local name = value.name
|
||||
local url = value.url
|
||||
local file = rule_file_path .. value.file
|
||||
-- local ua = value.user_agent
|
||||
local ua = ""
|
||||
|
||||
log('正在订阅:【' .. name .. '】' .. url)
|
||||
tmpfile = "/tmp/" .. cfgid
|
||||
-- os.remove(tmpfile)
|
||||
luci.sys.exec("rm -rf " .. tmpfile)
|
||||
local raw = curl(url, tmpfile, ua)
|
||||
-- log(raw);
|
||||
log("temp file: " .. tmpfile)
|
||||
log("target file: " .. file)
|
||||
if raw == 0 then
|
||||
-- os.remove(file)
|
||||
-- os.move(tmpfile, file)
|
||||
luci.sys.exec("mv " .. tmpfile .. " " .. file)
|
||||
else
|
||||
fail_list[#fail_list + 1] = value
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if #fail_list > 0 then
|
||||
for index, value in ipairs(fail_list) do
|
||||
log(string.format('【%s】订阅失败,可能是订阅地址失效,或是网络问题,请诊断!', value.name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
log("开始更新规则...")
|
||||
|
||||
xpcall(execute, function(e)
|
||||
log(e)
|
||||
log(debug.traceback())
|
||||
log('发生错误, 正在恢复服务')
|
||||
end)
|
||||
|
||||
log("规则更新完毕...")
|
||||
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
{
|
||||
"luci-app-coredns": {
|
||||
"description": "Grant UCI access for luci-app-coredns",
|
||||
"read": {
|
||||
"uci": [ "coredns" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "coredns" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ LUCI_TITLE:=dynv6 ddns script
|
||||
LUCI_DEPENDS:= +luci-compat
|
||||
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
PKG_MAINTAINER:=luochongjun <luochongjun@gl-inet.com>
|
||||
|
||||
define Package/luci-app-dynv6/postinst
|
||||
|
||||
17
luci-app-dynv6/root/etc/uci-defaults/luci-dynv6
Normal file
17
luci-app-dynv6/root/etc/uci-defaults/luci-dynv6
Normal file
@ -0,0 +1,17 @@
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-get.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-get.json << EEOF
|
||||
{
|
||||
"config": "get",
|
||||
"init": "get"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
#!/bin/sh
|
||||
|
||||
uci -q get ucitrack.@dynv6[0] || uci add ucitrack dynv6
|
||||
uci set ucitrack.@dynv6[0]=dynv6
|
||||
uci set ucitrack.@dynv6[0].exec="/bin/sh /etc/rc.common /etc/init.d/dynv6 restart"
|
||||
uci commit ucitrack
|
||||
/etc/init.d/ucitrack restart
|
||||
|
||||
exit 0
|
||||
@ -15,14 +15,6 @@ LUCI_MAINTAINER:=K
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+my-dnshelper
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
chmod a+x ${IPKG_INSTROOT}/etc/init.d/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
chmod a+x ${IPKG_INSTROOT}/usr/share/my-dnshelper/* >/dev/null 2>&1 || echo ""
|
||||
chmod a+x ${IPKG_INSTROOT}/usr/bin/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
exit 0
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
@ -862,7 +862,7 @@ for k, v in pairs(nodes_table) do
|
||||
socks:value(v.id, v["remark"])
|
||||
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
else
|
||||
elseif v.protocol ~= "_shunt" then
|
||||
socks:value(v.id, v["remark"])
|
||||
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
|
||||
@ -102,10 +102,12 @@ o.widget = "checkbox"
|
||||
o.template = appname .. "/cbi/nodes_multivalue"
|
||||
o.group = {}
|
||||
for i, v in pairs(nodes_table) do
|
||||
o:value(v.id, v.remark)
|
||||
o.group[#o.group+1] = v.group or ""
|
||||
socks_node:value(v.id, v["remark"])
|
||||
socks_node.group[#socks_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
if v.protocol ~= "_shunt" then
|
||||
o:value(v.id, v.remark)
|
||||
o.group[#o.group+1] = v.group or ""
|
||||
socks_node:value(v.id, v["remark"])
|
||||
socks_node.group[#socks_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
|
||||
end
|
||||
end
|
||||
-- 读取旧 DynamicList
|
||||
function o.cfgvalue(self, section)
|
||||
|
||||
@ -1521,14 +1521,28 @@ function gen_config(var)
|
||||
useSystemHosts = true
|
||||
}
|
||||
|
||||
local _direct_dns = {
|
||||
tag = "dns-global-direct",
|
||||
queryStrategy = (direct_dns_query_strategy and direct_dns_query_strategy ~= "") and direct_dns_query_strategy or "UseIP"
|
||||
}
|
||||
local _direct_dns = {}
|
||||
|
||||
direct_dns_udp_server = (direct_dns_udp_server and direct_dns_udp_server ~= "") and direct_dns_udp_server or nil
|
||||
|
||||
if direct_dns_udp_server or direct_dns_tcp_server then
|
||||
_direct_dns.tag = "dns-global-direct"
|
||||
_direct_dns.queryStrategy = (direct_dns_query_strategy and direct_dns_query_strategy ~= "") and direct_dns_query_strategy or "UseIP"
|
||||
|
||||
if direct_dns_udp_server then
|
||||
local port = tonumber(direct_dns_port) or 53
|
||||
_direct_dns.port = port
|
||||
_direct_dns.address = direct_dns_udp_server
|
||||
elseif direct_dns_tcp_server then
|
||||
local port = tonumber(direct_dns_port) or 53
|
||||
_direct_dns.address = "tcp://" .. direct_dns_tcp_server .. ":" .. port
|
||||
end
|
||||
|
||||
if COMMON.default_outbound_tag == "direct" then
|
||||
table.insert(dns.servers, _direct_dns)
|
||||
end
|
||||
end
|
||||
if dns_listen_port and next(_direct_dns) then
|
||||
local domain = {}
|
||||
local nodes_domain_text = sys.exec([[uci show passwall | sed -n "s/.*\.\(address\|download_address\)='\([^']*\)'/\2/p" | sort -u]])
|
||||
string.gsub(nodes_domain_text, '[^' .. "\r\n" .. ']+', function(w)
|
||||
@ -1543,19 +1557,6 @@ function gen_config(var)
|
||||
domain = domain
|
||||
})
|
||||
end
|
||||
|
||||
if direct_dns_udp_server then
|
||||
local port = tonumber(direct_dns_port) or 53
|
||||
_direct_dns.port = port
|
||||
_direct_dns.address = direct_dns_udp_server
|
||||
elseif direct_dns_tcp_server then
|
||||
local port = tonumber(direct_dns_port) or 53
|
||||
_direct_dns.address = "tcp://" .. direct_dns_tcp_server .. ":" .. port
|
||||
end
|
||||
|
||||
if COMMON.default_outbound_tag == "direct" then
|
||||
table.insert(dns.servers, _direct_dns)
|
||||
end
|
||||
end
|
||||
|
||||
local _remote_dns = {}
|
||||
@ -1795,10 +1796,13 @@ function gen_config(var)
|
||||
for line, _ in pairs(GLOBAL.DNS_HOSTNAME) do
|
||||
table.insert(hostname, line)
|
||||
end
|
||||
table.insert(dns.servers, 2, {
|
||||
tag = "dns-in-bootstrap",
|
||||
address = "localhost",
|
||||
domains = hostname
|
||||
local new_dns_server = next(_direct_dns) and api.clone(_direct_dns) or { address = "localhost" }
|
||||
new_dns_server.tag = "dns-in-bootstrap"
|
||||
new_dns_server.domains = hostname
|
||||
table.insert(dns.servers, 2, new_dns_server)
|
||||
table.insert(routing.rules, idx, {
|
||||
inboundTag = { "dns-in-bootstrap" },
|
||||
outboundTag = "direct"
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
[[ "$ACTION" == "ifup" && $(uci get "passwall.@global[0].enabled") == "1" ]] && [ -f /var/lock/passwall_ready.lock ] && {
|
||||
default_device=$(ip route | grep default | awk -F 'dev ' '{print $2}' | awk '{print $1}')
|
||||
[ "$default_device" == "$DEVICE" ] && {
|
||||
[ "$ACTION" = "ifup" ] || [ "$ACTION" = "ifupdate" ] || exit 0
|
||||
|
||||
[ "$(uci get passwall.@global[0].enabled 2>/dev/null)" = "1" ] && [ -f /var/lock/passwall_ready.lock ] && {
|
||||
|
||||
default_device=$(ip route show default 2>/dev/null | awk -F 'dev ' '{print $2}' | awk '{print $1}' | head -n1)
|
||||
default6_device=$(ip -6 route show default 2>/dev/null | awk -F 'dev ' '{print $2}' | awk '{print $1}' | head -n1)
|
||||
( [ "$default_device" = "$DEVICE" ] || [ "$default6_device" = "$DEVICE" ] ) && {
|
||||
|
||||
if [ "$ACTION" = "ifupdate" ]; then
|
||||
FWI=$(uci -q get firewall.passwall.path 2>/dev/null)
|
||||
[ -n "$FWI" ] && [ -f "$FWI" ] && sh "$FWI" >/dev/null 2>&1 &
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LOCK_FILE_DIR=/var/lock
|
||||
[ ! -d ${LOCK_FILE_DIR} ] && mkdir -p ${LOCK_FILE_DIR}
|
||||
LOCK_FILE="${LOCK_FILE_DIR}/passwall_ifup.lock"
|
||||
|
||||
@ -2060,16 +2060,7 @@ get_config() {
|
||||
REMOTE_DNS_QUERY_STRATEGY="UseIP"
|
||||
[ "$FILTER_PROXY_IPV6" = "1" ] && REMOTE_DNS_QUERY_STRATEGY="UseIPv4"
|
||||
DNSMASQ_FILTER_PROXY_IPV6=${FILTER_PROXY_IPV6}
|
||||
|
||||
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
|
||||
[ -f "${RESOLVFILE}" ] && [ -s "${RESOLVFILE}" ] || RESOLVFILE=/tmp/resolv.conf.auto
|
||||
|
||||
ISP_DNS=$(cat $RESOLVFILE 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep -v -E '^(0\.0\.0\.0|127\.0\.0\.1)$' | awk '!seen[$0]++')
|
||||
ISP_DNS6=$(cat $RESOLVFILE 2>/dev/null | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | awk -F % '{print $1}' | awk -F " " '{print $2}' | grep -v -Fx ::1 | grep -v -Fx :: | awk '!seen[$0]++')
|
||||
|
||||
DEFAULT_DNS=$(uci show dhcp.@dnsmasq[0] | grep "\.server=" | awk -F '=' '{print $2}' | sed "s/'//g" | tr ' ' '\n' | grep -v "\/" | sed ':label;N;s/\n/,/;b label')
|
||||
[ -z "${DEFAULT_DNS}" ] && [ "$(echo $ISP_DNS | tr ' ' '\n' | wc -l)" -ge 1 ] && DEFAULT_DNS=$(echo -n $ISP_DNS | tr ' ' '\n' | tr '\n' ',' | sed 's/,$//')
|
||||
LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29,223.5.5.5}"
|
||||
IPT_APPEND_DNS=${LOCAL_DNS}
|
||||
|
||||
DNSMASQ_CONF_DIR=/tmp/dnsmasq.d
|
||||
@ -2097,6 +2088,20 @@ get_config() {
|
||||
}
|
||||
}
|
||||
|
||||
get_local_dns() {
|
||||
RESOLVFILE=/tmp/resolv.conf.d/resolv.conf.auto
|
||||
[ -f "${RESOLVFILE}" ] && [ -s "${RESOLVFILE}" ] || RESOLVFILE=/tmp/resolv.conf.auto
|
||||
|
||||
ISP_DNS=$(cat $RESOLVFILE 2>/dev/null | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep -v -E '^(0\.0\.0\.0|127\.0\.0\.1)$' | awk '!seen[$0]++')
|
||||
ISP_DNS6=$(cat $RESOLVFILE 2>/dev/null | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | awk -F % '{print $1}' | awk -F " " '{print $2}' | grep -v -Fx ::1 | grep -v -Fx :: | awk '!seen[$0]++')
|
||||
|
||||
DEFAULT_DNS=$(uci show dhcp.@dnsmasq[0] | grep "\.server=" | awk -F '=' '{print $2}' | sed "s/'//g" | tr ' ' '\n' | grep -v "\/" | sed ':label;N;s/\n/,/;b label')
|
||||
[ -z "${DEFAULT_DNS}" ] && [ "$(echo $ISP_DNS | tr ' ' '\n' | wc -l)" -ge 1 ] && DEFAULT_DNS=$(echo -n $ISP_DNS | tr ' ' '\n' | tr '\n' ',' | sed 's/,$//')
|
||||
LOCAL_DNS="${DEFAULT_DNS:-119.29.29.29,223.5.5.5}"
|
||||
}
|
||||
|
||||
get_local_dns
|
||||
|
||||
arg1=$1
|
||||
shift
|
||||
case $arg1 in
|
||||
|
||||
@ -50,8 +50,8 @@ test_node() {
|
||||
[ -n "${_type}" ] && {
|
||||
local _tmp_port=$(get_new_port 48800 tcp,udp)
|
||||
NO_REC_PROCESS=1 $APP_FILE run_socks flag="test_node_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=test_node_${node_id}.json
|
||||
sleep 2s
|
||||
local curlx="socks5h://127.0.0.1:${_tmp_port}"
|
||||
sleep 1s
|
||||
local _proxy_status=$(test_url "${probe_url}" ${retry_num} ${connect_timeout} "-x $curlx")
|
||||
# 结束 SS 插件进程
|
||||
local pid_file="/tmp/etc/${CONFIG}/test_node_${node_id}_plugin.pid"
|
||||
|
||||
@ -60,7 +60,7 @@ url_test_node() {
|
||||
NO_REC_PROCESS=1 /usr/share/${CONFIG}/app.sh run_socks flag="url_test_${node_id}" node=${node_id} bind=127.0.0.1 socks_port=${_tmp_port} config_file=url_test_${node_id}.json
|
||||
local curlx="socks5h://127.0.0.1:${_tmp_port}"
|
||||
fi
|
||||
sleep 1s
|
||||
sleep 2s
|
||||
local probeUrl=$(config_t_get global_other url_test_url https://www.google.com/generate_204)
|
||||
result=$(curl --connect-timeout 3 --max-time 5 -o /dev/null -I -skL -w "%{http_code}:%{time_pretransfer}" -x ${curlx} "${probeUrl}")
|
||||
# 结束 SS 插件进程
|
||||
|
||||
@ -357,6 +357,7 @@ set_cache_var() {
|
||||
shift 1
|
||||
local val="$@"
|
||||
[ -n "${key}" ] && [ -n "${val}" ] && {
|
||||
[ ! -d $TMP_PATH ] && mkdir -p $TMP_PATH
|
||||
sed -i "/${key}=/d" $TMP_PATH/var >/dev/null 2>&1
|
||||
echo "${key}=\"${val}\"" >> $TMP_PATH/var
|
||||
eval ${key}=\"${val}\"
|
||||
|
||||
@ -15,7 +15,7 @@ include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
define Package/luci-app-synology/postinst
|
||||
#!/bin.sh
|
||||
chmod 755 /etc/init.d/synology
|
||||
chmod +x $${IPKG_INSTROOT}/etc/init.d/synology >/dev/null 2>&1
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-timedreboot
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3
|
||||
PKG_RELEASE:=4
|
||||
PKG_DATE:=20220920
|
||||
|
||||
PKG_MAINTAINER:=kongfl888 <kongfl888@outlook.com>
|
||||
@ -47,8 +47,8 @@ endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
chmod a+x ${IPKG_INSTROOT}/etc/init.d/timedreboot >/dev/null 2>&1
|
||||
chmod a+x ${IPKG_INSTROOT}/usr/bin/dorboot >/dev/null 2>&1
|
||||
chmod a+x $${IPKG_INSTROOT}/etc/init.d/timedreboot >/dev/null 2>&1
|
||||
chmod a+x $${IPKG_INSTROOT}/usr/bin/dorboot >/dev/null 2>&1
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
@ -1,6 +1,13 @@
|
||||
# OpenWrt LuCI web UI address
|
||||
VITE_OPENWRT_HOST=http://192.168.1.1
|
||||
|
||||
# SSH config for syncing .ut template files to the device on change
|
||||
# Leave SSH_HOST empty to disable ut sync.
|
||||
VITE_OPENWRT_SSH_HOST=root@192.168.1.1
|
||||
#
|
||||
# Path to SSH private key (optional, falls back to ssh-agent or ~/.ssh/config)
|
||||
# VITE_OPENWRT_SSH_KEY=~/.ssh/id_rsa
|
||||
|
||||
# Development server configuration
|
||||
VITE_DEV_PORT=5173
|
||||
|
||||
|
||||
@ -38,7 +38,9 @@ cp .env.example .env
|
||||
**Environment Variables:**
|
||||
|
||||
- `VITE_OPENWRT_HOST` - Your OpenWrt LuCI web interface URL (required)
|
||||
- `VITE_DEV_HOST` - Development server host (default: `127.0.0.1`)
|
||||
- `VITE_OPENWRT_SSH_HOST` - SSH target for `.ut` template sync, e.g. `root@192.168.1.1` (optional)
|
||||
- `VITE_OPENWRT_SSH_KEY` - Path to SSH private key (optional, falls back to ssh-agent or `~/.ssh/config`)
|
||||
- `VITE_DEV_HOST` - Development server host (code default: `127.0.0.1`, `.env.example` sets `0.0.0.0` for LAN access)
|
||||
- `VITE_DEV_PORT` - Development server port (default: `5173`)
|
||||
|
||||
## Development Workflow
|
||||
@ -91,7 +93,46 @@ For LuCI-specific JavaScript development, refer to the official API documentatio
|
||||
|
||||
- **CSS changes**: Trigger full page reload via custom HMR handler
|
||||
- **JS changes**: Trigger full page reload via custom HMR handler
|
||||
- **Template changes** (`.ut` files): **Require building a new package and installing it on the router**
|
||||
- **Template changes** (`.ut` files): Auto-synced to router via SCP and trigger full page reload (requires SSH setup, see below)
|
||||
|
||||
### Template (`.ut`) Live Sync
|
||||
|
||||
The `.ut` template files are rendered server-side on the OpenWrt device. To see template changes during development, the dev server can automatically sync modified `.ut` files to the router via SCP.
|
||||
|
||||
**1. Set up SSH key authentication to your router:**
|
||||
|
||||
```bash
|
||||
# Generate a key if you don't have one
|
||||
ssh-keygen -t ed25519
|
||||
|
||||
# Copy your public key to the router (OpenWrt uses Dropbear, not OpenSSH)
|
||||
cat ~/.ssh/id_ed25519.pub | ssh root@192.168.1.1 "cat >> /etc/dropbear/authorized_keys"
|
||||
|
||||
# Verify passwordless login works
|
||||
ssh root@192.168.1.1 "echo ok"
|
||||
```
|
||||
|
||||
**2. Add SSH config to `.env`:**
|
||||
|
||||
```bash
|
||||
# SSH target for .ut file sync (user@host)
|
||||
VITE_OPENWRT_SSH_HOST=root@192.168.1.1
|
||||
|
||||
# Optional: path to SSH private key (falls back to ssh-agent or ~/.ssh/config)
|
||||
# VITE_OPENWRT_SSH_KEY=~/.ssh/id_ed25519
|
||||
```
|
||||
|
||||
**3. Start `pnpm dev` and edit any `.ut` file** — the dev server will automatically sync it to the router and reload the browser.
|
||||
|
||||
**Troubleshooting:**
|
||||
|
||||
The dev server checks SSH connectivity on startup and prints actionable errors:
|
||||
|
||||
- **Host key mismatch** (device was reflashed): Run `ssh-keygen -R <device-ip>`, then restart the dev server
|
||||
- **Authentication failed** (public key not on device): Copy your key with the command above
|
||||
- **Connection refused/timed out**: Check that the device is online and SSH is enabled
|
||||
|
||||
If `VITE_OPENWRT_SSH_HOST` is not set, template sync is simply disabled and other dev features work normally.
|
||||
|
||||
## Building for Production
|
||||
|
||||
@ -111,11 +152,9 @@ htdocs/luci-static/
|
||||
├── aurora/
|
||||
│ ├── main.css # Minified CSS (via lightningcss)
|
||||
│ ├── fonts/ # Web fonts (Lato)
|
||||
│ └── images/ # Logo assets
|
||||
│ └── images/ # Logo assets + PWA icons
|
||||
└── resources/
|
||||
├── menu-aurora.js # Menu configuration (minified via Terser)
|
||||
└── view/aurora/
|
||||
└── sysauth.js # Login page view (minified via Terser)
|
||||
└── menu-aurora.js # Menu configuration (minified via Terser)
|
||||
```
|
||||
|
||||
**Build Process:**
|
||||
@ -129,11 +168,24 @@ htdocs/luci-static/
|
||||
|
||||
### Via GitHub Actions
|
||||
|
||||
1. Commit your changes to the repository
|
||||
2. Manually trigger the GitHub Actions workflow
|
||||
3. The workflow will compile the theme package (.ipk/.apk files)
|
||||
**Build frontend assets:**
|
||||
|
||||
**Workflow File:** `.github/workflows/build-and-release-aurora.yml`
|
||||
1. Manually trigger the `frontend-assets-build` workflow
|
||||
2. It runs `pnpm build`, then auto-commits the output to `htdocs/` if anything changed
|
||||
|
||||
**Build `.ipk`/`.apk` packages:**
|
||||
|
||||
1. Push a version tag (`v*`) or push to `master` with `[build]` in the commit message
|
||||
2. The `build-theme-package` workflow compiles the OpenWrt package
|
||||
|
||||
**PR checks:**
|
||||
|
||||
Pull requests that touch `.dev/`, `htdocs/`, `ucode/`, or `root/` are automatically linted and build-verified by the `pr-check` workflow.
|
||||
|
||||
**Workflow Files:** `.github/workflows/`
|
||||
- `frontend-assets-build.yml` — Build assets and auto-commit
|
||||
- `build-theme-package.yml` — Compile `.ipk`/`.apk` packages
|
||||
- `pr-check.yml` — Lint and build verification for PRs
|
||||
|
||||
## Directory Structure
|
||||
|
||||
@ -145,7 +197,7 @@ luci-theme-aurora/
|
||||
│ │ └── DEVELOPMENT.md # Development guide (this file)
|
||||
│ ├── public/aurora/ # Public static assets
|
||||
│ │ ├── fonts/ # Web fonts (Lato)
|
||||
│ │ └── images/ # Theme images
|
||||
│ │ └── images/ # Theme images + PWA icons
|
||||
│ ├── scripts/ # Build scripts
|
||||
│ │ └── clean.js # Build cleanup utility
|
||||
│ ├── src/ # Source code
|
||||
@ -153,7 +205,6 @@ luci-theme-aurora/
|
||||
│ │ ├── media/ # CSS entry points
|
||||
│ │ │ └── main.css # Main stylesheet (Tailwind CSS)
|
||||
│ │ └── resource/ # JavaScript resources
|
||||
│ │ ├── view/ # LuCI view components
|
||||
│ │ └── menu-aurora.js # Menu logic
|
||||
│ ├── .env.example # Environment variables template
|
||||
│ ├── .prettierrc # Prettier configuration
|
||||
@ -162,16 +213,16 @@ luci-theme-aurora/
|
||||
│ └── vite.config.ts # Vite configuration with custom plugins
|
||||
├── .github/ # GitHub configuration
|
||||
│ ├── ISSUE_TEMPLATE/ # Issue templates
|
||||
│ └── workflows/ # GitHub Actions workflows
|
||||
│ ├── workflows/ # GitHub Actions workflows
|
||||
│ └── renovate.json # Renovate dependency update config
|
||||
├── .vscode/ # VS Code workspace settings
|
||||
│ └── settings.json # Auto-format on save settings
|
||||
├── htdocs/luci-static/ # Build output (generated by Vite)
|
||||
│ ├── aurora/ # Theme CSS and assets
|
||||
│ │ ├── fonts/ # Built font files
|
||||
│ │ ├── images/ # Built images
|
||||
│ │ ├── images/ # Built images + PWA icons
|
||||
│ │ └── main.css # Compiled CSS
|
||||
│ └── resources/ # Built JavaScript modules
|
||||
│ ├── view/ # Minified view components
|
||||
│ └── menu-aurora.js # Minified menu logic
|
||||
├── root/etc/uci-defaults/ # OpenWrt system integration
|
||||
│ └── 30_luci-theme-aurora # Theme auto-setup script
|
||||
|
||||
@ -4,11 +4,16 @@
|
||||
*/
|
||||
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { exec } from "child_process";
|
||||
import { watch as fsWatch } from "fs";
|
||||
import { mkdir, readdir, readFile, writeFile } from "fs/promises";
|
||||
import { dirname, join, relative, resolve } from "path";
|
||||
import { basename, dirname, join, relative, resolve } from "path";
|
||||
import { minify as terserMinify } from "terser";
|
||||
import { promisify } from "util";
|
||||
import { defineConfig, loadEnv, Plugin, ResolvedConfig } from "vite";
|
||||
|
||||
const execAsync = promisify(exec);
|
||||
|
||||
const CURRENT_DIR = process.cwd();
|
||||
const PROJECT_ROOT = resolve(CURRENT_DIR, "..");
|
||||
const BUILD_OUTPUT = resolve(PROJECT_ROOT, "htdocs/luci-static");
|
||||
@ -179,6 +184,109 @@ function createLocalServePlugin(): Plugin {
|
||||
};
|
||||
}
|
||||
|
||||
const UT_TEMPLATE_DIR = resolve(PROJECT_ROOT, "ucode/template/themes/aurora");
|
||||
const UT_REMOTE_DIR = "/usr/share/ucode/luci/template/themes/aurora";
|
||||
|
||||
interface ScpConfig {
|
||||
host: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
function buildSshArgs(cfg: ScpConfig): string {
|
||||
const args = ["-o StrictHostKeyChecking=no", "-o UserKnownHostsFile=/dev/null"];
|
||||
if (cfg.key) args.push(`-i "${cfg.key}"`);
|
||||
return args.join(" ");
|
||||
}
|
||||
|
||||
function buildScpCommand(localPath: string, remotePath: string, cfg: ScpConfig): string {
|
||||
return `scp ${buildSshArgs(cfg)} "${localPath}" "${cfg.host}:${remotePath}"`;
|
||||
}
|
||||
|
||||
function parseHost(sshHost: string): string {
|
||||
const atIndex = sshHost.lastIndexOf("@");
|
||||
return atIndex !== -1 ? sshHost.slice(atIndex + 1) : sshHost;
|
||||
}
|
||||
|
||||
async function checkSshConnection(cfg: ScpConfig): Promise<boolean> {
|
||||
const host = parseHost(cfg.host);
|
||||
|
||||
try {
|
||||
await execAsync(`ssh ${buildSshArgs(cfg)} -o ConnectTimeout=5 "${cfg.host}" echo ok`);
|
||||
console.log(`[UT Sync] SSH connection verified.`);
|
||||
return true;
|
||||
} catch (err: any) {
|
||||
const stderr = err?.stderr || err?.message || "";
|
||||
|
||||
if (stderr.includes("Host key verification failed") || stderr.includes("REMOTE HOST IDENTIFICATION HAS CHANGED")) {
|
||||
console.error(`\n[UT Sync] SSH host key mismatch for ${host}.`);
|
||||
console.error(`[UT Sync] The device may have been reflashed. Run this to fix:\n`);
|
||||
console.error(` ssh-keygen -R ${host}\n`);
|
||||
console.error(`[UT Sync] Then restart the dev server.\n`);
|
||||
} else if (stderr.includes("Permission denied") || stderr.includes("Authentication failed")) {
|
||||
console.error(`\n[UT Sync] SSH authentication failed for ${cfg.host}.`);
|
||||
console.error(`[UT Sync] Copy your public key to the device:\n`);
|
||||
console.error(` cat ~/.ssh/id_ed25519.pub | ssh ${cfg.host} "cat >> /etc/dropbear/authorized_keys"\n`);
|
||||
} else if (stderr.includes("Connection refused") || stderr.includes("Connection timed out") || stderr.includes("No route to host")) {
|
||||
console.error(`\n[UT Sync] Cannot reach ${host}. Check that the device is online and SSH is enabled.\n`);
|
||||
} else {
|
||||
console.error(`\n[UT Sync] SSH connection failed: ${stderr}\n`);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function createUtSyncPlugin(cfg: ScpConfig): Plugin {
|
||||
let syncing = false;
|
||||
let connected = false;
|
||||
|
||||
return {
|
||||
name: "ut-sync-plugin",
|
||||
apply: "serve",
|
||||
|
||||
configureServer(server) {
|
||||
if (!cfg.host) {
|
||||
console.log("[UT Sync] Disabled: VITE_OPENWRT_SSH_HOST not set in .env");
|
||||
return;
|
||||
}
|
||||
|
||||
const authInfo = cfg.key ? `key (${cfg.key})` : "ssh-agent/config";
|
||||
console.log(`[UT Sync] Watching ${UT_TEMPLATE_DIR}`);
|
||||
console.log(`[UT Sync] Target: ${cfg.host}:${UT_REMOTE_DIR} (auth: ${authInfo})`);
|
||||
|
||||
checkSshConnection(cfg).then((ok) => {
|
||||
if (!ok) return;
|
||||
connected = true;
|
||||
|
||||
const watcher = fsWatch(UT_TEMPLATE_DIR, (eventType, filename) => {
|
||||
if (!filename?.endsWith(".ut") || eventType !== "change") return;
|
||||
if (syncing) return;
|
||||
|
||||
syncing = true;
|
||||
const filePath = join(UT_TEMPLATE_DIR, filename);
|
||||
const remotePath = `${UT_REMOTE_DIR}/${filename}`;
|
||||
const cmd = buildScpCommand(filePath, remotePath, cfg);
|
||||
|
||||
console.log(`[UT Sync] Syncing ${filename} → ${cfg.host}:${remotePath}`);
|
||||
execAsync(cmd)
|
||||
.then(() => {
|
||||
console.log(`[UT Sync] Done. Reloading browser.`);
|
||||
server.ws.send({ type: "full-reload", path: "*" });
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error(`[UT Sync] Failed to sync ${filename}:`, err?.message);
|
||||
})
|
||||
.finally(() => {
|
||||
syncing = false;
|
||||
});
|
||||
});
|
||||
|
||||
server.httpServer?.on("close", () => watcher.close());
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function createRedirectPlugin(): Plugin {
|
||||
return {
|
||||
name: "redirect-plugin",
|
||||
@ -200,6 +308,8 @@ function createRedirectPlugin(): Plugin {
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, CURRENT_DIR, "");
|
||||
const OPENWRT_HOST = env.VITE_OPENWRT_HOST || "http://192.168.1.1:80";
|
||||
const OPENWRT_SSH_HOST = env.VITE_OPENWRT_SSH_HOST || "";
|
||||
const OPENWRT_SSH_KEY = env.VITE_OPENWRT_SSH_KEY || "";
|
||||
const DEV_HOST = env.VITE_DEV_HOST || "127.0.0.1";
|
||||
const DEV_PORT = Number(env.VITE_DEV_PORT) || 5173;
|
||||
|
||||
@ -256,6 +366,7 @@ export default defineConfig(({ mode }) => {
|
||||
tailwindcss(),
|
||||
createRedirectPlugin(),
|
||||
createLocalServePlugin(),
|
||||
createUtSyncPlugin({ host: OPENWRT_SSH_HOST, key: OPENWRT_SSH_KEY }),
|
||||
createLuciJsCompressPlugin(),
|
||||
],
|
||||
|
||||
|
||||
39
luci-theme-aurora/CLAUDE.md
Normal file
39
luci-theme-aurora/CLAUDE.md
Normal file
@ -0,0 +1,39 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Commands
|
||||
|
||||
All dev commands run from `.dev/`:
|
||||
|
||||
```bash
|
||||
cd .dev/
|
||||
pnpm dev # Start Vite dev server (proxies to OpenWrt device)
|
||||
pnpm build # Clean + build production assets to htdocs/luci-static/
|
||||
pnpm clean # Remove build output only
|
||||
```
|
||||
|
||||
No test suite or linter CLI. Formatting uses Prettier with format-on-save (`.vscode/settings.json`).
|
||||
|
||||
## Architecture
|
||||
|
||||
**Dual-layer build**: source in `.dev/` → OpenWrt-compatible output in `htdocs/luci-static/`.
|
||||
|
||||
- `.dev/src/media/main.css` → `htdocs/luci-static/aurora/main.css` (TailwindCSS v4, lightningcss)
|
||||
- `.dev/src/resource/*.js` → `htdocs/luci-static/resources/*.js` (Terser, no bundling)
|
||||
- `.dev/public/aurora/` → `htdocs/luci-static/aurora/` (copied as-is)
|
||||
- `ucode/template/themes/aurora/*.ut` — server-side templates, not processed by Vite
|
||||
|
||||
**CSS**: single entry point `.dev/src/media/main.css`. All styling MUST use TailwindCSS v4 utility classes via `@apply` — no raw CSS properties (e.g. write `@apply text-sm font-semibold;` not `font-size: 14px; font-weight: 600;`). Use [CSS Nesting syntax](https://drafts.csswg.org/css-nesting/) for selectors. Theme colors defined as OKLCH custom properties in `:root` and mapped via `@theme inline`. `@layer` at-rules stripped by PostCSS plugin for OpenWrt compatibility.
|
||||
|
||||
**JavaScript**: LuCI `E()` DOM API (not React/Vue). Minified but not bundled.
|
||||
|
||||
**Dark mode**: `@custom-variant dark` keyed on `[data-darkmode=true]`, switching logic in `header.ut`.
|
||||
|
||||
**Templates**: `header.ut`, `footer.ut`, `sysauth.ut` — ucode templates rendered server-side on OpenWrt.
|
||||
|
||||
## Key References
|
||||
|
||||
- **Development guide**: `.dev/docs/DEVELOPMENT.md` — dev server setup, env config, proxy details, CI workflows, directory structure
|
||||
- **Vite config**: `.dev/vite.config.ts` — custom plugins (luci-js-compress, local-serve, ut-sync, remove-layers)
|
||||
- **Version**: `PKG_VERSION` and `PKG_RELEASE` in `Makefile`
|
||||
@ -9,7 +9,7 @@ LUCI_TITLE:=Aurora Theme (A modern browser theme built with Vite and Tailwind CS
|
||||
LUCI_DEPENDS:=+luci-base
|
||||
|
||||
PKG_VERSION:=0.11.4
|
||||
PKG_RELEASE:=5
|
||||
PKG_RELEASE:=6
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
|
||||
LUCI_MINIFY_CSS:=
|
||||
|
||||
@ -19,6 +19,17 @@
|
||||
<img src="https://raw.githubusercontent.com/eamonxg/assets/master/aurora/preview/theme/multi-device-showcase.png" alt="Multi-Device Showcase" width="100%">
|
||||
</div>
|
||||
|
||||
> [!NOTE]
|
||||
> **🤖 Exploring AI Workflows...**
|
||||
>
|
||||
> Hey everyone — I've been pretty busy with work lately, so my time for Aurora has been limited. But I don't want the project to stall, so I've been exploring AI-assisted workflows to help pick up the slack, especially on the debugging side.
|
||||
>
|
||||
> There's a backlog of open issues right now, and honestly, most of them are styling compatibility problems with third-party plugins. These aren't huge issues individually, but they're incredibly time-consuming to track down — you have to install the plugin, sometimes set up specific conditions on the router just to reproduce the problem.
|
||||
>
|
||||
> The root cause is that LuCI only provides a basic set of web components. When plugin authors need more complex UI, they end up rolling their own HTML/CSS/JS with no shared conventions, so compatibility headaches are inevitable. With the sheer number of LuCI plugins out there, getting them all to play nicely is a massive undertaking — especially when some plugins don't even follow LuCI's own JS conventions.
|
||||
>
|
||||
> So I'm bringing AI into the loop to handle these tedious but important tasks, and ideally automate as much of it as possible. If you have better ideas or suggestions, I'd love to hear them — come chat on [Discord](https://discord.gg/EBncRrzfTw).
|
||||
|
||||
## Features
|
||||
|
||||
- **Modern**: Modern, content-first UI design with a clean layout and elegant animations.
|
||||
|
||||
@ -19,6 +19,17 @@
|
||||
<img src="https://raw.githubusercontent.com/eamonxg/assets/master/aurora/preview/theme/multi-device-showcase.png" alt="Multi-Device Showcase" width="100%">
|
||||
</div>
|
||||
|
||||
> [!NOTE]
|
||||
> **🤖 AI 工作流探索中…**
|
||||
>
|
||||
> 大家好,最近工作比较忙,能投入到 Aurora 主题的时间有限,但我不希望 Aurora 因此停滞不前,所以最近一直在研究 AI 工作流,希望借助 AI 来分担一部分工作,尤其是调试方面。
|
||||
>
|
||||
> 目前主题积压了不少 issue,其实大部分都是第三方插件的样式兼容问题。这类问题说大不大,但调起来真的很耗时间——你得先装上对应的插件,有时候路由器还得满足特定条件才能复现。
|
||||
>
|
||||
> 归根结底,LuCI 本身只提供了一套基础的 Web 组件,插件作者想实现更复杂的交互,就只能用 HTML + CSS + JS 自行实现,没有统一的规范,各种兼容问题在所难免。LuCI 插件数量庞大,要逐一做好兼容,工作量可想而知——更何况有些插件本身也没有按照 LuCI JS 的规范来开发。
|
||||
>
|
||||
> 所以我希望引入 AI,把这些琐碎但繁重的任务交给它来完成,如果能实现自动化那就更理想了。如果你有更好的建议或想法,欢迎来 [Discord](https://discord.gg/EBncRrzfTw) 聊聊。
|
||||
|
||||
## 特性
|
||||
|
||||
- **现代化**:内容优先的现代化 UI 设计,布局整洁,动画优雅。
|
||||
|
||||
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mihomo
|
||||
PKG_VERSION:=1.19.23
|
||||
PKG_RELEASE:=4
|
||||
PKG_RELEASE:=6
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/metacubex/mihomo/tar.gz/v$(PKG_VERSION)?
|
||||
|
||||
@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=my-dnshelper
|
||||
PKG_VERSION:=1.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_MAINTAINER:=kongfl888 <kongfl888@outlook.com>
|
||||
PKG_LICENSE:=GPLv2
|
||||
@ -53,9 +53,9 @@ endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
chmod a+x ${IPKG_INSTROOT}/etc/init.d/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
chmod a+x ${IPKG_INSTROOT}/usr/share/my-dnshelper/* >/dev/null 2>&1 || echo ""
|
||||
chmod a+x ${IPKG_INSTROOT}/usr/bin/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
chmod a+x $${IPKG_INSTROOT}/etc/init.d/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
chmod a+x $${IPKG_INSTROOT}/usr/share/my-dnshelper/* >/dev/null 2>&1 || echo ""
|
||||
chmod a+x $${IPKG_INSTROOT}/usr/bin/my-dnshelper >/dev/null 2>&1 || echo ""
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=sing-box
|
||||
PKG_VERSION:=1.13.7
|
||||
PKG_RELEASE:=7
|
||||
PKG_RELEASE:=10
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/SagerNet/sing-box/tar.gz/v$(PKG_VERSION)?
|
||||
|
||||
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=Xray-core
|
||||
PKG_VERSION:=26.3.27
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=5
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/XTLS/Xray-core/tar.gz/v$(PKG_VERSION)?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user