update config
This commit is contained in:
parent
73e884fa45
commit
d8882bafee
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ LUCI_PKGARCH:=all
|
|||||||
LUCI_DEPENDS:=+mosdns +jsonfilter +bash +v2ray-geoip +v2ray-geosite
|
LUCI_DEPENDS:=+mosdns +jsonfilter +bash +v2ray-geoip +v2ray-geosite
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/conffiles
|
define Package/$(PKG_NAME)/conffiles
|
||||||
/etc/mosdns/cus_config.yaml
|
/etc/mosdns/config_custom.yaml
|
||||||
/etc/config/mosdns
|
/etc/config/mosdns
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
@ -12,22 +12,22 @@ enable = s:option(Flag, "enabled", translate("Enable"))
|
|||||||
enable.rmempty = false
|
enable.rmempty = false
|
||||||
|
|
||||||
configfile = s:option(ListValue, "configfile", translate("MosDNS Config File"))
|
configfile = s:option(ListValue, "configfile", translate("MosDNS Config File"))
|
||||||
configfile:value("./def_config.yaml", translate("Def Config"))
|
configfile:value("/etc/mosdns/config.yaml", translate("Def Config"))
|
||||||
configfile:value("./cus_config.yaml", translate("Cus Config"))
|
configfile:value("/etc/mosdns/config_custom.yaml", translate("Cus Config"))
|
||||||
configfile.default = "./def_config.yaml"
|
configfile.default = "/etc/mosdns/config.yaml"
|
||||||
|
|
||||||
loglv = s:option(ListValue, "loglv", translate("Log Level"))
|
loglevel = s:option(ListValue, "log_level", translate("Log Level"))
|
||||||
loglv:value("debug")
|
loglevel:value("debug")
|
||||||
loglv:value("info")
|
loglevel:value("info")
|
||||||
loglv:value("warn")
|
loglevel:value("warn")
|
||||||
loglv:value("error")
|
loglevel:value("error")
|
||||||
loglv.default = "error"
|
loglevel.default = "error"
|
||||||
loglv:depends( "configfile", "./def_config.yaml")
|
loglevel:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
logfile = s:option(Value, "logfile", translate("MosDNS Log File"))
|
logfile = s:option(Value, "logfile", translate("MosDNS Log File"))
|
||||||
logfile.placeholder = "/dev/null"
|
logfile.placeholder = "/dev/null"
|
||||||
logfile.default = "/dev/null"
|
logfile.default = "/dev/null"
|
||||||
logfile:depends( "configfile", "./def_config.yaml")
|
logfile:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
dnsforward = s:option(Value, "dns_forward", translate("Remote DNS"))
|
dnsforward = s:option(Value, "dns_forward", translate("Remote DNS"))
|
||||||
dnsforward.default = "tls://8.8.4.4"
|
dnsforward.default = "tls://8.8.4.4"
|
||||||
@ -36,7 +36,7 @@ dnsforward:value("tls://8.8.8.8", "8.8.8.8 (Google DNS)")
|
|||||||
dnsforward:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
dnsforward:value("tls://8.8.4.4", "8.8.4.4 (Google DNS)")
|
||||||
dnsforward:value("208.67.222.222", "208.67.222.222 (Open DNS)")
|
dnsforward:value("208.67.222.222", "208.67.222.222 (Open DNS)")
|
||||||
dnsforward:value("208.67.220.220", "208.67.220.220 (Open DNS)")
|
dnsforward:value("208.67.220.220", "208.67.220.220 (Open DNS)")
|
||||||
dnsforward:depends( "configfile", "./def_config.yaml")
|
dnsforward:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
|
|
||||||
cache_size = s:option(Value, "cache_size", translate("DNS Cache Size"))
|
cache_size = s:option(Value, "cache_size", translate("DNS Cache Size"))
|
||||||
cache_size.datatype = "and(uinteger,min(0))"
|
cache_size.datatype = "and(uinteger,min(0))"
|
||||||
@ -52,26 +52,26 @@ maximum_ttl.datatype = "and(uinteger,min(1))"
|
|||||||
maximum_ttl.rmempty = false
|
maximum_ttl.rmempty = false
|
||||||
|
|
||||||
redirect = s:option(Flag, "redirect", translate("Enable DNS Redirect"))
|
redirect = s:option(Flag, "redirect", translate("Enable DNS Redirect"))
|
||||||
redirect:depends( "configfile", "./def_config.yaml")
|
redirect:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
redirect.default = true
|
redirect.default = true
|
||||||
|
|
||||||
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
adblock = s:option(Flag, "adblock", translate("Enable DNS ADblock"))
|
||||||
adblock:depends( "configfile", "./def_config.yaml")
|
adblock:depends( "configfile", "/etc/mosdns/config.yaml")
|
||||||
adblock.default = true
|
adblock.default = true
|
||||||
|
|
||||||
config = s:option(TextValue, "manual-config")
|
config = s:option(TextValue, "manual-config")
|
||||||
config.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>")
|
config.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>")
|
||||||
config.template = "cbi/tvalue"
|
config.template = "cbi/tvalue"
|
||||||
config.rows = 25
|
config.rows = 25
|
||||||
config:depends( "configfile", "./cus_config.yaml")
|
config:depends( "configfile", "/etc/mosdns/config_custom.yaml")
|
||||||
|
|
||||||
function config.cfgvalue(self, section)
|
function config.cfgvalue(self, section)
|
||||||
return nixio.fs.readfile("/etc/mosdns/cus_config.yaml")
|
return nixio.fs.readfile("/etc/mosdns/config_custom.yaml")
|
||||||
end
|
end
|
||||||
|
|
||||||
function config.write(self, section, value)
|
function config.write(self, section, value)
|
||||||
value = value:gsub("\r\n?", "\n")
|
value = value:gsub("\r\n?", "\n")
|
||||||
nixio.fs.writefile("/etc/mosdns/cus_config.yaml", value)
|
nixio.fs.writefile("/etc/mosdns/config_custom.yaml", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -30,7 +30,7 @@ data_update = s:option(Button, "geo_update_database", translate("Database Update
|
|||||||
data_update.inputtitle = translate("Check And Update")
|
data_update.inputtitle = translate("Check And Update")
|
||||||
data_update.inputstyle = "reload"
|
data_update.inputstyle = "reload"
|
||||||
data_update.write = function()
|
data_update.write = function()
|
||||||
luci.sys.exec("/etc/mosdns/mosupdater.sh &> /dev/null &")
|
luci.sys.exec("/usr/share/mosdns/update_geodat.sh &> /dev/null &")
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
|
|
||||||
config mosdns 'mosdns'
|
config mosdns 'mosdns'
|
||||||
option not_first_start '0'
|
|
||||||
option enabled '0'
|
option enabled '0'
|
||||||
option geo_auto_update '0'
|
option geo_auto_update '0'
|
||||||
option geo_update_week_time 'all'
|
option geo_update_week_time 'all'
|
||||||
option geo_update_day_time '2'
|
option geo_update_day_time '2'
|
||||||
option redirect '1'
|
option redirect '1'
|
||||||
option autoconf '1'
|
|
||||||
option update_adlist '1'
|
option update_adlist '1'
|
||||||
option adblock '0'
|
option adblock '0'
|
||||||
option configfile './def_config.yaml'
|
option configfile '/etc/mosdns/config.yaml'
|
||||||
option loglv 'error'
|
option log_level 'error'
|
||||||
option logfile '/tmp/mosdns.log'
|
option logfile '/tmp/mosdns.log'
|
||||||
option dns_forward 'tls://8.8.4.4'
|
option dns_forward 'tls://8.8.4.4'
|
||||||
option cache_size '1024'
|
option cache_size '1024'
|
||||||
|
@ -53,13 +53,13 @@ reload_service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setcron() {
|
setcron() {
|
||||||
sed -i '/mosupdater.sh/d' $CRON_FILE 2>/dev/null
|
sed -i '/update_geodat.sh/d' $CRON_FILE 2>/dev/null
|
||||||
[ "$(uci -q get mosdns.mosdns.geo_auto_update)" -eq 1 ] && echo "0 $(uci -q get mosdns.mosdns.geo_update_day_time) * * $(uci -q get mosdns.mosdns.geo_update_week_time) /etc/mosdns/mosupdater.sh" >>$CRON_FILE
|
[ "$(uci -q get mosdns.mosdns.geo_auto_update)" -eq 1 ] && echo "0 $(uci -q get mosdns.mosdns.geo_update_day_time) * * $(uci -q get mosdns.mosdns.geo_update_week_time) /usr/share/mosdns/update_geodat.sh" >>$CRON_FILE
|
||||||
crontab $CRON_FILE
|
crontab $CRON_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
delcron() {
|
delcron() {
|
||||||
sed -i '/mosupdater.sh/d' $CRON_FILE 2>/dev/null
|
sed -i '/update_geodat.sh/d' $CRON_FILE 2>/dev/null
|
||||||
crontab $CRON_FILE
|
crontab $CRON_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,15 +67,7 @@ start_service() {
|
|||||||
|
|
||||||
# Reading config
|
# Reading config
|
||||||
inital_conf
|
inital_conf
|
||||||
if [ "$enabled" -eq 0 ]; then
|
[ $enabled != 1 ] && return 1
|
||||||
firstblood=$(uci -q get mosdns.mosdns.not_first_start)
|
|
||||||
[ "${firstblood}" = "0" ] && restore_setting
|
|
||||||
[ "${firstblood}" = "0" ] && reload_others
|
|
||||||
uci set mosdns.mosdns.not_first_start='1'
|
|
||||||
uci commit mosdns
|
|
||||||
echo "MosDNS has turned off"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
delcron
|
delcron
|
||||||
setcron
|
setcron
|
||||||
procd_open_instance mosdns
|
procd_open_instance mosdns
|
||||||
@ -87,25 +79,21 @@ start_service() {
|
|||||||
procd_close_instance mosdns
|
procd_close_instance mosdns
|
||||||
|
|
||||||
configfile=$(uci -q get mosdns.mosdns.configfile)
|
configfile=$(uci -q get mosdns.mosdns.configfile)
|
||||||
if [ "${configfile}" = "./def_config.yaml" ]; then
|
if [ "${configfile}" = "/etc/mosdns/config.yaml" ]; then
|
||||||
restore_setting
|
restore_setting
|
||||||
redirect_setting
|
redirect_setting
|
||||||
reload_others
|
reload_others
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "MosDNS turn on"
|
echo "MosDNS turn on"
|
||||||
echo "enabled=$enabled"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_service() {
|
stop_service() {
|
||||||
|
|
||||||
pgrep -f /usr/bin/mosdns | xargs kill -9
|
pgrep -f /usr/bin/mosdns | xargs kill -9
|
||||||
echo "MosDNS turn off"
|
echo "MosDNS turn off"
|
||||||
echo "enabled=$enabled"
|
|
||||||
|
|
||||||
configfile=$(uci -q get mosdns.mosdns.configfile)
|
configfile=$(uci -q get mosdns.mosdns.configfile)
|
||||||
if [ "${configfile}" = "./def_config.yaml" ]; then
|
if [ "${configfile}" = "/etc/mosdns/config.yaml" ]; then
|
||||||
config_load "mosdns"
|
config_load "mosdns"
|
||||||
enabled=$(uci -q get mosdns.mosdns.enabled)
|
enabled=$(uci -q get mosdns.mosdns.enabled)
|
||||||
[ "${enabled}" = "0" ] && restore_setting
|
[ "${enabled}" = "0" ] && restore_setting
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
log:
|
log:
|
||||||
level: ${{ uci -q get mosdns.mosdns.loglv }}
|
level: ${{ uci -q get mosdns.mosdns.log_level }}
|
||||||
file: ${{ uci -q get mosdns.mosdns.logfile }}
|
file: ${{ uci -q get mosdns.mosdns.logfile }}
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
@ -73,8 +73,8 @@ plugin:
|
|||||||
type: fast_forward
|
type: fast_forward
|
||||||
args:
|
args:
|
||||||
upstream:
|
upstream:
|
||||||
- addr: ${{ ./dns.sh 0 }}
|
- addr: ${{ /usr/share/mosdns/dns.sh 0 }}
|
||||||
- addr: ${{ ./dns.sh 1 }}
|
- addr: ${{ /usr/share/mosdns/dns.sh 1 }}
|
||||||
|
|
||||||
- tag: query_is_whitelist_domain
|
- tag: query_is_whitelist_domain
|
||||||
type: query_matcher
|
type: query_matcher
|
||||||
@ -111,4 +111,4 @@ plugin:
|
|||||||
type: query_matcher
|
type: query_matcher
|
||||||
args:
|
args:
|
||||||
domain:
|
domain:
|
||||||
- ${{ ./ad_domain.sh }}
|
- ${{ /usr/share/mosdns/ad_domain.sh }}
|
@ -53,8 +53,8 @@ plugin:
|
|||||||
type: fast_forward
|
type: fast_forward
|
||||||
args:
|
args:
|
||||||
upstream:
|
upstream:
|
||||||
- addr: ${{ ./dns.sh 0 }}
|
- addr: ${{ /usr/share/mosdns/dns.sh 0 }}
|
||||||
- addr: ${{ ./dns.sh 1 }}
|
- addr: ${{ /usr/share/mosdns/dns.sh 1 }}
|
||||||
|
|
||||||
- tag: forward_remote
|
- tag: forward_remote
|
||||||
type: fast_forward
|
type: fast_forward
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
# shellcheck source=/etc/mosdns/library.sh
|
# shellcheck source=/etc/mosdns/library.sh
|
||||||
source /etc/mosdns/library.sh
|
source /usr/share/mosdns/library.sh
|
||||||
|
|
||||||
if [ "$(ifconfig | grep -c wan)" = 0 ]; then
|
if [ "$(ifconfig | grep -c wan)" = 0 ]; then
|
||||||
bakdns "$1"
|
bakdns "$1"
|
@ -2,7 +2,7 @@
|
|||||||
# shellcheck source=/etc/mosdns/library.sh
|
# shellcheck source=/etc/mosdns/library.sh
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
source /etc/mosdns/library.sh
|
source /usr/share/mosdns/library.sh
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d) || exit 1
|
TMPDIR=$(mktemp -d) || exit 1
|
||||||
getdat geoip.dat
|
getdat geoip.dat
|
Loading…
Reference in New Issue
Block a user