mirror of
https://github.com/roacn/openwrt-packages.git
synced 2025-01-09 12:28:17 +08:00
🍉 Sync 2023-05-04 20:37
This commit is contained in:
parent
40c8a29357
commit
d3d11fbdf8
@ -1,77 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=aliyundrive-fuse
|
||||
PKG_VERSION:=0.1.14
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_MAINTAINER:=messense <messense@icloud.com>
|
||||
|
||||
PKG_LIBC:=musl
|
||||
ifeq ($(ARCH),arm)
|
||||
PKG_LIBC:=musleabi
|
||||
|
||||
ARM_CPU_FEATURES:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
|
||||
ifneq ($(filter $(ARM_CPU_FEATURES),vfp vfpv2),)
|
||||
PKG_LIBC:=musleabihf
|
||||
endif
|
||||
endif
|
||||
|
||||
PKG_ARCH=$(ARCH)
|
||||
ifeq ($(ARCH),i386)
|
||||
PKG_ARCH:=i686
|
||||
endif
|
||||
|
||||
PKG_SOURCE:=aliyundrive-fuse-v$(PKG_VERSION).$(PKG_ARCH)-unknown-linux-$(PKG_LIBC).tar.gz
|
||||
PKG_SOURCE_URL:=https://github.com/messense/aliyundrive-fuse/releases/download/v$(PKG_VERSION)/
|
||||
PKG_HASH:=skip
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/aliyundrive-fuse
|
||||
SECTION:=multimedia
|
||||
CATEGORY:=Multimedia
|
||||
DEPENDS:=+fuse-utils
|
||||
TITLE:=FUSE for AliyunDrive
|
||||
URL:=https://github.com/messense/aliyundrive-fuse
|
||||
endef
|
||||
|
||||
define Package/aliyundrive-fuse/description
|
||||
FUSE for AliyunDrive.
|
||||
endef
|
||||
|
||||
define Package/aliyundrive-fuse/conffiles
|
||||
/etc/config/aliyundrive-fuse
|
||||
endef
|
||||
|
||||
define Download/sha256sum
|
||||
FILE:=$(PKG_SOURCE).sha256
|
||||
URL_FILE:=$(FILE)
|
||||
URL:=$(PKG_SOURCE_URL)
|
||||
HASH:=skip
|
||||
endef
|
||||
$(eval $(call Download,sha256sum))
|
||||
|
||||
define Build/Prepare
|
||||
mv $(DL_DIR)/$(PKG_SOURCE).sha256 .
|
||||
cp $(DL_DIR)/$(PKG_SOURCE) .
|
||||
shasum -a 256 -c $(PKG_SOURCE).sha256
|
||||
rm $(PKG_SOURCE).sha256 $(PKG_SOURCE)
|
||||
|
||||
tar -C $(PKG_BUILD_DIR)/ -zxf $(DL_DIR)/$(PKG_SOURCE)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
echo "aliyundrive-fuse using precompiled binary."
|
||||
endef
|
||||
|
||||
define Package/aliyundrive-fuse/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/aliyundrive-fuse $(1)/usr/bin/aliyundrive-fuse
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/aliyundrive-fuse.init $(1)/etc/init.d/aliyundrive-fuse
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/aliyundrive-fuse.config $(1)/etc/config/aliyundrive-fuse
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,aliyundrive-fuse))
|
@ -1,7 +0,0 @@
|
||||
config default
|
||||
option enable '0'
|
||||
option debug '0'
|
||||
option refresh_token ''
|
||||
option mount_point '/mnt/aliyundrive'
|
||||
option read_buffer_size '10485760'
|
||||
option allow_other '1'
|
@ -1,48 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=99
|
||||
STOP=15
|
||||
|
||||
NAME=aliyundrive-fuse
|
||||
|
||||
uci_get_by_type() {
|
||||
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
start_service() {
|
||||
local enable=$(uci_get_by_type default enable)
|
||||
case "$enable" in
|
||||
1|on|true|yes|enabled)
|
||||
local refresh_token=$(uci_get_by_type default refresh_token)
|
||||
local mount_point=$(uci_get_by_type default mount_point)
|
||||
local read_buf_size=$(uci_get_by_type default read_buffer_size 10485760)
|
||||
local allow_other=$(uci_get_by_type default allow_other 0)
|
||||
|
||||
local extra_options=""
|
||||
|
||||
if [ "$allow_other" = "1" ]; then
|
||||
extra_options="$extra_options --allow-other"
|
||||
fi
|
||||
|
||||
mkdir -p "$mount_point"
|
||||
procd_open_instance
|
||||
procd_set_param command /bin/sh -c "/usr/bin/$NAME $extra_options -S $read_buf_size --workdir /var/run/$NAME $mount_point >>/var/log/$NAME.log 2>&1"
|
||||
procd_set_param pidfile /var/run/$NAME.pid
|
||||
procd_set_param env REFRESH_TOKEN="$refresh_token"
|
||||
case $(uci_get_by_type default debug) in
|
||||
1|on|true|yes|enabled)
|
||||
procd_append_param env RUST_LOG="aliyundrive_fuse=debug" ;;
|
||||
*) ;;
|
||||
esac
|
||||
procd_close_instance ;;
|
||||
*)
|
||||
stop_service ;;
|
||||
esac
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "aliyundrive-fuse"
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-aliyundrive-fuse
|
||||
PKG_VERSION:=0.1.14
|
||||
PKG_RELEASE:=1
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)-$(PKG_RELEASE)
|
||||
|
||||
PKG_LICENSE:=MIT
|
||||
PKG_MAINTAINER:=messense <messense@icloud.com>
|
||||
|
||||
LUCI_TITLE:=LuCI Support for aliyundrive-fuse
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+aliyundrive-fuse
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
@ -1,40 +0,0 @@
|
||||
module("luci.controller.aliyundrive-fuse", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/aliyundrive-fuse") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
page = entry({"admin", "services", "aliyundrive-fuse"}, alias("admin", "services", "aliyundrive-fuse", "client"), _("AliyunDrive FUSE"), 10) -- 首页
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-aliyundrive-fuse" }
|
||||
|
||||
entry({"admin", "services", "aliyundrive-fuse", "client"}, cbi("aliyundrive-fuse/client"), _("Settings"), 10).leaf = true -- 客户端配置
|
||||
entry({"admin", "services", "aliyundrive-fuse", "log"}, form("aliyundrive-fuse/log"), _("Log"), 30).leaf = true -- 日志页面
|
||||
|
||||
entry({"admin", "services", "aliyundrive-fuse", "status"}, call("action_status")).leaf = true
|
||||
entry({"admin", "services", "aliyundrive-fuse", "logtail"}, call("action_logtail")).leaf = true
|
||||
end
|
||||
|
||||
function action_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pidof aliyundrive-fuse >/dev/null") == 0
|
||||
e.application = luci.sys.exec("aliyundrive-fuse --version")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function action_logtail()
|
||||
local fs = require "nixio.fs"
|
||||
local log_path = "/var/log/aliyundrive-fuse.log"
|
||||
local e = {}
|
||||
e.running = luci.sys.call("pidof aliyundrive-fuse >/dev/null") == 0
|
||||
if fs.access(log_path) then
|
||||
e.log = luci.sys.exec("tail -n 100 %s | sed 's/\\x1b\\[[0-9;]*m//g'" % log_path)
|
||||
else
|
||||
e.log = ""
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
@ -1,30 +0,0 @@
|
||||
m = Map("aliyundrive-fuse")
|
||||
m.title = translate("AliyunDrive FUSE")
|
||||
m.description = translate("<a href=\"https://github.com/messense/aliyundrive-fuse\" target=\"_blank\">Project GitHub URL</a>")
|
||||
|
||||
m:section(SimpleSection).template = "aliyundrive-fuse/aliyundrive-fuse_status"
|
||||
|
||||
e = m:section(TypedSection, "default")
|
||||
e.anonymous = true
|
||||
|
||||
enable = e:option(Flag, "enable", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
|
||||
refresh_token = e:option(Value, "refresh_token", translate("Refresh Token"))
|
||||
refresh_token.description = translate("<a href=\"https://github.com/messense/aliyundrive-webdav#%E8%8E%B7%E5%8F%96-refresh_token\" target=\"_blank\">How to get refresh token</a>")
|
||||
|
||||
mount_point = e:option(Value, "mount_point", translate("Mount Point"))
|
||||
mount_point.default = "/mnt/aliyundrive"
|
||||
|
||||
read_buffer_size = e:option(Value, "read_buffer_size", translate("Read Buffer Size"))
|
||||
read_buffer_size.default = "10485760"
|
||||
read_buffer_size.datatype = "uinteger"
|
||||
|
||||
allow_other = e:option(Flag, "allow_other", translate("Allow Other users Access"))
|
||||
allow_other.description = translate("Allow other users to access the drive, enable this if you share with samba")
|
||||
allow_other.rmempty = false
|
||||
|
||||
debug = e:option(Flag, "debug", translate("Debug Mode"))
|
||||
debug.rmempty = false
|
||||
|
||||
return m
|
@ -1,9 +0,0 @@
|
||||
log = SimpleForm("logview")
|
||||
log.submit = false
|
||||
log.reset = false
|
||||
|
||||
t = log:field(DummyValue, '', '')
|
||||
t.rawhtml = true
|
||||
t.template = 'aliyundrive-fuse/aliyundrive-fuse_log'
|
||||
|
||||
return log
|
@ -1,15 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<textarea id="logview" class="cbi-input-textarea" style="width: 100%" rows="30" readonly="readonly"></textarea>
|
||||
|
||||
<script type="text/javascript">
|
||||
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "services", "aliyundrive-fuse", "logtail")%>';
|
||||
XHR.poll(1, LOG_URL, null, (x, d) => {
|
||||
let logview = document.getElementById("logview");
|
||||
if (!d.running) {
|
||||
XHR.halt();
|
||||
}
|
||||
logview.value = d.log;
|
||||
logview.scrollTop = logview.scrollHeight;
|
||||
});
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -1,21 +0,0 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[aliyundrive-fuse]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('aliyundrive-fuse_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
tb.innerHTML = '<em><b style=color:green>' + data.application + '<%:RUNNING%></b></em>';
|
||||
} else {
|
||||
tb.innerHTML = '<em><b style=color:red>' + data.application + '<%:NOT RUNNING%></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="aliyundrive-fuse_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -1,50 +0,0 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "AliyunDrive"
|
||||
msgstr "阿里云盘"
|
||||
|
||||
msgid "AliyunDrive FUSE"
|
||||
msgstr "阿里云盘 FUSE"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Refresh Token"
|
||||
msgstr "Refresh Token"
|
||||
|
||||
msgid "Mount Point"
|
||||
msgstr "挂载点"
|
||||
|
||||
msgid "Read Buffer Size"
|
||||
msgstr "下载缓冲大小(bytes)"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "获取数据中..."
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Settings"
|
||||
msgstr "设置"
|
||||
|
||||
msgid "Log"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Debug Mode"
|
||||
msgstr "调试模式"
|
||||
|
||||
msgid "<a href=\"https://github.com/messense/aliyundrive-fuse\" target=\"_blank\">Project GitHub URL</a>"
|
||||
msgstr "<a href=\"https://github.com/messense/aliyundrive-fuse\" target=\"_blank\">GitHub 项目地址</a>"
|
||||
|
||||
msgid "<a href=\"https://github.com/messense/aliyundrive-webdav#%E8%8E%B7%E5%8F%96-refresh_token\" target=\"_blank\">How to get refresh token</a>"
|
||||
msgstr "<a href=\"https://github.com/messense/aliyundrive-webdav#%E8%8E%B7%E5%8F%96-refresh_token\" target=\"_blank\">查看获取 refresh token 的方法</a>"
|
||||
|
||||
msgid "Allow Other users Access"
|
||||
msgstr "允许其他用户访问"
|
||||
|
||||
msgid "Allow other users to access the drive, enable this if you share with samba"
|
||||
msgstr "允许其他用户访问此驱动,如果你想用Samba分享请开启此开关"
|
@ -1 +0,0 @@
|
||||
zh-cn
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@aliyundrive-fuse[-1]
|
||||
add ucitrack aliyundrive-fuse
|
||||
set ucitrack.@aliyundrive-fuse[-1].init=aliyundrive-fuse
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"luci-app-aliyundrive-fuse": {
|
||||
"description": "Grant UCI access for luci-app-aliyundrive-fuse",
|
||||
"read": {
|
||||
"uci": [ "aliyundrive-fuse" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "aliyundrive-fuse" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
# Author: mingxiaoyu (fengying0347@163.com)
|
||||
#
|
||||
# Licensed to the public under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-cloudflarespeedtest
|
||||
|
||||
LUCI_TITLE:=LuCI support for Cloudflares Speed Test
|
||||
LUCI_DEPENDS:=+cdnspeedtest +openssl-util +curl
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.5.2
|
||||
PKG_RELEASE:=0
|
||||
PKG_LICENSE:=AGPL-3.0
|
||||
PKG_MAINTAINER:=mingxiaoyu <fengying0347@163.com>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
@ -1,50 +0,0 @@
|
||||
-- Copyright (C) 2020 mingxiaoyu <fengying0347@163.com>
|
||||
-- Licensed to the public under the GNU General Public License v3.
|
||||
module("luci.controller.cloudflarespeedtest",package.seeall)
|
||||
|
||||
function index()
|
||||
|
||||
if not nixio.fs.access('/etc/config/cloudflarespeedtest') then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
page = entry({"admin", "services", "cloudflarespeedtest"}, firstchild(), _("Cloudflare Speed Test"), 99)
|
||||
page.dependent = false
|
||||
page.acl_depends = { "luci-app-cloudflarespeedtest" }
|
||||
|
||||
entry({"admin", "services", "cloudflarespeedtest", "general"}, cbi("cloudflarespeedtest/cloudflarespeedtest"), _("Base Setting"), 1)
|
||||
entry({"admin", "services", "cloudflarespeedtest", "logread"}, form("cloudflarespeedtest/logread"), _("Logs"), 2)
|
||||
|
||||
entry({"admin", "services", "cloudflarespeedtest", "status"}, call("act_status")).leaf = true
|
||||
entry({"admin", "services", "cloudflarespeedtest", "stop"}, call("act_stop"))
|
||||
entry({"admin", "services", "cloudflarespeedtest", "start"}, call("act_start"))
|
||||
entry({"admin", "services", "cloudflarespeedtest", "getlog"}, call("get_log"))
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = luci.sys.call("busybox ps -w | grep cdnspeedtest | grep -v grep >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function act_stop()
|
||||
luci.sys.call("busybox ps -w | grep cdnspeedtest | grep -v grep | xargs kill -9 >/dev/null")
|
||||
luci.http.write('')
|
||||
end
|
||||
|
||||
function act_start()
|
||||
act_stop()
|
||||
luci.sys.call("/usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start")
|
||||
luci.http.write('')
|
||||
end
|
||||
|
||||
function get_log()
|
||||
local fs = require "nixio.fs"
|
||||
local e = {}
|
||||
e.running = luci.sys.call("busybox ps -w | grep cdnspeedtest | grep -v grep >/dev/null") == 0
|
||||
e.log= fs.readfile("/var/log/cloudflarespeedtest.log") or ""
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
@ -1,335 +0,0 @@
|
||||
require("luci.sys")
|
||||
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
m = Map('cloudflarespeedtest')
|
||||
m.title = translate('Cloudflare Speed Test')
|
||||
m.description = '<a href=\"https://github.com/mingxiaoyu/luci-app-cloudflarespeedtest\" target=\"_blank\">GitHub</a>'
|
||||
|
||||
-- [[ 基本设置 ]]--
|
||||
|
||||
s = m:section(NamedSection, 'global')
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
o=s:option(Flag,"enabled",translate("Enabled"))
|
||||
o.description = translate("Enabled scheduled task test Cloudflare IP")
|
||||
o.rmempty=false
|
||||
o.default = 0
|
||||
|
||||
o=s:option(Flag,"ipv6_enabled",translate("IPv6 Enabled"))
|
||||
o.description = translate("Provides only one method, if IPv6 is enabled, IPv4 will not be tested")
|
||||
o.default = 0
|
||||
o.rmempty=false
|
||||
|
||||
o=s:option(Value,"speed",translate("Broadband speed"))
|
||||
o.description =translate("100M broadband download speed is about 12M/s. It is not recommended to fill in an excessively large value, and it may run all the time.");
|
||||
o.datatype ="uinteger"
|
||||
o.rmempty=false
|
||||
|
||||
o=s:option(Value,"custome_url",translate("Custome Url"))
|
||||
o.description = translate("<a href=\"https://github.com/XIU2/CloudflareSpeedTest/issues/168\" target=\"_blank\">How to create</a>")
|
||||
o.rmempty=false
|
||||
|
||||
o=s:option(Flag,"custome_cors_enabled",translate("Custome Cron Enabled"))
|
||||
o.default = 0
|
||||
o.rmempty=false
|
||||
|
||||
o = s:option(Value, "custome_cron", translate("Custome Cron"))
|
||||
o:depends("custome_cors_enabled", 1)
|
||||
|
||||
hour = s:option(Value, "hour", translate("Hour"))
|
||||
hour.datatype = "range(0,23)"
|
||||
hour:depends("custome_cors_enabled", 0)
|
||||
|
||||
minute = s:option(Value, "minute", translate("Minute"))
|
||||
minute.datatype = "range(0,59)"
|
||||
minute:depends("custome_cors_enabled", 0)
|
||||
|
||||
o = s:option(ListValue, "proxy_mode", translate("Proxy Mode"))
|
||||
o:value("nil", translate("HOLD"))
|
||||
o.description = translate("during the speed testing, swith to which mode")
|
||||
o:value("gfw", translate("GFW List"))
|
||||
o:value("close", translate("CLOSE"))
|
||||
o.default = "gfw"
|
||||
|
||||
o=s:option(Flag,"advanced",translate("Advanced"))
|
||||
o.description = translate("Not recommended")
|
||||
o.default = 0
|
||||
o.rmempty=false
|
||||
|
||||
o = s:option(Value, "threads", translate("Thread"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 200
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "tl", translate("Average Latency Cap"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 200
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "tll", translate("Average Latency Lower Bound"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 40
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "t", translate("Delayed speed measurement time"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 4
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "dt", translate("Download speed test time"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 10
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "dn", translate("Number of download speed tests"))
|
||||
o.datatype ="uinteger"
|
||||
o.default = 1
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Flag, "dd", translate("Disable download speed test"))
|
||||
o.default = 0
|
||||
o.rmempty=true
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(Value, "tp", translate("Port"))
|
||||
o.rmempty=true
|
||||
o.default = 443
|
||||
o.datatype ="port"
|
||||
o:depends("advanced", 1)
|
||||
|
||||
o = s:option(DummyValue, '', '')
|
||||
o.rawhtml = true
|
||||
o.template = "cloudflarespeedtest/actions"
|
||||
|
||||
s = m:section(NamedSection, "servers", "section", translate("Third party applications settings"))
|
||||
|
||||
if nixio.fs.access("/etc/config/shadowsocksr") then
|
||||
s:tab("ssr", translate("Shadowsocksr Plus+"))
|
||||
|
||||
o=s:taboption("ssr", Flag, "ssr_enabled",translate("Shadowsocksr Plus+ Enabled"))
|
||||
o.rmempty=true
|
||||
|
||||
local ssr_server_table = {}
|
||||
uci:foreach("shadowsocksr", "servers", function(s)
|
||||
if s.alias then
|
||||
ssr_server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.v2ray_protocol or s.type), s.alias}
|
||||
elseif s.server and s.server_port then
|
||||
ssr_server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.v2ray_protocol or s.type), s.server, s.server_port}
|
||||
end
|
||||
end)
|
||||
|
||||
local ssr_key_table = {}
|
||||
for key, _ in pairs(ssr_server_table) do
|
||||
table.insert(ssr_key_table, key)
|
||||
end
|
||||
|
||||
table.sort(ssr_key_table)
|
||||
|
||||
o = s:taboption("ssr", DynamicList, "ssr_services",
|
||||
translate("Shadowsocksr Servers"),
|
||||
translate("Please select a service"))
|
||||
|
||||
for _, key in pairs(ssr_key_table) do
|
||||
o:value(key, ssr_server_table[key])
|
||||
end
|
||||
o:depends("ssr_enabled", 1)
|
||||
o.forcewrite = true
|
||||
|
||||
end
|
||||
|
||||
|
||||
if nixio.fs.access("/etc/config/passwall") then
|
||||
s:tab("passwalltab", translate("passwall"))
|
||||
|
||||
o=s:taboption("passwalltab", Flag, "passwall_enabled",translate("Passwall Enabled"))
|
||||
o.rmempty=true
|
||||
|
||||
local passwall_server_table = {}
|
||||
uci:foreach("passwall", "nodes", function(s)
|
||||
if s.remarks then
|
||||
passwall_server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.protocol or s.type), s.remarks}
|
||||
end
|
||||
end)
|
||||
|
||||
local passwall_key_table = {}
|
||||
for key, _ in pairs(passwall_server_table) do
|
||||
table.insert(passwall_key_table, key)
|
||||
end
|
||||
|
||||
table.sort(passwall_key_table)
|
||||
|
||||
o = s:taboption("passwalltab", DynamicList, "passwall_services",
|
||||
translate("Passwall Servers"),
|
||||
translate("Please select a service"))
|
||||
|
||||
for _, key in pairs(passwall_key_table) do
|
||||
o:value(key, passwall_server_table[key])
|
||||
end
|
||||
o:depends("passwall_enabled", 1)
|
||||
o.forcewrite = true
|
||||
|
||||
end
|
||||
|
||||
if nixio.fs.access("/etc/config/passwall2") then
|
||||
s:tab("passwall2tab", translate("passwall2"))
|
||||
|
||||
o=s:taboption("passwall2tab", Flag, "passwall2_enabled",translate("PassWall2 Enabled"))
|
||||
o.rmempty=true
|
||||
|
||||
local passwall2_server_table = {}
|
||||
uci:foreach("passwall2", "nodes", function(s)
|
||||
if s.remarks then
|
||||
passwall2_server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.protocol or s.type), s.remarks}
|
||||
end
|
||||
end)
|
||||
|
||||
local passwall2_key_table = {}
|
||||
for key, _ in pairs(passwall2_server_table) do
|
||||
table.insert(passwall2_key_table, key)
|
||||
end
|
||||
|
||||
table.sort(passwall2_key_table)
|
||||
|
||||
o = s:taboption("passwall2tab", DynamicList, "passwall2_services",
|
||||
translate("Passwall2 Servers"),
|
||||
translate("Please select a service"))
|
||||
|
||||
for _, key in pairs(passwall2_key_table) do
|
||||
o:value(key, passwall2_server_table[key])
|
||||
end
|
||||
o:depends("passwall2_enabled", 1)
|
||||
o.forcewrite = true
|
||||
|
||||
end
|
||||
|
||||
s:tab("bypasstab", translate("Bypass"))
|
||||
if nixio.fs.access("/etc/config/bypass") then
|
||||
|
||||
o=s:taboption("bypasstab", Flag, "bypass_enabled",translate("Bypass Enabled"))
|
||||
o.rmempty=true
|
||||
|
||||
local bypass_server_table = {}
|
||||
uci:foreach("bypass", "servers", function(s)
|
||||
if s.alias then
|
||||
bypass_server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.protocol or s.type), s.alias}
|
||||
elseif s.server and s.server_port then
|
||||
bypass_server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.protocol or s.type), s.server, s.server_port}
|
||||
end
|
||||
end)
|
||||
|
||||
local bypass_key_table = {}
|
||||
for key, _ in pairs(bypass_server_table) do
|
||||
table.insert(bypass_key_table, key)
|
||||
end
|
||||
|
||||
table.sort(bypass_key_table)
|
||||
|
||||
o = s:taboption("bypasstab", DynamicList, "bypass_services",
|
||||
translate("Bypass Servers"),
|
||||
translate("Please select a service"))
|
||||
|
||||
for _, key in pairs(bypass_key_table) do
|
||||
o:value(key, bypass_server_table[key])
|
||||
end
|
||||
o:depends("bypass_enabled", 1)
|
||||
o.forcewrite = true
|
||||
|
||||
end
|
||||
|
||||
s:tab("vssrtab", translate("Vssr"))
|
||||
if nixio.fs.access("/etc/config/vssr") then
|
||||
|
||||
o=s:taboption("vssrtab", Flag, "vssr_enabled",translate("Vssr Enabled"))
|
||||
o.rmempty=true
|
||||
|
||||
local vssr_server_table = {}
|
||||
uci:foreach("vssr", "servers", function(s)
|
||||
if s.alias then
|
||||
vssr_server_table[s[".name"]] = "[%s]:%s" % {string.upper(s.protocol or s.type), s.alias}
|
||||
elseif s.server and s.server_port then
|
||||
vssr_server_table[s[".name"]] = "[%s]:%s:%s" % {string.upper(s.protocol or s.type), s.server, s.server_port}
|
||||
end
|
||||
end)
|
||||
|
||||
local vssr_key_table = {}
|
||||
for key, _ in pairs(vssr_server_table) do
|
||||
table.insert(vssr_key_table, key)
|
||||
end
|
||||
|
||||
table.sort(vssr_key_table)
|
||||
|
||||
o = s:taboption("vssrtab", DynamicList, "vssr_services",
|
||||
translate("Vssr Servers"),
|
||||
translate("Please select a service"))
|
||||
|
||||
for _, key in pairs(vssr_key_table) do
|
||||
o:value(key, vssr_server_table[key])
|
||||
end
|
||||
o:depends("vssr_enabled", 1)
|
||||
o.forcewrite = true
|
||||
|
||||
end
|
||||
|
||||
s:tab("dnstab", translate("DNS"))
|
||||
|
||||
o=s:taboption("dnstab", Flag, "DNS_enabled",translate("DNS Enabled"))
|
||||
|
||||
o=s:taboption("dnstab", ListValue, "DNS_type", translate("DNS Type"))
|
||||
o:value("aliyu", translate("AliyuDNS"))
|
||||
o:depends("DNS_enabled", 1)
|
||||
|
||||
o=s:taboption("dnstab", Value,"app_key",translate("Access Key ID"))
|
||||
o.rmempty=true
|
||||
o:depends("DNS_enabled", 1)
|
||||
o=s:taboption("dnstab", Value,"app_secret",translate("Access Key Secret"))
|
||||
o.rmempty=true
|
||||
o:depends("DNS_enabled", 1)
|
||||
|
||||
o=s:taboption("dnstab", Value,"main_domain",translate("Main Domain"),translate("For example: test.github.com -> github.com"))
|
||||
o.rmempty=true
|
||||
o:depends("DNS_enabled", 1)
|
||||
o=s:taboption("dnstab", DynamicList,"sub_domain",translate("Sub Domain"),translate("For example: test.github.com -> test"))
|
||||
o.rmempty=true
|
||||
o:depends("DNS_enabled", 1)
|
||||
|
||||
o=s:taboption("dnstab", ListValue, "line", translate("Lines"))
|
||||
o:value("default", translate("default"))
|
||||
o:value("telecom", translate("telecom"))
|
||||
o:value("unicom", translate("unicom"))
|
||||
o:value("mobile", translate("mobile"))
|
||||
o:depends("DNS_enabled", 1)
|
||||
o.default ="telecom"
|
||||
|
||||
s:tab("dnshost", translate("HOST"))
|
||||
o=s:taboption("dnshost", Flag, "HOST_enabled",translate("HOST Enabled"))
|
||||
o=s:taboption("dnshost", Value,"host_domain",translate("Domain"))
|
||||
o.rmempty=true
|
||||
o:depends("HOST_enabled", 1)
|
||||
|
||||
e=m:section(TypedSection,"global",translate("Best IP"))
|
||||
e.anonymous=true
|
||||
local a="/usr/share/cloudflarespeedtestresult.txt"
|
||||
tvIPs=e:option(TextValue,"syipstext")
|
||||
tvIPs.rows=8
|
||||
tvIPs.readonly="readonly"
|
||||
tvIPs.wrap="off"
|
||||
|
||||
function tvIPs.cfgvalue(e,e)
|
||||
sylogtext=""
|
||||
if a and nixio.fs.access(a) then
|
||||
sylogtext=luci.sys.exec("tail -n 100 %s"%a)
|
||||
end
|
||||
return sylogtext
|
||||
end
|
||||
tvIPs.write=function(e,e,e)
|
||||
end
|
||||
|
||||
return m
|
@ -1,9 +0,0 @@
|
||||
log = SimpleForm("logview")
|
||||
log.submit = false
|
||||
log.reset = false
|
||||
|
||||
t = log:field(DummyValue, '', '')
|
||||
t.rawhtml = true
|
||||
t.template = 'cloudflarespeedtest/logread'
|
||||
|
||||
return log
|
@ -1,56 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
const STATUS_URL = '<%=luci.dispatcher.build_url("admin", "services", "cloudflarespeedtest","status")%>';
|
||||
const RUN_URL = '<%=luci.dispatcher.build_url("admin", "services", "cloudflarespeedtest","start")%>';
|
||||
const STOP_URL = '<%=luci.dispatcher.build_url("admin", "services", "cloudflarespeedtest","stop")%>';
|
||||
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "services", "cloudflarespeedtest","logread")%>';
|
||||
|
||||
XHR.poll(3, STATUS_URL, null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('cloudflarespeedtest_status');
|
||||
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
buttonStatus(true)
|
||||
tb.innerHTML = '<em><b><font color=green><%:RUNNING %></font></b></em>';
|
||||
} else {
|
||||
buttonStatus(false)
|
||||
tb.innerHTML = '<em><b><font color=red> <%:NOT RUNNING %></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function cloudflarespeedtest_act_start() {
|
||||
buttonStatus(true)
|
||||
XHR.get(RUN_URL, null, () => {
|
||||
});
|
||||
setTimeout(() => { window.location = LOG_URL }, 500);
|
||||
return false;
|
||||
}
|
||||
|
||||
function cloudflarespeedtest_act_stop(){
|
||||
XHR.get(STOP_URL, null, () => {
|
||||
buttonStatus(false)
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function buttonStatus(running){
|
||||
document.getElementById('cloudflarespeedtest_start').style.display = running ? "none" : "block"
|
||||
document.getElementById('cloudflarespeedtest_stop').style.display = running ? "block" : "none"
|
||||
}
|
||||
|
||||
//]]></script>
|
||||
<label class="cbi-value-title"><%= translate("Status") %></label>
|
||||
<div class="cbi-value-field">
|
||||
<p id="cloudflarespeedtest_status"><em><%:Collecting data...%></em></p>
|
||||
</div>
|
||||
|
||||
<label class="cbi-value-title"><%= translate("Speed Test") %></label>
|
||||
<div class="cbi-value-field">
|
||||
<input id="cloudflarespeedtest_start" type="button" style="display:block;" class="btn cbi-button cbi-button-apply" value="<%= translate('TEST AND APPLY') %>" onclick="cloudflarespeedtest_act_start()" />
|
||||
<input id="cloudflarespeedtest_stop" type="button" style="display:none;" class="btn cbi-button cbi-button-apply" value="<%= translate('STOP') %>" onclick="cloudflarespeedtest_act_stop()" />
|
||||
</div>
|
||||
|
||||
<%+cbi/valuefooter%>
|
@ -1,23 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<input type="checkbox" id="checkbox1" checked><%:Auto refresh%></input>
|
||||
<textarea id="logview" class="cbi-input-textarea" style="width: 100%" rows="30" readonly="readonly"></textarea>
|
||||
|
||||
<script type="text/javascript">
|
||||
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "services", "cloudflarespeedtest","getlog")%>';
|
||||
|
||||
function getlog(){
|
||||
XHR.get(LOG_URL, null, function(x, data) {
|
||||
logview.value = data.log;
|
||||
if(document.getElementById("checkbox1").checked == true){
|
||||
logview.scrollTop = logview.scrollHeight;
|
||||
}
|
||||
});
|
||||
}
|
||||
getlog()
|
||||
setInterval(() => {
|
||||
if(document.getElementById("checkbox1").checked == true){
|
||||
getlog()
|
||||
}
|
||||
}, 2000);
|
||||
</script>
|
||||
<%+cbi/valuefooter%>
|
@ -1 +0,0 @@
|
||||
zh_Hans
|
@ -1,221 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"POT-Creation-Date: \n"
|
||||
"PO-Revision-Date: 2022-02-10 20:44+0000\n"
|
||||
"Last-Translator: mingxiaoyu <fengying0347@163.com>\n"
|
||||
"Language: zh_Hans\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 4.8-dev\n"
|
||||
|
||||
msgid "<a href=\"https://github.com/mingxiaoyu/luci-app-cloudflarespeedtest\" target=\"_blank\">GitHub</a>"
|
||||
msgstr "<a href=\"https://github.com/mingxiaoyu/luci-app-cloudflarespeedtest\" target=\"_blank\">GitHub项目地址</a>"
|
||||
|
||||
msgid "Cloudflare Speed Test"
|
||||
msgstr "Cloudflare速度测试"
|
||||
|
||||
msgid "Base Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Logs"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Enabled scheduled task test Cloudflare IP"
|
||||
msgstr "启用计划任务测试 Cloudflare IP"
|
||||
|
||||
msgid "Broadband speed"
|
||||
msgstr "宽带速度"
|
||||
|
||||
msgid "Custome Url Enabled"
|
||||
msgstr "启用自定义地址"
|
||||
|
||||
msgid "Custome Url"
|
||||
msgstr "自定义地址"
|
||||
|
||||
msgid "Custome Cron Enabled"
|
||||
msgstr "启用自定义Cron"
|
||||
|
||||
msgid "Custome Cron"
|
||||
msgstr "自定义Cron"
|
||||
|
||||
msgid "Hour"
|
||||
msgstr "小时"
|
||||
|
||||
msgid "Minute"
|
||||
msgstr "分钟"
|
||||
|
||||
msgid "100M broadband download speed is about 12M/s. It is not recommended to fill in an excessively large value, and it may run all the time."
|
||||
msgstr "100M的宽带下载大概为速度12M/s。不推荐填过大的值,可能出现一直运行。"
|
||||
|
||||
msgid "Shadowsocksr Plus+ Enabled"
|
||||
msgstr "启用ShadowSocksR Plus+"
|
||||
|
||||
msgid "Passwall Enabled"
|
||||
msgstr "启用Passwall"
|
||||
|
||||
msgid "PassWall2 Enabled"
|
||||
msgstr "启用PassWall2"
|
||||
|
||||
msgid "Bypass Enabled"
|
||||
msgstr "启用Bypass"
|
||||
|
||||
msgid "Vssr Enabled"
|
||||
msgstr "启用Vssr"
|
||||
msgid "Shadowsocksr Servers"
|
||||
msgstr "ShadowSocksR Plus+服务"
|
||||
|
||||
msgid "Passwall Servers"
|
||||
msgstr "Passwall服务"
|
||||
|
||||
msgid "Passwall2 Servers"
|
||||
msgstr "Passwall2服务"
|
||||
|
||||
msgid "Bypass Servers"
|
||||
msgstr "Bypass服务"
|
||||
|
||||
msgid "Vssr Servers"
|
||||
msgstr "Vssr服务"
|
||||
|
||||
msgid "Please select a service"
|
||||
msgstr "请选择一项服务"
|
||||
|
||||
msgid "Speed Test"
|
||||
msgstr "速度测试"
|
||||
|
||||
msgid "Best IP"
|
||||
msgstr "最佳IP"
|
||||
|
||||
msgid "TEST AND APPLY"
|
||||
msgstr "测试并应用"
|
||||
|
||||
msgid "STOP"
|
||||
msgstr "停止"
|
||||
|
||||
msgid "Advanced"
|
||||
msgstr "高级模式"
|
||||
|
||||
msgid "Thread"
|
||||
msgid "线程数"
|
||||
|
||||
msgid "Average Latency Cap"
|
||||
msgstr "平均延迟上限"
|
||||
|
||||
msgid "Average Latency Lower Bound"
|
||||
msgstr "平均延迟下限"
|
||||
|
||||
msgid "IPv6 Enabled"
|
||||
msgstr "启用IPv6"
|
||||
|
||||
msgid "Delayed speed measurement time"
|
||||
msgstr "延迟测速次数"
|
||||
|
||||
msgid "Download speed test time"
|
||||
msgstr "下载测速时间"
|
||||
|
||||
msgid "Number of download speed tests"
|
||||
msgstr "下载测速数量"
|
||||
|
||||
msgid "Disable download speed test"
|
||||
msgstr "禁用下载测速"
|
||||
|
||||
msgid "Port"
|
||||
msgstr "端口"
|
||||
|
||||
msgid "Not recommended"
|
||||
msgstr "不推荐"
|
||||
|
||||
msgid "Provides only one method, if IPv6 is enabled, IPv4 will not be tested"
|
||||
msgstr "IPv4和IPv6只能选一个!!!!!!"
|
||||
|
||||
msgid "<a href=\"https://github.com/XIU2/CloudflareSpeedTest/issues/168\" target=\"_blank\">How to create</a>"
|
||||
msgstr "<a href=\"https://github.com/XIU2/CloudflareSpeedTest/issues/168\" target=\"_blank\">如何创建</a>"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "收集数据中..."
|
||||
|
||||
msgid "Third party applications settings"
|
||||
msgstr "第三方应用设置"
|
||||
|
||||
msgid "Auto refresh"
|
||||
msgstr "自动刷新"
|
||||
|
||||
msgid "Status"
|
||||
msgstr "状态"
|
||||
|
||||
msgid "Proxy Mode"
|
||||
msgstr "代理模式"
|
||||
|
||||
msgid "HOLD"
|
||||
msgstr "保持"
|
||||
|
||||
msgid "GFW List"
|
||||
msgid "GFW列表"
|
||||
|
||||
msgid "CLOSE"
|
||||
msgstr "关闭"
|
||||
|
||||
msgid "during the speed testing, swith to which mode"
|
||||
msgstr "在速度测试期间,切换到哪种模式"
|
||||
|
||||
msgid "DNS"
|
||||
msgstr "DNS"
|
||||
|
||||
msgid "DNS Enabled"
|
||||
msgstr "启用DNS"
|
||||
|
||||
msgid "DNS Type"
|
||||
msgstr "DNS类型"
|
||||
|
||||
msgid "AliyuDNS"
|
||||
msgstr "阿里云DNS"
|
||||
|
||||
msgid "Access Key ID"
|
||||
msgstr "Access Key ID"
|
||||
|
||||
msgid "Access Key Secret"
|
||||
msgstr "Access Key Secret"
|
||||
|
||||
msgid "Main Domain"
|
||||
msgstr "主域名"
|
||||
|
||||
msgid "Sub Domain"
|
||||
msgstr "子域名"
|
||||
|
||||
msgid "For example: test.github.com -> github.com"
|
||||
msgstr "例如: test.github.com 则填: github.com"
|
||||
|
||||
msgid "For example: test.github.com -> test"
|
||||
msgstr "例如: test.github.com, 则填: test"
|
||||
|
||||
msgid "Lines"
|
||||
msgstr "解析线路"
|
||||
|
||||
msgid "default"
|
||||
msgstr "默认"
|
||||
|
||||
msgid "telecom"
|
||||
msgstr "电信"
|
||||
|
||||
msgid "unicom"
|
||||
msgstr "联通"
|
||||
|
||||
msgid "mobile"
|
||||
msgstr "移动"
|
||||
|
||||
msgid "HOST Enabled"
|
||||
msgstr "启用HOST"
|
||||
|
||||
msgid "Domain"
|
||||
msgstr "域名"
|
@ -1,21 +0,0 @@
|
||||
|
||||
config global 'global'
|
||||
option hour '5'
|
||||
option minute '0'
|
||||
option enabled '0'
|
||||
option ipv6_enabled '0'
|
||||
option advanced '0'
|
||||
option tl '200'
|
||||
option tll '40'
|
||||
option custome_url 'https://speed.cloudflare.com/__down?bytes=300000000'
|
||||
option threads '200'
|
||||
option speed '100'
|
||||
|
||||
config servers 'servers'
|
||||
option ssr_enabled '0'
|
||||
option passwall_enabled '0'
|
||||
option passwall2_enabled '0'
|
||||
option bypass_enabled '0'
|
||||
option vssr_enabled '0'
|
||||
option DNS_enabled '0'
|
||||
|
@ -1,59 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "cloudflarespeedtest"
|
||||
}
|
||||
|
||||
add_cron(){
|
||||
local enabled
|
||||
config_get_bool enabled $1 enabled
|
||||
|
||||
del_cron
|
||||
|
||||
if [ $enabled = 1 ] ; then
|
||||
local minute
|
||||
local hour
|
||||
local custome_cors_enabled
|
||||
local custome_cron
|
||||
|
||||
config_get minute $1 minute
|
||||
config_get hour $1 hour
|
||||
config_get_bool custome_cors_enabled $1 custome_cors_enabled
|
||||
config_get custome_cron $1 custome_cron
|
||||
|
||||
if [ $custome_cors_enabled = 1 ] ; then
|
||||
echo "$custome_cron /usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start" >> $CRON_FILE
|
||||
else
|
||||
echo "$minute $hour * * * /usr/bin/cloudflarespeedtest/cloudflarespeedtest.sh start" >> $CRON_FILE
|
||||
fi
|
||||
crontab $CRON_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
del_cron(){
|
||||
sed -i '/cloudflarespeedtest/d' $CRON_FILE
|
||||
/etc/init.d/cron restart
|
||||
}
|
||||
|
||||
stop_instance(){
|
||||
del_cron
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
config_load cloudflarespeedtest
|
||||
config_foreach stop_instance global
|
||||
}
|
||||
start_service() {
|
||||
config_load cloudflarespeedtest
|
||||
config_foreach add_cron global
|
||||
}
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
#!/bin/sh
|
||||
LOG_FILE='/var/log/cloudflarespeedtest.log'
|
||||
|
||||
echolog() {
|
||||
local d="$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
echo -e "$d: $*" >>$LOG_FILE
|
||||
}
|
||||
|
||||
urlencode() {
|
||||
# urlencode url<string>
|
||||
out=''
|
||||
for c in $(echo -n $1 | sed 's/[^\n]/&\n/g'); do
|
||||
case $c in
|
||||
[a-zA-Z0-9._-]) out="$out$c" ;;
|
||||
*) out="$out$(printf '%%%02X' "'$c")" ;;
|
||||
esac
|
||||
done
|
||||
echo -n $out
|
||||
}
|
||||
|
||||
send_request() {
|
||||
# send_request action<string> args<string>
|
||||
local args="AccessKeyId=$ak_id&Action=$1&Format=json&$2&Version=2015-01-09"
|
||||
local hash=$(urlencode $(echo -n "GET&%2F&$(urlencode $args)" | openssl dgst -sha1 -hmac "$ak_sec&" -binary | openssl base64))
|
||||
curl -sSL --connect-timeout 5 "http://alidns.aliyuncs.com/?$args&Signature=$hash"
|
||||
}
|
||||
|
||||
get_recordid() {
|
||||
sed 's/RR/\n/g' | sed -n 's/.*RecordId[^0-9]*\([0-9]*\).*/\1\n/p' | sort -ru | sed /^$/d
|
||||
}
|
||||
|
||||
query_recordid() {
|
||||
send_request "DescribeSubDomainRecords" "SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&SubDomain=$sub_dm.$main_dm&Timestamp=$timestamp&Type=A"
|
||||
}
|
||||
|
||||
update_record() {
|
||||
send_request "UpdateDomainRecord" "Line=$line&RR=$sub_dm&RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=$type&Value=$ip"
|
||||
}
|
||||
|
||||
add_record() {
|
||||
send_request "AddDomainRecord&DomainName=$main_dm" "Line=$line&RR=$sub_dm&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp&Type=$type&Value=$ip"
|
||||
}
|
||||
|
||||
del_record() {
|
||||
send_request "DeleteDomainRecord" "RecordId=$1&SignatureMethod=HMAC-SHA1&SignatureNonce=$timestamp&SignatureVersion=1.0&Timestamp=$timestamp"
|
||||
}
|
||||
|
||||
aliddns() {
|
||||
ak_id=$1
|
||||
ak_sec=$2
|
||||
main_dm=$3
|
||||
sub_dm=$4
|
||||
line=$5
|
||||
isIpv6=$6
|
||||
ip=$7
|
||||
type=A
|
||||
|
||||
if [ $isIpv6 -eq "1" ] ;then
|
||||
type=AAAA
|
||||
fi
|
||||
echo $ip
|
||||
echo $type
|
||||
rrid=`query_recordid | get_recordid`
|
||||
|
||||
if [ -z "$rrid" ]; then
|
||||
rrid=`add_record | get_recordid`
|
||||
echolog "ADD record $rrid"
|
||||
else
|
||||
update_record $rrid
|
||||
echolog "UPDATE record $rrid"
|
||||
fi
|
||||
if [ -z "$rrid" ]; then
|
||||
# failed
|
||||
echolog "# ERROR, Please Check Config/Time"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
timestamp=$(date -u "+%Y-%m-%dT%H%%3A%M%%3A%SZ")
|
||||
|
||||
aliddns "$@"
|
@ -1,318 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
LOG_FILE='/var/log/cloudflarespeedtest.log'
|
||||
IP_FILE='/usr/share/cloudflarespeedtestresult.txt'
|
||||
IPV4_TXT='/usr/share/CloudflareSpeedTest/ip.txt'
|
||||
IPV6_TXT='/usr/share/CloudflareSpeedTest/ipv6.txt'
|
||||
|
||||
function get_global_config(){
|
||||
while [[ "$*" != "" ]]; do
|
||||
eval ${1}='`uci get cloudflarespeedtest.global.$1`' 2>/dev/null
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
function get_servers_config(){
|
||||
while [[ "$*" != "" ]]; do
|
||||
eval ${1}='`uci get cloudflarespeedtest.servers.$1`' 2>/dev/null
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
echolog() {
|
||||
local d="$(date "+%Y-%m-%d %H:%M:%S")"
|
||||
echo -e "$d: $*"
|
||||
echo -e "$d: $*" >>$LOG_FILE
|
||||
}
|
||||
|
||||
function read_config(){
|
||||
get_global_config "enabled" "speed" "custome_url" "threads" "custome_cors_enabled" "custome_cron" "t" "tp" "dt" "dn" "dd" "tl" "tll" "ipv6_enabled" "advanced" "proxy_mode"
|
||||
get_servers_config "ssr_services" "ssr_enabled" "passwall_enabled" "passwall_services" "passwall2_enabled" "passwall2_services" "bypass_enabled" "bypass_services" "vssr_enabled" "vssr_services" "DNS_enabled" "HOST_enabled"
|
||||
}
|
||||
|
||||
function appinit(){
|
||||
ssr_started='';
|
||||
passwall_started='';
|
||||
passwall2_started='';
|
||||
bypass_started='';
|
||||
vssr_started='';
|
||||
}
|
||||
|
||||
function speed_test(){
|
||||
|
||||
rm -rf $LOG_FILE
|
||||
|
||||
command="/usr/bin/cdnspeedtest -sl $((speed*125/1000)) -url ${custome_url} -o ${IP_FILE}"
|
||||
|
||||
if [ $ipv6_enabled -eq "1" ] ;then
|
||||
command="${command} -f ${IPV6_TXT}"
|
||||
else
|
||||
command="${command} -f ${IPV4_TXT}"
|
||||
fi
|
||||
|
||||
if [ $advanced -eq "1" ] ; then
|
||||
command="${command} -tl ${tl} -tll ${tll} -n ${threads} -t ${t} -dt ${dt} -dn ${dn}"
|
||||
if [ $dd -eq "1" ] ; then
|
||||
command="${command} -dd"
|
||||
fi
|
||||
if [ $tp -ne "443" ] ; then
|
||||
command="${command} -tp ${tp}"
|
||||
fi
|
||||
else
|
||||
command="${command} -tl 200 -tll 40 -n 200 -t 4 -dt 10 -dn 1"
|
||||
fi
|
||||
|
||||
appinit
|
||||
|
||||
ssr_original_server=$(uci get shadowsocksr.@global[0].global_server 2>/dev/null)
|
||||
ssr_original_run_mode=$(uci get shadowsocksr.@global[0].run_mode 2>/dev/null)
|
||||
if [ "x${ssr_original_server}" != "xnil" ] && [ "x${ssr_original_server}" != "x" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set shadowsocksr.@global[0].global_server="nil"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set shadowsocksr.@global[0].run_mode="gfw"
|
||||
fi
|
||||
ssr_started='1';
|
||||
uci commit shadowsocksr
|
||||
/etc/init.d/shadowsocksr restart
|
||||
fi
|
||||
|
||||
passwall_server_enabled=$(uci get passwall.@global[0].enabled 2>/dev/null)
|
||||
passwall_original_run_mode=$(uci get passwall.@global[0].tcp_proxy_mode 2>/dev/null)
|
||||
if [ "x${passwall_server_enabled}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set passwall.@global[0].enabled="0"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set passwall.@global[0].tcp_proxy_mode="gfwlist"
|
||||
fi
|
||||
passwall_started='1';
|
||||
uci commit passwall
|
||||
/etc/init.d/passwall restart 2>/dev/null
|
||||
fi
|
||||
|
||||
passwall2_server_enabled=$(uci get passwall2.@global[0].enabled 2>/dev/null)
|
||||
passwall2_original_run_mode=$(uci get passwall2.@global[0].tcp_proxy_mode 2>/dev/null)
|
||||
if [ "x${passwall2_server_enabled}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set passwall2.@global[0].enabled="0"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set passwall2.@global[0].tcp_proxy_mode="gfwlist"
|
||||
fi
|
||||
passwall2_started='1';
|
||||
uci commit passwall2
|
||||
/etc/init.d/passwall2 restart 2>/dev/null
|
||||
fi
|
||||
|
||||
vssr_original_server=$(uci get vssr.@global[0].global_server 2>/dev/null)
|
||||
vssr_original_run_mode=$(uci get vssr.@global[0].run_mode 2>/dev/null)
|
||||
if [ "x${vssr_original_server}" != "xnil" ] && [ "x${vssr_original_server}" != "x" ] ;then
|
||||
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set vssr.@global[0].global_server="nil"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set vssr.@global[0].run_mode="gfw"
|
||||
fi
|
||||
vssr_started='1';
|
||||
uci commit vssr
|
||||
/etc/init.d/vssr restart
|
||||
fi
|
||||
|
||||
bypass_original_server=$(uci get bypass.@global[0].global_server 2>/dev/null)
|
||||
bypass_original_run_mode=$(uci get bypass.@global[0].run_mode 2>/dev/null)
|
||||
if [ "x${bypass_original_server}" != "x" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set bypass.@global[0].global_server=""
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set bypass.@global[0].run_mode="gfw"
|
||||
fi
|
||||
bypass_started='1';
|
||||
uci commit bypass
|
||||
/etc/init.d/bypass restart
|
||||
fi
|
||||
|
||||
echo $command >> $LOG_FILE 2>&1
|
||||
echolog "-----------start----------"
|
||||
$command >> $LOG_FILE 2>&1
|
||||
echolog "-----------end------------"
|
||||
}
|
||||
|
||||
function ip_replace(){
|
||||
|
||||
# 获取最快 IP(从 result.csv 结果文件中获取第一个 IP)
|
||||
bestip=$(sed -n "2,1p" $IP_FILE | awk -F, '{print $1}')
|
||||
if [[ -z "${bestip}" ]]; then
|
||||
echolog "CloudflareST 测速结果 IP 数量为 0,跳过下面步骤..."
|
||||
else
|
||||
host_ip
|
||||
alidns_ip
|
||||
ssr_best_ip
|
||||
vssr_best_ip
|
||||
bypass_best_ip
|
||||
passwall_best_ip
|
||||
passwall2_best_ip
|
||||
restart_app
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
function host_ip() {
|
||||
if [ "x${HOST_enabled}" == "x1" ] ;then
|
||||
get_servers_config "host_domain"
|
||||
HOSTS_LINE=$(echo "$host_domain" | sed 's/,/ /g' | sed "s/^/$bestip /g")
|
||||
host_domain_first=$(echo "$host_domain" | awk -F, '{print $1}')
|
||||
|
||||
if [ -n "$(grep $host_domain_first /etc/hosts)" ]
|
||||
then
|
||||
echo $host_domain_first
|
||||
sed -i".bak" "/$host_domain_first/d" /etc/hosts
|
||||
echo $HOSTS_LINE >> /etc/hosts;
|
||||
else
|
||||
echo $HOSTS_LINE >> /etc/hosts;
|
||||
fi
|
||||
/etc/init.d/dnsmasq reload &>/dev/null
|
||||
echolog "HOST 完成"
|
||||
fi
|
||||
}
|
||||
|
||||
function passwall_best_ip(){
|
||||
if [ "x${passwall_enabled}" == "x1" ] ;then
|
||||
echolog "设置passwall IP"
|
||||
for ssrname in $passwall_services
|
||||
do
|
||||
echo $ssrname
|
||||
uci set passwall.$ssrname.address="${bestip}"
|
||||
done
|
||||
uci commit passwall
|
||||
fi
|
||||
}
|
||||
|
||||
function passwall2_best_ip(){
|
||||
if [ "x${passwall2_enabled}" == "x1" ] ;then
|
||||
echolog "设置passwall2 IP"
|
||||
for ssrname in $passwall2_services
|
||||
do
|
||||
echo $ssrname
|
||||
uci set passwall2.$ssrname.address="${bestip}"
|
||||
done
|
||||
uci commit passwall2
|
||||
fi
|
||||
}
|
||||
|
||||
function ssr_best_ip(){
|
||||
if [ "x${ssr_enabled}" == "x1" ] ;then
|
||||
echolog "设置ssr IP"
|
||||
for ssrname in $ssr_services
|
||||
do
|
||||
echo $ssrname
|
||||
uci set shadowsocksr.$ssrname.server="${bestip}"
|
||||
uci set shadowsocksr.$ssrname.ip="${bestip}"
|
||||
done
|
||||
uci commit shadowsocksr
|
||||
fi
|
||||
}
|
||||
|
||||
function vssr_best_ip(){
|
||||
if [ "x${vssr_enabled}" == "x1" ] ;then
|
||||
echolog "设置Vssr IP"
|
||||
for ssrname in $vssr_services
|
||||
do
|
||||
echo $ssrname
|
||||
uci set vssr.$ssrname.server="${bestip}"
|
||||
done
|
||||
uci commit vssr
|
||||
fi
|
||||
}
|
||||
|
||||
function bypass_best_ip(){
|
||||
if [ "x${bypass_enabled}" == "x1" ] ;then
|
||||
echolog "设置Bypass IP"
|
||||
for ssrname in $bypass_services
|
||||
do
|
||||
echo $ssrname
|
||||
uci set bypass.$ssrname.server="${bestip}"
|
||||
done
|
||||
uci commit bypass
|
||||
fi
|
||||
}
|
||||
|
||||
function restart_app(){
|
||||
if [ "x${ssr_started}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set shadowsocksr.@global[0].global_server="${ssr_original_server}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set shadowsocksr.@global[0].run_mode="${ssr_original_run_mode}"
|
||||
fi
|
||||
uci commit shadowsocksr
|
||||
/etc/init.d/shadowsocksr restart &>/dev/null
|
||||
echolog "ssr重启完成"
|
||||
fi
|
||||
|
||||
if [ "x${passwall_started}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set passwall.@global[0].enabled="${passwall_server_enabled}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set passwall.@global[0].tcp_proxy_mode="${passwall_original_run_mode}"
|
||||
fi
|
||||
uci commit passwall
|
||||
/etc/init.d/passwall restart 2>/dev/null
|
||||
echolog "passwall重启完成"
|
||||
fi
|
||||
|
||||
if [ "x${passwall2_started}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set passwall2.@global[0].enabled="${passwall2_server_enabled}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set passwall2.@global[0].tcp_proxy_mode="${passwall2_original_run_mode}"
|
||||
fi
|
||||
uci commit passwall2
|
||||
/etc/init.d/passwall2 restart 2>/dev/null
|
||||
echolog "passwall2重启完成"
|
||||
fi
|
||||
|
||||
if [ "x${vssr_started}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set vssr.@global[0].global_server="${vssr_original_server}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set vssr.@global[0].run_mode="${vssr_original_run_mode}"
|
||||
fi
|
||||
uci commit vssr
|
||||
/etc/init.d/vssr restart &>/dev/null
|
||||
echolog "Vssr重启完成"
|
||||
fi
|
||||
|
||||
if [ "x${bypass_started}" == "x1" ] ;then
|
||||
if [ $proxy_mode == "close" ] ;then
|
||||
uci set bypass.@global[0].global_server="${bypass_original_server}"
|
||||
elif [ $proxy_mode == "gfw" ] ;then
|
||||
uci set bypass.@global[0].run_mode="${bypass_original_run_mode}"
|
||||
fi
|
||||
uci commit bypass
|
||||
/etc/init.d/bypass restart &>/dev/null
|
||||
echolog "Bypass重启完成"
|
||||
fi
|
||||
}
|
||||
|
||||
function alidns_ip(){
|
||||
if [ "x${DNS_enabled}" == "x1" ] ;then
|
||||
get_servers_config "DNS_type" "app_key" "app_secret" "main_domain" "sub_domain" "line"
|
||||
if [ $DNS_type == "aliyu" ] ;then
|
||||
for sub in $sub_domain
|
||||
do
|
||||
/usr/bin/cloudflarespeedtest/aliddns.sh $app_key $app_secret $main_domain $sub $line $ipv6_enabled $bestip
|
||||
echolog "更新域名${sub}阿里云DNS完成"
|
||||
sleep 1s
|
||||
done
|
||||
fi
|
||||
echo "aliyun done"
|
||||
fi
|
||||
}
|
||||
|
||||
read_config
|
||||
|
||||
# 启动参数
|
||||
if [ "$1" ] ;then
|
||||
[ $1 == "start" ] && speed_test && ip_replace
|
||||
[ $1 == "test" ] && speed_test
|
||||
[ $1 == "replace" ] && ip_replace
|
||||
exit
|
||||
fi
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"luci-app-cloudflarespeedtest": {
|
||||
"description": "Grant UCI access for luci-app-cloudflarespeedtest",
|
||||
"read": {
|
||||
"uci": [ "cloudflarespeedtest" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "cloudflarespeedtest" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-mosdns
|
||||
PKG_VERSION:=1.5.4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
LUCI_TITLE:=LuCI Support for mosdns
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+mosdns +jsonfilter +luci-compat +curl +v2ray-geoip +v2ray-geosite +v2dat
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/mosdns
|
||||
/etc/mosdns/cache.dump
|
||||
/etc/mosdns/config_custom.yaml
|
||||
/etc/mosdns/rule
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
#!/bin/sh
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
sysctl -p /etc/sysctl.d/20-mosdns-buffer-increase.conf
|
||||
exit 0
|
||||
}
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
@ -1,53 +0,0 @@
|
||||
local sys = require "luci.sys"
|
||||
local http = require "luci.http"
|
||||
|
||||
module("luci.controller.mosdns", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/mosdns") then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "services", "mosdns"}, alias("admin", "services", "mosdns", "basic"), _("MosDNS"), 30)
|
||||
page.dependent = true
|
||||
page.acl_depends = { "luci-app-mosdns" }
|
||||
|
||||
entry({"admin", "services", "mosdns", "basic"}, cbi("mosdns/basic"), _("Basic Setting"), 1).leaf = true
|
||||
entry({"admin", "services", "mosdns", "rule_list"}, cbi("mosdns/rule_list"), _("Rule List"), 2).leaf = true
|
||||
entry({"admin", "services", "mosdns", "update"}, cbi("mosdns/update"), _("Geodata Update"), 3).leaf = true
|
||||
entry({"admin", "services", "mosdns", "log"}, cbi("mosdns/log"), _("Logs"), 4).leaf = true
|
||||
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "get_log"}, call("get_log")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "clear_log"}, call("clear_log")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "geo_update"}, call("geo_update")).leaf = true
|
||||
entry({"admin", "services", "mosdns", "flush_cache"}, call("flush_cache")).leaf = true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e = {}
|
||||
e.running = sys.call("pgrep -f mosdns >/dev/null") == 0
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
end
|
||||
|
||||
function get_log()
|
||||
http.write(sys.exec("cat $(/usr/share/mosdns/mosdns.sh logfile)"))
|
||||
end
|
||||
|
||||
function clear_log()
|
||||
sys.call("cat /dev/null > $(/usr/share/mosdns/mosdns.sh logfile)")
|
||||
end
|
||||
|
||||
function geo_update()
|
||||
local e = {}
|
||||
e.updating = sys.call("/usr/share/mosdns/mosdns.sh geodata >/dev/null") == 0
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
end
|
||||
|
||||
function flush_cache()
|
||||
local e = {}
|
||||
e.flushing = sys.call("/usr/share/mosdns/mosdns.sh flush >/dev/null") == 0
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(e)
|
||||
end
|
@ -1,210 +0,0 @@
|
||||
local fs = require "nixio.fs"
|
||||
local sys = require "luci.sys"
|
||||
|
||||
if fs.access("/usr/bin/mosdns") then
|
||||
mosdns_version = sys.exec("/usr/share/mosdns/mosdns.sh version")
|
||||
else
|
||||
mosdns_version = "Unknown Version"
|
||||
end
|
||||
m = Map("mosdns")
|
||||
m.title = translate("MosDNS") .. " " .. mosdns_version
|
||||
m.description = translate("MosDNS is a 'programmable' DNS forwarder.")
|
||||
|
||||
m:section(SimpleSection).template = "mosdns/mosdns_status"
|
||||
|
||||
s = m:section(TypedSection, "mosdns")
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("basic", translate("Basic Options"))
|
||||
|
||||
o = s:taboption("basic", Flag, "enabled", translate("Enabled"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("basic", ListValue, "configfile", translate("Config File"))
|
||||
o:value("/etc/mosdns/config.yaml", translate("Default Config"))
|
||||
o:value("/etc/mosdns/config_custom.yaml", translate("Custom Config"))
|
||||
o.default = "/etc/mosdns/config.yaml"
|
||||
|
||||
o = s:taboption("basic", Value, "listen_port", translate("Listen port"))
|
||||
o.datatype = "and(port,min(1))"
|
||||
o.default = 5335
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("basic", ListValue, "log_level", translate("Log Level"))
|
||||
o:value("debug", translate("Debug"))
|
||||
o:value("info", translate("Info"))
|
||||
o:value("warn", translate("Warning"))
|
||||
o:value("error", translate("Error"))
|
||||
o.default = "info"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("basic", Value, "logfile", translate("Log File"))
|
||||
o.placeholder = "/tmp/mosdns.log"
|
||||
o.default = "/tmp/mosdns.log"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("basic", Flag, "redirect", translate("DNS Forward"), translate("Forward Dnsmasq Domain Name resolution requests to MosDNS"))
|
||||
o.default = true
|
||||
|
||||
o = s:taboption("basic", Flag, "custom_local_dns", translate("Local DNS"), translate("Follow WAN interface DNS if not enabled"))
|
||||
o:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||
o.default = false
|
||||
o = s:taboption("basic", DynamicList, "local_dns", translate("Upstream DNS servers"))
|
||||
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("https://doh.pub/dns-query", "DNSPod DoH")
|
||||
o:value("https://dns.alidns.com/dns-query", "AliDNS DoH")
|
||||
o:value("https://doh.360.cn/dns-query", "360DNS DoH")
|
||||
o:depends("custom_local_dns", "1")
|
||||
|
||||
o = s:taboption("basic", DynamicList, "remote_dns", translate("Remote 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: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:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("basic", ListValue, "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.default = "119.29.29.29"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
s:tab("advanced", translate("Advanced Options"))
|
||||
|
||||
o = s:taboption("advanced", Value, "concurrent", translate("Concurrent"), translate("DNS query request concurrency, The number of upstream DNS servers that are allowed to initiate requests at the same time"))
|
||||
o.datatype = "and(uinteger,min(1),max(3))"
|
||||
o.default = "1"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "max_conns", translate("Maximum Connections"), translate("Set the Maximum connections for DoH and pipeline's TCP/DoT, Except for the HTTP/3 protocol"))
|
||||
o.datatype = "and(uinteger,min(1))"
|
||||
o.default = "2"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "idle_timeout", translate("Idle Timeout"), translate("DoH/TCP/DoT Connection Multiplexing idle timeout (default 30 seconds)"))
|
||||
o.datatype = "and(uinteger,min(1))"
|
||||
o.default = "30"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "enable_pipeline", translate("TCP/DoT Connection Multiplexing"), translate("Enable TCP/DoT RFC 7766 new Query Pipelining connection multiplexing mode"))
|
||||
o.rmempty = false
|
||||
o.default = false
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "insecure_skip_verify", translate("Disable TLS Certificate"), translate("Disable TLS Servers certificate validation, Can be useful if system CA certificate expires or the system time is out of order"))
|
||||
o.rmempty = false
|
||||
o.default = false
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "enable_http3", translate("Enable HTTP/3"), translate("Enable DoH HTTP/3 protocol support for remote DNS, Upstream DNS server support is required (Experimental)"))
|
||||
o.rmempty = false
|
||||
o.default = false
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "enable_ecs_remote", translate("Enable EDNS client subnet"), translate("Add the EDNS Client Subnet option (ECS) to Remote DNS") .. '<br />' .. translate("MosDNS will auto identify the IP address subnet segment of your remote connection (.0/24)") .. '<br />' .. translate("If your remote access network changes, May need restart MosDNS to update the ECS request address"))
|
||||
o.rmempty = false
|
||||
o.default = false
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "cache_size", translate("DNS Cache Size"))
|
||||
o.datatype = "and(uinteger,min(0))"
|
||||
o.default = "20000"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "cache_survival_time", translate("Cache Survival Time"))
|
||||
o.datatype = "and(uinteger,min(0))"
|
||||
o.default = "86400"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "dump_file", translate("Cache Dump"), translate("Save the cache locally and reload the cache dump on the next startup"))
|
||||
o.rmempty = false
|
||||
o.default = false
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "dump_interval", translate("Auto Save Cache Interval"))
|
||||
o.datatype = "and(uinteger,min(0))"
|
||||
o.default = "600"
|
||||
o:depends("dump_file", "1")
|
||||
|
||||
o = s:taboption("advanced", Value, "minimal_ttl", translate("Minimum TTL"), translate("Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating no modification"))
|
||||
o.datatype = "and(uinteger,min(0),max(604800))"
|
||||
o.default = "0"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Value, "maximum_ttl", translate("Maximum TTL"), translate("Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating no modification"))
|
||||
o.datatype = "and(uinteger,min(0),max(604800))"
|
||||
o.default = "0"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("advanced", Flag, "adblock", translate("Enable DNS ADblock"))
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
o.default = false
|
||||
|
||||
o = s:taboption("advanced", Value, "ad_source", translate("ADblock Source"), translate("When using custom rule sources, use the rule types supported by MosDNS"))
|
||||
o:depends("adblock", "1")
|
||||
o.default = "https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt"
|
||||
o:value("geosite.dat", "v2ray-geosite")
|
||||
o:value("https://raw.githubusercontent.com/privacy-protection-tools/anti-AD/master/anti-ad-domains.txt", "anti-AD")
|
||||
o:value("https://raw.githubusercontent.com/ookangzheng/dbl-oisd-nl/master/dbl_light.txt", "oisd (small)")
|
||||
o:value("https://raw.githubusercontent.com/ookangzheng/dbl-oisd-nl/master/dbl.txt", "oisd (big)")
|
||||
o:value("https://raw.githubusercontent.com/QiuSimons/openwrt-mos/master/dat/serverlist.txt", "QiuSimons/openwrt-mos")
|
||||
|
||||
o = s:taboption("basic", Button, "_reload", translate("Reload Service"), translate("Reload service to take effect of new configuration"))
|
||||
o.write = function()
|
||||
sys.exec("/etc/init.d/mosdns reload")
|
||||
end
|
||||
o:depends("configfile", "/etc/mosdns/config_custom.yaml")
|
||||
|
||||
o = s:taboption("basic", TextValue, "manual-config")
|
||||
o.description = translate("<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.</strong></font>")
|
||||
o.template = "cbi/tvalue"
|
||||
o.rows = 25
|
||||
o:depends("configfile", "/etc/mosdns/config_custom.yaml")
|
||||
|
||||
function o.cfgvalue(self, section)
|
||||
return fs.readfile("/etc/mosdns/config_custom.yaml")
|
||||
end
|
||||
|
||||
function o.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
fs.writefile("/etc/mosdns/config_custom.yaml", value)
|
||||
end
|
||||
|
||||
s:tab("api", translate("API Options"))
|
||||
|
||||
o = s:taboption("api", Value, "listen_port_api", translate("API Listen port"))
|
||||
o.datatype = "and(port,min(1))"
|
||||
o.default = 9091
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
o = s:taboption("api", Button, "flush_cache", translate("Flush Cache"), translate("Flushing Cache will clear any IP addresses or DNS records from MosDNS cache"))
|
||||
o.rawhtml = true
|
||||
o.template = "mosdns/mosdns_flush_cache"
|
||||
o:depends("configfile", "/etc/mosdns/config.yaml")
|
||||
|
||||
s:tab("geodata", translate("GeoData Export"))
|
||||
|
||||
o = s:taboption("geodata", DynamicList, "geosite_tags", translate("GeoSite Tags"), translate("Enter the GeoSite.dat category to be exported, Allow add multiple tags") .. '<br />' .. translate("Export directory: /var/mosdns"))
|
||||
o:depends("configfile", "/etc/mosdns/config_custom.yaml")
|
||||
|
||||
o = s:taboption("geodata", DynamicList, "geoip_tags", translate("GeoIP Tags"), translate("Enter the GeoIP.dat category to be exported, Allow add multiple tags") .. '<br />' .. translate("Export directory: /var/mosdns"))
|
||||
o:depends("configfile", "/etc/mosdns/config_custom.yaml")
|
||||
|
||||
return m
|
@ -1,5 +0,0 @@
|
||||
m = Map("mosdns")
|
||||
|
||||
m:append(Template("mosdns/mosdns_log"))
|
||||
|
||||
return m
|
@ -1,99 +0,0 @@
|
||||
local datatypes = require "luci.cbi.datatypes"
|
||||
|
||||
local white_list_file = "/etc/mosdns/rule/whitelist.txt"
|
||||
local block_list_file = "/etc/mosdns/rule/blocklist.txt"
|
||||
local grey_list_file = "/etc/mosdns/rule/greylist.txt"
|
||||
local hosts_list_file = "/etc/mosdns/rule/hosts.txt"
|
||||
local redirect_list_file = "/etc/mosdns/rule/redirect.txt"
|
||||
local local_ptr_file = "/etc/mosdns/rule/local-ptr.txt"
|
||||
local ddns_list_file = "/etc/mosdns/rule/ddnslist.txt"
|
||||
|
||||
m = Map("mosdns")
|
||||
|
||||
s = m:section(TypedSection, "mosdns", translate("Rule Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("white_list", translate("White Lists"))
|
||||
s:tab("block_list", translate("Block Lists"))
|
||||
s:tab("grey_list", translate("Grey Lists"))
|
||||
s:tab("ddns_list", translate("DDNS Lists"))
|
||||
s:tab("hosts_list", translate("Hosts"))
|
||||
s:tab("redirect_list", translate("Redirect"))
|
||||
s:tab("local_ptr_list", translate("Block PTR"))
|
||||
|
||||
o = s:taboption("white_list", TextValue, "whitelist", "", "<font color='red'>" .. translate("These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(white_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(white_list_file , value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(white_list_file , "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("block_list", TextValue, "blocklist", "", "<font color='red'>" .. translate("These domains are blocked from DNS resolution. Please input the domain names of websites, every line can input only one website domain. For example: baidu.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(block_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(block_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(block_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("grey_list", TextValue, "greylist", "", "<font color='red'>" .. translate("These domains are always resolved using remote DNS. Please input the domain names of websites, every line can input only one website domain. For example: google.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(grey_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(grey_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(grey_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("ddns_list", TextValue, "ddns", "", "<font color='red'>" .. translate("These domains are always resolved using local DNS. And force TTL 5 seconds, DNS resolution results will not enter the cache. For example: myddns.example.com.") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(ddns_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(ddns_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(ddns_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("hosts_list", TextValue, "hosts", "", "<font color='red'>" .. translate("Hosts For example: baidu.com 10.0.0.1") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(hosts_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(hosts_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(hosts_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("redirect_list", TextValue, "redirect", "", "<font color='red'>" .. translate("The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(redirect_list_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(redirect_list_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(redirect_list_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
o = s:taboption("local_ptr_list", TextValue, "local_ptr", "", "<font color='red'>" .. translate("These domains are blocked from PTR requests") .. "</font>" .. "<font color='#00bd3e'>" .. translate("<br>The list of rules only apply to 'Default Config' profiles.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return nixio.fs.readfile(local_ptr_file) or "" end
|
||||
o.write = function(self, section, value) nixio.fs.writefile(local_ptr_file, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) nixio.fs.writefile(local_ptr_file, "") end
|
||||
o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
local apply = luci.http.formvalue("cbi.apply")
|
||||
if apply then
|
||||
luci.sys.exec("/etc/init.d/mosdns reload")
|
||||
end
|
||||
|
||||
return m
|
@ -1,31 +0,0 @@
|
||||
m = Map("mosdns")
|
||||
|
||||
s = m:section(TypedSection, "mosdns", translate("Update GeoIP & GeoSite dat"))
|
||||
s.addremove = false
|
||||
s.anonymous = true
|
||||
|
||||
enable = s:option(Flag, "geo_auto_update", translate("Enable Auto Database Update"))
|
||||
enable.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "geo_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, "geo_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, "geo_update_database", translate("Database Update"))
|
||||
data_update.rawhtml = true
|
||||
data_update.template = "mosdns/geo_update"
|
||||
|
||||
return m
|
@ -1,34 +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", "mosdns", "geo_update")%>',
|
||||
{ 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%>';
|
||||
}
|
||||
);
|
||||
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,34 +0,0 @@
|
||||
<%+cbi/valueheader%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function flush_cache(btn, dataname)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Flushing...%> ';
|
||||
st=dataname;
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "mosdns", "flush_cache")%>',
|
||||
{ set:st },
|
||||
function(x,data)
|
||||
{
|
||||
var tb = document.getElementById(dataname+'-status');
|
||||
if (tb)
|
||||
{
|
||||
switch (data.flushing)
|
||||
{
|
||||
case true:
|
||||
tb.innerHTML = "<font color='green'>" + "<%:Flushing Success%>" + "</font>";
|
||||
break;
|
||||
case false:
|
||||
tb.innerHTML = "<font color='red'>" + "<%:Flushing Failed, Please check if MosDNS is enabled%>" + "</font>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:Flush Cache%>';
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Flush Cache%>" onclick="return flush_cache(this,'<%=self.option%>')" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
<%+cbi/valuefooter%>
|
@ -1,29 +0,0 @@
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clear_log(btn) {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[mosdns]], [[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]], [[mosdns]], [[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]], [[mosdns]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('mosdns_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b style=color:green>MosDNS <%:RUNNING%></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b style=color:red>MosDNS <%:NOT RUNNING%></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>
|
||||
.mar-10 {
|
||||
margin-left: 50px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="mosdns_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -1,305 +0,0 @@
|
||||
msgid "Basic Setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Basic Options"
|
||||
msgstr "基本选项"
|
||||
|
||||
msgid "Advanced Options"
|
||||
msgstr "高级选项"
|
||||
|
||||
msgid "API Options"
|
||||
msgstr "API 选项"
|
||||
|
||||
msgid "MosDNS is a 'programmable' DNS forwarder."
|
||||
msgstr "MosDNS 是一个插件化的 DNS 转发/分流器。"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "获取数据中..."
|
||||
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Listen port"
|
||||
msgstr "监听端口"
|
||||
|
||||
msgid "API Listen port"
|
||||
msgstr "API 监听端口"
|
||||
|
||||
msgid "Flush Cache"
|
||||
msgstr "刷新缓存"
|
||||
|
||||
msgid "Flushing Cache will clear any IP addresses or DNS records from MosDNS cache"
|
||||
msgstr "刷新缓存会清空 MosDNS 所有 IP 地址和 DNS 解析缓存"
|
||||
|
||||
msgid "Flushing..."
|
||||
msgstr "正在刷新..."
|
||||
|
||||
msgid "Flushing Success"
|
||||
msgstr "刷新成功"
|
||||
|
||||
msgid "Flushing Failed, Please check if MosDNS is enabled"
|
||||
msgstr "刷新失败,请检查 MosDNS 是否已启用"
|
||||
|
||||
msgid "Log Level"
|
||||
msgstr "日志等级"
|
||||
|
||||
msgid "DNS Forward"
|
||||
msgstr "DNS 转发"
|
||||
|
||||
msgid "Forward Dnsmasq Domain Name resolution requests to MosDNS"
|
||||
msgstr "将 Dnsmasq 域名解析请求转发到 MosDNS 服务器"
|
||||
|
||||
msgid "Enable DNS ADblock"
|
||||
msgstr "启用 DNS 广告过滤"
|
||||
|
||||
msgid "ADblock Source"
|
||||
msgstr "广告过滤规则来源"
|
||||
|
||||
msgid "When using custom rule sources, use the rule types supported by MosDNS"
|
||||
msgstr "使用自定义规则来源时,请使用 MosDNS 支持的规则类型"
|
||||
|
||||
msgid "Reload Service"
|
||||
msgstr "重载服务"
|
||||
|
||||
msgid "Reload service to take effect of new configuration"
|
||||
msgstr "重载 MosDNS 服务生效配置文件"
|
||||
|
||||
msgid "<font color=\"ff0000\"><strong>View the Custom YAML Configuration file used by this MosDNS. You can edit it as you own need.</strong></font>"
|
||||
msgstr "<font color=\"ff0000\"><strong>注意!此页的更改仅当配置文件为 “自定义” 时才会生效</strong></font>"
|
||||
|
||||
msgid "Geodata Update"
|
||||
msgstr "更新数据库"
|
||||
|
||||
msgid "Update GeoIP & GeoSite dat"
|
||||
msgstr "更新广告规则、GeoIP & GeoSite 数据库"
|
||||
|
||||
msgid "Update Time"
|
||||
msgstr "更新时间"
|
||||
|
||||
msgid "Update Cycle"
|
||||
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 "Database Update"
|
||||
msgstr "数据库更新"
|
||||
|
||||
msgid "Check And Update"
|
||||
msgstr "检查并更新"
|
||||
|
||||
msgid "Enable Auto Database Update"
|
||||
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 "Local DNS"
|
||||
msgstr "本地 DNS"
|
||||
|
||||
msgid "Follow WAN interface DNS if not enabled"
|
||||
msgstr "不启用则使用 WAN 接口 DNS"
|
||||
|
||||
msgid "Upstream DNS servers"
|
||||
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 "Remote DNS"
|
||||
msgstr "远程 DNS"
|
||||
|
||||
msgid "Concurrent"
|
||||
msgstr "DNS 服务器并发数(默认 1)"
|
||||
|
||||
msgid "DNS query request concurrency, The number of upstream DNS servers that are allowed to initiate requests at the same time"
|
||||
msgstr "DNS 查询请求并发数,允许同时发起请求的上游 DNS 服务器数量"
|
||||
|
||||
msgid "Maximum Connections"
|
||||
msgstr "最大连接数(默认 2)"
|
||||
|
||||
msgid "Set the Maximum connections for DoH and pipeline's TCP/DoT, Except for the HTTP/3 protocol"
|
||||
msgstr "设置 DoH 和已启用 Query Pipelining 连接复用模式的 TCP/DoT 最大连接数,HTTP/3 协议除外"
|
||||
|
||||
msgid "Idle Timeout"
|
||||
msgstr "空闲超时"
|
||||
|
||||
msgid "DoH/TCP/DoT Connection Multiplexing idle timeout (default 30 seconds)"
|
||||
msgstr "DoH/TCP/DoT 连接复用空闲保持时间(默认 30 秒)"
|
||||
|
||||
msgid "TCP/DoT Connection Multiplexing"
|
||||
msgstr "TCP/DoT 连接复用"
|
||||
|
||||
msgid "Enable TCP/DoT RFC 7766 new Query Pipelining connection multiplexing mode"
|
||||
msgstr "启用 TCP/DoT RFC 7766 新型 Query Pipelining 连接复用模式"
|
||||
|
||||
msgid "Disable TLS Certificate"
|
||||
msgstr "禁用 TLS 证书"
|
||||
|
||||
msgid "Disable TLS Servers certificate validation, Can be useful if system CA certificate expires or the system time is out of order"
|
||||
msgstr "禁用 TLS 服务器证书验证,当系统 CA 证书过期或系统时间错乱时,本选项可能会有用"
|
||||
|
||||
msgid "Enable HTTP/3"
|
||||
msgstr "启用 HTTP/3"
|
||||
|
||||
msgid "Enable DoH HTTP/3 protocol support for remote DNS, Upstream DNS server support is required (Experimental)"
|
||||
msgstr "为远程 DNS 启用 DoH HTTP/3 协议支持,需要上游 DNS 服务器支持(实验性,谨慎启用该功能)"
|
||||
|
||||
msgid "Enable EDNS client subnet"
|
||||
msgstr "启用 EDNS 客户端子网"
|
||||
|
||||
msgid "Add the EDNS Client Subnet option (ECS) to Remote DNS"
|
||||
msgstr "在远程 DNS 请求中加入 EDNS 客户端子网(即 ECS)选项(需要上游 DNS 服务器支持)"
|
||||
|
||||
msgid "MosDNS will auto identify the IP address subnet segment of your remote connection (.0/24)"
|
||||
msgstr "MosDNS 将会自动获取您访问远程连接时使用的 IP 子网段(.0/24)"
|
||||
|
||||
msgid "If your remote access network changes, May need restart MosDNS to update the ECS request address"
|
||||
msgstr "如果您的远程访问网络发生改变时可能需要重启 MosDNS 以更新 ECS 请求地址"
|
||||
|
||||
msgid "DNS Cache Size"
|
||||
msgstr "DNS 缓存大小(条)"
|
||||
|
||||
msgid "Cache Survival Time"
|
||||
msgstr "缓存生存时间(秒)"
|
||||
|
||||
msgid "Cache Dump"
|
||||
msgstr "自动保存缓存"
|
||||
|
||||
msgid "Save the cache locally and reload the cache dump on the next startup"
|
||||
msgstr "保存缓存到本地文件,以供下次启动时重新载入使用"
|
||||
|
||||
msgid "Auto Save Cache Interval"
|
||||
msgstr "自动保存缓存间隔(秒)"
|
||||
|
||||
msgid "Minimum TTL"
|
||||
msgstr "覆盖最小 TTL 值(默认 0)"
|
||||
|
||||
msgid "Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating no modification"
|
||||
msgstr "修改 DNS 应答结果的最小 TTL 值 (秒),0 表示不修改"
|
||||
|
||||
msgid "Maximum TTL"
|
||||
msgstr "覆盖最大 TTL 值(默认 0)"
|
||||
|
||||
msgid "Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating no modification"
|
||||
msgstr "修改 DNS 应答结果的最大 TTL 值(秒),0 表示不修改"
|
||||
|
||||
msgid "Logs"
|
||||
msgstr "日志"
|
||||
|
||||
msgid "Clear logs"
|
||||
msgstr "清空日志"
|
||||
|
||||
msgid "Rule List"
|
||||
msgstr "规则列表"
|
||||
|
||||
msgid "Rule Settings"
|
||||
msgstr "自定义规则列表"
|
||||
|
||||
msgid "<br>The list of rules only apply to 'Default Config' profiles."
|
||||
msgstr "<br>规则列表仅适用于 “内置预设” 配置文件"
|
||||
|
||||
msgid "White Lists"
|
||||
msgstr "白名单"
|
||||
|
||||
msgid "These domain names allow DNS resolution with the highest priority. Please input the domain names of websites, every line can input only one website domain. For example: hm.baidu.com."
|
||||
msgstr "加入的域名始终允许使用 “本地 DNS” 进行解析,且优先级最高(每个域名一行,支持域名匹配规则)"
|
||||
|
||||
msgid "Block Lists"
|
||||
msgstr "黑名单"
|
||||
|
||||
msgid "These domains are blocked from DNS resolution. Please input the domain names of websites, every line can input only one website domain. For example: baidu.com."
|
||||
msgstr "加入的域名将屏蔽 DNS 解析(每个域名一行,支持域名匹配规则)"
|
||||
|
||||
msgid "Grey Lists"
|
||||
msgstr "灰名单"
|
||||
|
||||
msgid "These domains are always resolved using remote DNS. Please input the domain names of websites, every line can input only one website domain. For example: google.com."
|
||||
msgstr "加入的域名始终使用 “远程 DNS” 进行解析(每个域名一行,支持域名匹配规则)"
|
||||
|
||||
msgid "DDNS Lists"
|
||||
msgstr "DDNS 域名"
|
||||
|
||||
msgid "These domains are always resolved using local DNS. And force TTL 5 seconds, DNS resolution results will not enter the cache. For example: myddns.example.com."
|
||||
msgstr "加入的域名始终使用 “本地 DNS” 进行解析,并且强制 TTL 5 秒,解析结果不会进入缓存(每个域名一行,支持域名匹配规则)"
|
||||
|
||||
msgid "Hosts For example: baidu.com 10.0.0.1"
|
||||
msgstr "自定义 Hosts 重写,如:baidu.com 10.0.0.1(每个规则一行)"
|
||||
|
||||
msgid "Redirect"
|
||||
msgstr "重定向"
|
||||
|
||||
msgid "The domain name to redirect the request to. Requests domain A, but returns records for domain B. example: a.com b.com"
|
||||
msgstr "重定向请求的域名。请求域名 A,但返回域名 B 的记录,如:baidu.com qq.com(每个规则一行)"
|
||||
|
||||
msgid "Block PTR"
|
||||
msgstr "PTR 黑名单"
|
||||
|
||||
msgid "These domains are blocked from PTR requests"
|
||||
msgstr "加入的域名将阻止 PTR 请求(每个域名一行,支持域名匹配规则)"
|
||||
|
||||
msgid "GeoData Export"
|
||||
msgstr "GeoData 导出"
|
||||
|
||||
msgid "GeoSite Tags"
|
||||
msgstr "GeoSite 标签"
|
||||
|
||||
msgid "Enter the GeoSite.dat category to be exported, Allow add multiple tags"
|
||||
msgstr "填写需要导出的 GeoSite.dat 类别条目,允许添加多个标签"
|
||||
|
||||
msgid "GeoIP Tags"
|
||||
msgstr "GeoIP 标签"
|
||||
|
||||
msgid "Enter the GeoIP.dat category to be exported, Allow add multiple tags"
|
||||
msgstr "输入需要导出的 GeoIP.dat 类别条目,允许添加多个标签"
|
||||
|
||||
msgid "Export directory: /var/mosdns"
|
||||
msgstr "导出目录:/var/mosdns"
|
@ -1 +0,0 @@
|
||||
zh-cn
|
@ -1,29 +0,0 @@
|
||||
|
||||
config mosdns 'config'
|
||||
option enabled '0'
|
||||
option listen_port '5335'
|
||||
option geo_auto_update '0'
|
||||
option geo_update_week_time '*'
|
||||
option geo_update_day_time '2'
|
||||
option redirect '1'
|
||||
option adblock '0'
|
||||
option configfile '/etc/mosdns/config.yaml'
|
||||
option log_level 'info'
|
||||
option logfile '/tmp/mosdns.log'
|
||||
option cache_size '20000'
|
||||
option cache_survival_time '86400'
|
||||
option dump_file '0'
|
||||
option concurrent '1'
|
||||
option max_conns '2'
|
||||
option idle_timeout '30'
|
||||
option minimal_ttl '0'
|
||||
option maximum_ttl '0'
|
||||
option custom_local_dns '0'
|
||||
option enable_pipeline '0'
|
||||
option insecure_skip_verify '0'
|
||||
option enable_http3 '0'
|
||||
option listen_port_api '9091'
|
||||
option bootstrap_dns '119.29.29.29'
|
||||
list remote_dns 'tls://8.8.8.8'
|
||||
list remote_dns 'tls://1.1.1.1'
|
||||
|
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
[ "$ACTION" = ifup ] && /etc/init.d/mosdns restart
|
@ -1,188 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2020-2022, IrineSistiana
|
||||
#
|
||||
# Copyright (C) 2023, sbwml <admin@cooluc.com>
|
||||
#
|
||||
# This file is part of mosdns.
|
||||
#
|
||||
# mosdns is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# mosdns is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
PROG=/usr/bin/mosdns
|
||||
CONF=$(uci -q get mosdns.config.configfile)
|
||||
CRON_FILE=/etc/crontabs/root
|
||||
DUMP_FILE=/etc/mosdns/cache.dump
|
||||
DUMP_FILE_DEFAULT=/usr/share/mosdns/cache.dump
|
||||
DEFAULT_CONF=/usr/share/mosdns/default.yaml
|
||||
MOSDNS_SCRIPT=/usr/share/mosdns/mosdns.sh
|
||||
|
||||
get_config() {
|
||||
config_get enabled $1 enabled 0
|
||||
config_get adblock $1 adblock 0
|
||||
config_get ad_source $1 ad_source ""
|
||||
config_get cache_size $1 cache_size 20000
|
||||
config_get cache_survival_time $1 cache_survival_time 86400
|
||||
config_get dump_file $1 dump_file 0
|
||||
config_get dump_interval $1 dump_interval 600
|
||||
config_get enable_pipeline $1 enable_pipeline 0
|
||||
config_get geo_auto_update $1 geo_auto_update 0
|
||||
config_get geo_update_day_time $1 geo_update_day_time 2
|
||||
config_get geo_update_week_time $1 geo_update_week_time "*"
|
||||
config_get listen_port $1 listen_port 5335
|
||||
config_get log_file $1 logfile "/tmp/mosdns.log"
|
||||
config_get log_level $1 log_level "info"
|
||||
config_get maximum_ttl_custom $1 maximum_ttl 0
|
||||
config_get minimal_ttl_custom $1 minimal_ttl 0
|
||||
config_get redirect $1 redirect 0
|
||||
config_get remote_dns $1 remote_dns "tls://8.8.8.8 tls://1.1.1.1"
|
||||
config_get custom_local_dns $1 custom_local_dns 0
|
||||
config_get bootstrap_dns $1 bootstrap_dns "119.29.29.29"
|
||||
config_get listen_port_api $1 listen_port_api 9091
|
||||
config_get concurrent $1 concurrent 1
|
||||
config_get max_conns $1 max_conns 2
|
||||
config_get insecure_skip_verify $1 insecure_skip_verify 0
|
||||
config_get idle_timeout $1 idle_timeout 30
|
||||
config_get enable_http3 $1 enable_http3 0
|
||||
config_get enable_ecs_remote $1 enable_ecs_remote 0
|
||||
}
|
||||
|
||||
init_yaml() {
|
||||
TMPDIR=$(mktemp -d) || exit 1
|
||||
adlist=$($MOSDNS_SCRIPT ad)
|
||||
[ $enable_pipeline -eq 1 ] && enable_pipeline=true || enable_pipeline=false
|
||||
[ $insecure_skip_verify -eq 1 ] && insecure_skip_verify=true || insecure_skip_verify=false
|
||||
[ $enable_http3 -eq 1 ] && enable_http3=true || enable_http3=false
|
||||
[ "$custom_local_dns" -eq 1 ] && \
|
||||
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: %s\n%s bootstrap: '${bootstrap_dns}'\n%s enable_pipeline: '${enable_pipeline}'\n%s max_conns: '${max_conns}'\n%s insecure_skip_verify: '${insecure_skip_verify}'\n%s idle_timeout: '${idle_timeout}'\n",s,$i,s,s,s,s,s}' s=' ') || \
|
||||
local_dns=$($MOSDNS_SCRIPT dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: %s\n",s,$i,s}' s=' ')
|
||||
remote_dns=$(echo $remote_dns | awk '{for(i=1;i<=NF;i++)printf "%s- addr: %s\n%s bootstrap: '${bootstrap_dns}'\n%s enable_pipeline: '${enable_pipeline}'\n%s max_conns: '${max_conns}'\n%s insecure_skip_verify: '${insecure_skip_verify}'\n%s idle_timeout: '${idle_timeout}'\n%s enable_http3: '${enable_http3}'\n",s,$i,s,s,s,s,s,s}' s=' ')
|
||||
sed "s,log_level,$log_level,g;s,log_file,$log_file,g; \
|
||||
s,listen_port,$listen_port,g;s,cache_size,$cache_size,g; \
|
||||
s,cache_survival_time,$cache_survival_time,g; \
|
||||
s,minimal_ttl_custom,$minimal_ttl_custom,g; \
|
||||
s,maximum_ttl_custom,$maximum_ttl_custom,g; \
|
||||
s,concurrent_num,$concurrent,g;s,api_port,$listen_port_api,g; \
|
||||
s,adblock,$adlist,g;s,remote_dns_pipeline,$enable_pipeline,g" $DEFAULT_CONF > $CONF
|
||||
echo "${local_dns}" > $TMPDIR/local_dns.txt
|
||||
echo "${remote_dns}" > $TMPDIR/remote_dns.txt
|
||||
sed -i -e '/- addr: local_dns/{r '$TMPDIR/local_dns.txt -e';d};/- addr: remote_dns/{r '$TMPDIR/remote_dns.txt -e';d}' $CONF
|
||||
[ "$dump_file" -eq 1 ] && sed -i "/lazy_cache_ttl/a\ dump_file: $DUMP_FILE\n dump_interval: $dump_interval" $CONF
|
||||
[ "$dump_file" -eq 1 ] && [ ! -f $DUMP_FILE ] && cp -a $DUMP_FILE_DEFAULT $DUMP_FILE
|
||||
[ "$dump_file" -eq 0 ] && \cp -a $DUMP_FILE_DEFAULT $DUMP_FILE
|
||||
if [ "$enable_ecs_remote" -eq 1 ]; then
|
||||
ecs_remote=$(sh /usr/share/mosdns/mosdns.sh ecs_remote)
|
||||
sed -i "s,ecs_remote,$ecs_remote,g" $CONF
|
||||
else
|
||||
sed -i "/ecs_remote/d;" $CONF
|
||||
fi
|
||||
rm -rf $TMPDIR
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "mosdns"
|
||||
}
|
||||
|
||||
restore_setting() {
|
||||
rm -f /etc/mosdns/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() {
|
||||
if [ "${CONF}" = "/etc/mosdns/config.yaml" ]; then
|
||||
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
|
||||
else
|
||||
sed -i "/list server/d" /etc/config/dhcp
|
||||
uci add_list dhcp.@dnsmasq[0].server="127.0.0.1#$(awk -F'[:" ]+' '/^\s+listen:/{for(i=1;i<=NF;i++){if($i~/^[0-9]+$/){print $i;exit}}}' $CONF)"
|
||||
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
|
||||
fi
|
||||
touch /etc/mosdns/redirect.lock
|
||||
}
|
||||
|
||||
reload_dnsmasq() {
|
||||
/etc/init.d/dnsmasq reload
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
|
||||
setcron() {
|
||||
sed -i '/mosdns.sh/d' $CRON_FILE 2>/dev/null
|
||||
[ "$geo_auto_update" -eq 1 ] && echo "0 $geo_update_day_time * * $geo_update_week_time $MOSDNS_SCRIPT geodata" >> $CRON_FILE
|
||||
crontab $CRON_FILE
|
||||
}
|
||||
|
||||
delcron() {
|
||||
sed -i '/mosdns.sh/d' $CRON_FILE 2>/dev/null
|
||||
crontab $CRON_FILE
|
||||
}
|
||||
|
||||
v2dat_dump() {
|
||||
$MOSDNS_SCRIPT v2dat_dump
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "mosdns"
|
||||
config_foreach get_config "mosdns"
|
||||
[ $enabled -ne 1 ] && return 1
|
||||
delcron ; setcron
|
||||
[ "${CONF}" = "/etc/mosdns/config.yaml" ] && init_yaml
|
||||
:> $($MOSDNS_SCRIPT logfile)
|
||||
if [ "${log_level}" = "error" ] || [ "${log_level}" = "warn" ]; then
|
||||
v2dat_dump > /dev/null 2>&1
|
||||
else
|
||||
v2dat_dump >> $($MOSDNS_SCRIPT logfile) 2>&1
|
||||
fi
|
||||
procd_open_instance mosdns
|
||||
procd_set_param command $PROG start -c "$CONF"
|
||||
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 mosdns
|
||||
[ "$redirect" -ne 1 ] && [ -f "/etc/mosdns/redirect.lock" ] && restore_setting
|
||||
[ "$redirect" -eq 1 ] && redirect_setting
|
||||
reload_dnsmasq
|
||||
update_list=0
|
||||
[ "$adblock" -eq 1 ] && [ "$ad_source" != "geosite.dat" ] && {
|
||||
[ -s "/etc/mosdns/rule/adlist.txt" ] && [ -f "/etc/mosdns/rule/.ad_source" ] && url_adlist=$(cat /etc/mosdns/rule/.ad_source) || update_list=1
|
||||
[ "$ad_source" != "$url_adlist" ] && update_list=1
|
||||
}
|
||||
[ "$update_list" -eq 1 ] && $MOSDNS_SCRIPT adlist_update &> /dev/null &
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
config_load "mosdns"
|
||||
config_foreach get_config "mosdns"
|
||||
[ "$enabled" -eq "0" ] && [ -f "/etc/mosdns/redirect.lock" ] && restore_setting
|
||||
reload_dnsmasq
|
||||
delcron
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
log:
|
||||
level: info
|
||||
file: "/tmp/mosdns.log"
|
||||
|
||||
# API 入口设置
|
||||
api:
|
||||
http: "0.0.0.0:9091"
|
||||
|
||||
include: []
|
||||
|
||||
plugins:
|
||||
# 国内域名
|
||||
- tag: geosite_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geosite_cn.txt"
|
||||
|
||||
# 国内 IP
|
||||
- tag: geoip_cn
|
||||
type: ip_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geoip_cn.txt"
|
||||
|
||||
# 国外域名
|
||||
- tag: geosite_no_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geosite_geolocation-!cn.txt"
|
||||
|
||||
# 缓存
|
||||
- tag: lazy_cache
|
||||
type: cache
|
||||
args:
|
||||
size: 20000
|
||||
lazy_cache_ttl: 86400
|
||||
dump_file: "/etc/mosdns/cache.dump"
|
||||
dump_interval: 600
|
||||
|
||||
# 转发至本地服务器
|
||||
- tag: forward_local
|
||||
type: forward
|
||||
args:
|
||||
upstreams:
|
||||
- addr: "https://doh.pub/dns-query"
|
||||
bootstrap: 180.76.76.76
|
||||
- addr: 119.29.29.29
|
||||
|
||||
# 转发至远程服务器
|
||||
- tag: forward_remote
|
||||
type: forward
|
||||
args:
|
||||
upstreams:
|
||||
- addr: tls://8.8.8.8
|
||||
enable_pipeline: false
|
||||
|
||||
# 国内解析
|
||||
- tag: local_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $forward_local
|
||||
|
||||
# 国外解析
|
||||
- tag: remote_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: prefer_ipv4
|
||||
- exec: $forward_remote
|
||||
|
||||
# 有响应终止返回
|
||||
- tag: has_resp_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- matches: has_resp
|
||||
exec: accept
|
||||
|
||||
# fallback 用本地服务器 sequence
|
||||
# 返回非国内 ip 则 drop_resp
|
||||
- tag: query_is_local_ip
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $local_sequence
|
||||
- matches: "!resp_ip $geoip_cn"
|
||||
exec: drop_resp
|
||||
|
||||
# fallback 用远程服务器 sequence
|
||||
- tag: query_is_remote
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $remote_sequence
|
||||
|
||||
# fallback 用远程服务器 sequence
|
||||
- tag: fallback
|
||||
type: fallback
|
||||
args:
|
||||
primary: query_is_local_ip
|
||||
secondary: query_is_remote
|
||||
threshold: 500
|
||||
always_standby: true
|
||||
|
||||
# 查询国内域名
|
||||
- tag: query_is_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_cn
|
||||
exec: $local_sequence
|
||||
|
||||
# 查询国外域名
|
||||
- tag: query_is_no_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_no_cn
|
||||
exec: $remote_sequence
|
||||
|
||||
# 主要的运行逻辑插件
|
||||
# sequence 插件中调用的插件 tag 必须在 sequence 前定义,
|
||||
# 否则 sequence 找不到对应插件。
|
||||
- tag: main_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $lazy_cache
|
||||
- exec: $query_is_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_no_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $fallback
|
||||
|
||||
# 启动 udp 服务器。
|
||||
- tag: udp_server
|
||||
type: udp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: ":5335"
|
||||
|
||||
# 启动 tcp 服务器。
|
||||
- tag: tcp_server
|
||||
type: tcp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: ":5335"
|
@ -1,3 +0,0 @@
|
||||
domain:gstatic.com
|
||||
domain:kernel.org
|
||||
keyword:github
|
@ -1,3 +0,0 @@
|
||||
# block all PTR requests
|
||||
domain:in-addr.arpa
|
||||
domain:ip6.arpa
|
@ -1,24 +0,0 @@
|
||||
domain:bing.com
|
||||
domain:live.com
|
||||
domain:msn.com
|
||||
domain:ntp.org
|
||||
domain:office.com
|
||||
domain:qlogo.cn
|
||||
domain:qq.com
|
||||
domain:redhat.com
|
||||
keyword:aaplimg
|
||||
keyword:aicdn
|
||||
keyword:akadns
|
||||
keyword:akamai
|
||||
keyword:apple
|
||||
keyword:douyin
|
||||
keyword:fclouddns
|
||||
keyword:icloud
|
||||
keyword:itunes
|
||||
keyword:microsoft
|
||||
keyword:mzstatic
|
||||
keyword:ssrcdn
|
||||
keyword:windows
|
||||
keyword:xxpkg
|
||||
keyword:yximgs
|
||||
keyword:yxygslb
|
@ -1,5 +0,0 @@
|
||||
# Do not edit, changes to this file will be lost on upgrades
|
||||
# /etc/sysctl.conf can be used to customize sysctl settings
|
||||
|
||||
net.core.rmem_max=4194304
|
||||
net.core.wmem_max=4194304
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@mosdns[-1]
|
||||
add ucitrack mosdns
|
||||
set ucitrack.@mosdns[-1].init=mosdns
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -rf /tmp/luci-*
|
||||
exit 0
|
Binary file not shown.
@ -1,230 +0,0 @@
|
||||
log:
|
||||
level: log_level
|
||||
file: "log_file"
|
||||
|
||||
api:
|
||||
http: "0.0.0.0:api_port"
|
||||
|
||||
include: []
|
||||
|
||||
plugins:
|
||||
- tag: geosite_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geosite_cn.txt"
|
||||
|
||||
- tag: geoip_cn
|
||||
type: ip_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geoip_cn.txt"
|
||||
|
||||
- tag: geosite_no_cn
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/var/mosdns/geosite_geolocation-!cn.txt"
|
||||
|
||||
- tag: whitelist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/whitelist.txt"
|
||||
|
||||
- tag: blocklist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/blocklist.txt"
|
||||
|
||||
- tag: greylist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/greylist.txt"
|
||||
|
||||
- tag: ddnslist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/ddnslist.txt"
|
||||
|
||||
- tag: hosts
|
||||
type: hosts
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/hosts.txt"
|
||||
|
||||
- tag: redirect
|
||||
type: redirect
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/redirect.txt"
|
||||
|
||||
- tag: adlist
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "adblock"
|
||||
|
||||
- tag: local_ptr
|
||||
type: domain_set
|
||||
args:
|
||||
files:
|
||||
- "/etc/mosdns/rule/local-ptr.txt"
|
||||
|
||||
- tag: lazy_cache
|
||||
type: cache
|
||||
args:
|
||||
size: cache_size
|
||||
lazy_cache_ttl: cache_survival_time
|
||||
|
||||
- tag: forward_local
|
||||
type: forward
|
||||
args:
|
||||
concurrent: concurrent_num
|
||||
upstreams:
|
||||
- addr: local_dns
|
||||
|
||||
- tag: forward_remote
|
||||
type: forward
|
||||
args:
|
||||
concurrent: concurrent_num
|
||||
upstreams:
|
||||
- addr: remote_dns
|
||||
|
||||
- tag: modify_ttl
|
||||
type: sequence
|
||||
args:
|
||||
- exec: ttl minimal_ttl_custom-maximum_ttl_custom
|
||||
|
||||
- tag: modify_ddns_ttl
|
||||
type: sequence
|
||||
args:
|
||||
- exec: ttl 5-5
|
||||
|
||||
- tag: local_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $forward_local
|
||||
|
||||
- tag: remote_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: prefer_ipv4
|
||||
- exec: ecs_remote
|
||||
- exec: $forward_remote
|
||||
|
||||
- tag: has_resp_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $ddnslist
|
||||
exec: $modify_ddns_ttl
|
||||
- matches: "!qname $ddnslist"
|
||||
exec: $modify_ttl
|
||||
- matches: has_resp
|
||||
exec: accept
|
||||
|
||||
- tag: query_is_local_ip
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $local_sequence
|
||||
- matches: "!resp_ip $geoip_cn"
|
||||
exec: drop_resp
|
||||
|
||||
- tag: query_is_remote
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $remote_sequence
|
||||
|
||||
- tag: fallback
|
||||
type: fallback
|
||||
args:
|
||||
primary: query_is_local_ip
|
||||
secondary: query_is_remote
|
||||
threshold: 500
|
||||
always_standby: true
|
||||
|
||||
- tag: query_is_ddns_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $ddnslist
|
||||
exec: $local_sequence
|
||||
|
||||
- tag: query_is_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_cn
|
||||
exec: $local_sequence
|
||||
|
||||
- tag: query_is_no_local_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $geosite_no_cn
|
||||
exec: $remote_sequence
|
||||
|
||||
- tag: query_is_whitelist_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $whitelist
|
||||
exec: $local_sequence
|
||||
|
||||
- tag: query_is_greylist_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $greylist
|
||||
exec: $remote_sequence
|
||||
|
||||
- tag: query_is_reject_domain
|
||||
type: sequence
|
||||
args:
|
||||
- matches: qname $blocklist
|
||||
exec: reject 3
|
||||
- matches: qname $adlist
|
||||
exec: reject 3
|
||||
- matches:
|
||||
- qtype 12
|
||||
- qname $local_ptr
|
||||
exec: reject 3
|
||||
- matches: qtype 65
|
||||
exec: reject 3
|
||||
|
||||
- tag: main_sequence
|
||||
type: sequence
|
||||
args:
|
||||
- exec: $hosts
|
||||
- exec: jump has_resp_sequence
|
||||
- matches:
|
||||
- "!qname $ddnslist"
|
||||
- "!qname $blocklist"
|
||||
- "!qname $adlist"
|
||||
- "!qname $local_ptr"
|
||||
exec: $lazy_cache
|
||||
- exec: $redirect
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_ddns_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_whitelist_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_reject_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_greylist_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $query_is_no_local_domain
|
||||
- exec: jump has_resp_sequence
|
||||
- exec: $fallback
|
||||
|
||||
- tag: udp_server
|
||||
type: udp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: ":listen_port"
|
||||
|
||||
- tag: tcp_server
|
||||
type: tcp_server
|
||||
args:
|
||||
entry: main_sequence
|
||||
listen: ":listen_port"
|
@ -1,159 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_action=${1}
|
||||
|
||||
logfile_path() (
|
||||
configfile=$(uci -q get mosdns.config.configfile)
|
||||
if [ "$configfile" = "/etc/mosdns/config.yaml" ]; then
|
||||
uci -q get mosdns.config.logfile
|
||||
else
|
||||
[ ! -f /etc/mosdns/config_custom.yaml ] && exit 1
|
||||
awk '/^log:/{f=1;next}f==1{if($0~/file:/){print;exit}if($0~/^[^ ]/)exit}' /etc/mosdns/config_custom.yaml | grep -Eo "/[^'\"]+"
|
||||
fi
|
||||
)
|
||||
|
||||
interface_dns() (
|
||||
if [ "$(uci -q get mosdns.config.custom_local_dns)" = 1 ]; then
|
||||
uci -q get mosdns.config.local_dns
|
||||
else
|
||||
peerdns=$(uci -q get network.wan.peerdns)
|
||||
proto=$(uci -q get network.wan.proto)
|
||||
if [ "$peerdns" = 0 ] || [ "$proto" = "static" ]; then
|
||||
uci -q get network.wan.dns
|
||||
else
|
||||
interface_status=$(ubus call network.interface.wan status)
|
||||
echo $interface_status | jsonfilter -e "@['dns-server'][0]"
|
||||
echo $interface_status | jsonfilter -e "@['dns-server'][1]"
|
||||
fi
|
||||
[ $? -ne 0 ] && echo "119.29.29.29 223.5.5.5"
|
||||
fi
|
||||
)
|
||||
|
||||
ad_block() (
|
||||
adblock=$(uci -q get mosdns.config.adblock)
|
||||
if [ "$adblock" = 1 ]; then
|
||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||
if [ "$ad_source" = "geosite.dat" ]; then
|
||||
echo "/var/mosdns/geosite_category-ads-all.txt"
|
||||
else
|
||||
echo "/etc/mosdns/rule/adlist.txt"
|
||||
fi
|
||||
else
|
||||
touch /var/disable-ads.txt ; echo "/var/disable-ads.txt"
|
||||
fi
|
||||
)
|
||||
|
||||
adlist_update() (
|
||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||
[ "$ad_source" = "geosite.dat" ] || [ -z "$ad_source" ] && exit 0
|
||||
AD_TMPDIR=$(mktemp -d) || exit 1
|
||||
if echo "$ad_source" | grep -Eq "^https://raw.githubusercontent.com" ; then
|
||||
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
||||
[ "$google_status" -ne "204" ] && mirror="https://ghproxy.com/"
|
||||
fi
|
||||
echo -e "\e[1;32mDownloading $mirror$ad_source\e[0m"
|
||||
curl --connect-timeout 60 -m 90 --ipv4 -kfSLo "$AD_TMPDIR/adlist.txt" "$mirror$ad_source"
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf "$AD_TMPDIR"
|
||||
exit 1
|
||||
else
|
||||
\cp "$AD_TMPDIR/adlist.txt" /etc/mosdns/rule/adlist.txt
|
||||
echo "$ad_source" > /etc/mosdns/rule/.ad_source
|
||||
rm -rf "$AD_TMPDIR"
|
||||
fi
|
||||
)
|
||||
|
||||
geodat_update() (
|
||||
geodat_download() (
|
||||
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
||||
[ "$google_status" -ne "204" ] && mirror="https://ghproxy.com/"
|
||||
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1\e[0m"
|
||||
curl --connect-timeout 60 -m 900 --ipv4 -kfSLo "$TMPDIR/$1" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1"
|
||||
)
|
||||
TMPDIR=$(mktemp -d) || exit 1
|
||||
geodat_download geoip.dat && geodat_download geosite.dat
|
||||
if [ $? -ne 0 ]; then
|
||||
rm -rf "$TMPDIR"
|
||||
exit 1
|
||||
fi
|
||||
cp -f "$TMPDIR"/* /usr/share/v2ray
|
||||
rm -rf "$TMPDIR"
|
||||
)
|
||||
|
||||
restart_service() {
|
||||
/etc/init.d/mosdns restart
|
||||
}
|
||||
|
||||
ecs_local() {
|
||||
ipaddr=$(curl -s --connect-timeout 3 -H "Host:ip.3322.org" 118.184.169.32) || ipaddr=119.29.0.0
|
||||
echo "ecs ${ipaddr%.*}.0/24"
|
||||
}
|
||||
|
||||
ecs_remote() {
|
||||
ipaddr=$(curl -s --connect-timeout 3 -H "Host:ifconfig.me" 34.160.111.145) || ipaddr=103.103.65.0
|
||||
echo "ecs ${ipaddr%.*}.0/24"
|
||||
}
|
||||
|
||||
flush_cache() {
|
||||
curl -s 127.0.0.1:$(uci -q get mosdns.config.listen_port_api)/plugins/lazy_cache/flush || exit 1
|
||||
}
|
||||
|
||||
v2dat_dump() {
|
||||
# env
|
||||
v2dat_dir=/usr/share/v2ray
|
||||
adblock=$(uci -q get mosdns.config.adblock)
|
||||
ad_source=$(uci -q get mosdns.config.ad_source)
|
||||
configfile=$(uci -q get mosdns.config.configfile)
|
||||
mkdir -p /var/mosdns
|
||||
rm -f /var/mosdns/geo*.txt
|
||||
if [ "$configfile" = "/etc/mosdns/config.yaml" ]; then
|
||||
# default config
|
||||
v2dat unpack geoip -o /var/mosdns -f cn $v2dat_dir/geoip.dat
|
||||
v2dat unpack geosite -o /var/mosdns -f cn -f 'geolocation-!cn' $v2dat_dir/geosite.dat
|
||||
[ "$adblock" -eq 1 ] && [ "$ad_source" = "geosite.dat" ] && v2dat unpack geosite -o /var/mosdns -f category-ads-all $v2dat_dir/geosite.dat
|
||||
else
|
||||
# custom config
|
||||
v2dat unpack geoip -o /var/mosdns -f cn $v2dat_dir/geoip.dat
|
||||
v2dat unpack geosite -o /var/mosdns -f cn -f 'geolocation-!cn' $v2dat_dir/geosite.dat
|
||||
geoip_tags=$(uci -q get mosdns.config.geoip_tags)
|
||||
geosite_tags=$(uci -q get mosdns.config.geosite_tags)
|
||||
[ -n "$geoip_tags" ] && v2dat unpack geoip -o /var/mosdns $(echo $geoip_tags | sed -r 's/\S+/-f &/g') $v2dat_dir/geoip.dat
|
||||
[ -n "$geosite_tags" ] && v2dat unpack geosite -o /var/mosdns $(echo $geosite_tags | sed -r 's/\S+/-f &/g') $v2dat_dir/geosite.dat
|
||||
fi
|
||||
}
|
||||
|
||||
case $script_action in
|
||||
"dns")
|
||||
interface_dns
|
||||
;;
|
||||
"ad")
|
||||
ad_block
|
||||
;;
|
||||
"geodata")
|
||||
geodat_update && adlist_update && restart_service
|
||||
;;
|
||||
"logfile")
|
||||
logfile_path
|
||||
;;
|
||||
"adlist_update")
|
||||
adlist_update && restart_service
|
||||
;;
|
||||
"ecs_local")
|
||||
ecs_local
|
||||
;;
|
||||
"ecs_remote")
|
||||
ecs_remote
|
||||
;;
|
||||
"flush")
|
||||
flush_cache
|
||||
;;
|
||||
"v2dat_dump")
|
||||
v2dat_dump
|
||||
;;
|
||||
"version")
|
||||
mosdns version
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"luci-app-mosdns": {
|
||||
"description": "Grant UCI access for luci-app-mosdns",
|
||||
"read": {
|
||||
"uci": [ "mosdns" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "mosdns" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=1.14-1
|
||||
PKG_VERSION:=1.14-2
|
||||
PKG_RELEASE:=
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
@ -385,6 +385,14 @@ load_acl() {
|
||||
}
|
||||
}
|
||||
|
||||
filter_haproxy() {
|
||||
for item in $(uci show $CONFIG | grep ".lbss=" | cut -d "'" -f 2); do
|
||||
local ip=$(get_host_ip ipv4 $(echo $item | awk -F ":" '{print $1}') 1)
|
||||
[ -n "$ip" ] && ipset -q add $IPSET_VPSIPLIST $ip
|
||||
done
|
||||
echolog "加入负载均衡的节点到ipset[$IPSET_VPSIPLIST]直连完成"
|
||||
}
|
||||
|
||||
filter_vpsip() {
|
||||
uci show $CONFIG | grep ".address=" | cut -d "'" -f 2 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_VPSIPLIST &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
|
||||
uci show $CONFIG | grep ".address=" | cut -d "'" -f 2 | grep -E "([A-Fa-f0-9]{1,4}::?){1,7}[A-Fa-f0-9]{1,4}" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_VPSIPLIST6 &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
|
||||
@ -554,6 +562,7 @@ add_firewall_rule() {
|
||||
|
||||
# 过滤所有节点IP
|
||||
filter_vpsip > /dev/null 2>&1 &
|
||||
filter_haproxy > /dev/null 2>&1 &
|
||||
|
||||
accept_icmp=$(config_t_get global_forwarding accept_icmp 0)
|
||||
accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0)
|
||||
|
@ -126,6 +126,25 @@ do
|
||||
end)
|
||||
end
|
||||
|
||||
if true then
|
||||
local i = 0
|
||||
local option = "lbss"
|
||||
uci:foreach(appname, "haproxy_config", function(t)
|
||||
i = i + 1
|
||||
local node_id = t[option]
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
id = t[".name"],
|
||||
remarks = "HAProxy负载均衡节点列表[" .. i .. "]",
|
||||
currentNode = node_id and uci:get_all(appname, node_id) or nil,
|
||||
set = function(o, server)
|
||||
uci:set(appname, t[".name"], option, server)
|
||||
o.newNodeId = server
|
||||
end
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
||||
if true then
|
||||
local i = 0
|
||||
uci:foreach(appname, "acl_rule", function(t)
|
||||
|
@ -1,45 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mosdns
|
||||
PKG_VERSION:=5.1.3
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=7db89b2399ace81e86b53e95e5260e55778ad5e6e8dd82a73dd6989dcd2e0eda
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_LICENSE_FILE:=LICENSE
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
GO_PKG:=github.com/IrineSistiana/mosdns
|
||||
GO_PKG_LDFLAGS_X:=main.version=v$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/mosdns
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=IP Addresses and Names
|
||||
TITLE:=A plug-in DNS forwarder/splitter
|
||||
URL:=https://github.com/IrineSistiana/mosdns
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
|
||||
endef
|
||||
|
||||
GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) CGO_ENABLED=0
|
||||
|
||||
define Package/mosdns/install
|
||||
$(call GoPackage/Package/Install/Bin,$(1))
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,mosdns))
|
||||
$(eval $(call BuildPackage,mosdns))
|
Loading…
Reference in New Issue
Block a user