Add conf-file option.
Luci add custom.conf Bugfix for timer Update address matching.
This commit is contained in:
@@ -27,8 +27,8 @@ function act_status()
|
||||
e.local_port = smartdns.get_config_option("smartdns", "smartdns", "port", nil);
|
||||
if e.redirect == "1" then
|
||||
if e.local_port ~= nil and e.local_port ~= "53" then
|
||||
e.ipv4_works = luci.sys.call("iptables -t nat -nL PREROUTING | grep REDIRECT | grep dpt:53 | grep %q >/dev/null 2>&1" % e.local_port) == 0
|
||||
e.ipv6_works = luci.sys.call("ip6tables -t nat -nL PREROUTING | grep REDIRECT | grep dpt:53 | grep %q >/dev/null 2>&1" % e.local_port) == 0
|
||||
e.ipv4_works = luci.sys.call("iptables -t nat -nL PREROUTING 2>/dev/null | grep REDIRECT | grep dpt:53 | grep %q >/dev/null 2>&1" % e.local_port) == 0
|
||||
e.ipv6_works = luci.sys.call("ip6tables -t nat -nL PREROUTING 2>/dev/null| grep REDIRECT | grep dpt:53 | grep %q >/dev/null 2>&1" % e.local_port) == 0
|
||||
else
|
||||
e.redirect = 0
|
||||
end
|
||||
|
||||
@@ -13,6 +13,9 @@ msgstr "SmartDNS 服务器"
|
||||
msgid "SmartDNS is a local high-performance DNS server, supports finding fastest IP, supports ad filtering, and supports avoiding DNS poisoning."
|
||||
msgstr "SmartDNS是一个本地高性能DNS服务器,支持避免域名污染,支持返回最快IP,支持广告过滤。"
|
||||
|
||||
msgid "Custom Settings"
|
||||
msgstr "自定义设置"
|
||||
|
||||
msgid "Server Name"
|
||||
msgstr "服务器名称"
|
||||
|
||||
@@ -67,6 +70,9 @@ msgstr "域名TTL最大值"
|
||||
msgid "Maximum TTL for all domain result."
|
||||
msgstr "设置所有域名的TTL最大值"
|
||||
|
||||
msgid "smartdns custom settings"
|
||||
msgstr "smartdns 自定义设置,具体配置参数参考指导"
|
||||
|
||||
msgid "Upstream Servers"
|
||||
msgstr "上游服务器"
|
||||
|
||||
|
||||
@@ -15,25 +15,28 @@ m:section(SimpleSection).template = "smartdns/smartdns_status"
|
||||
s = m:section(TypedSection, "smartdns", translate("Settings"), translate("General Settings"))
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("settings", translate("General Settings"))
|
||||
s:tab("custom", translate("Custom Settings"))
|
||||
|
||||
---- Eanble
|
||||
o = s:option(Flag, "enabled", translate("Enable"), translate("Enable or disable smartdns server"))
|
||||
o = s:taboption("settings", Flag, "enabled", translate("Enable"), translate("Enable or disable smartdns server"))
|
||||
o.default = o.disabled
|
||||
o.rempty = false
|
||||
|
||||
---- server name
|
||||
o = s:option(Value, "server_name", translate("Server Name"), translate("Smartdns server name"))
|
||||
o = s:taboption("settings", Value, "server_name", translate("Server Name"), translate("Smartdns server name"))
|
||||
o.default = "smartdns"
|
||||
o.datatype = "hostname"
|
||||
o.rempty = false
|
||||
|
||||
---- Port
|
||||
o = s:option(Value, "port", translate("Local Port"), translate("Smartdns local server port"))
|
||||
o = s:taboption("settings", Value, "port", translate("Local Port"), translate("Smartdns local server port"))
|
||||
o.placeholder = 5353
|
||||
o.default = 5353
|
||||
o.datatype = "port"
|
||||
o.rempty = false
|
||||
|
||||
o = s:option(Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns, as default DNS server"))
|
||||
o = s:taboption("settings", Flag, "redirect", translate("Redirect"), translate("Redirect standard dns query from 53 to smartdns, as default DNS server"))
|
||||
o.rmempty = false
|
||||
o.default = o.enabled
|
||||
o.cfgvalue = function(...)
|
||||
@@ -41,21 +44,40 @@ o.cfgvalue = function(...)
|
||||
end
|
||||
|
||||
---- cache-size
|
||||
o = s:option(Value, "cache_size", translate("Cache Size"), translate("DNS domain result cache size"))
|
||||
o = s:taboption("settings", Value, "cache_size", translate("Cache Size"), translate("DNS domain result cache size"))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl
|
||||
o = s:option(Value, "rr_ttl", translate("Domain TTL"), translate("TTL for all domain result."))
|
||||
o = s:taboption("settings", Value, "rr_ttl", translate("Domain TTL"), translate("TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl-min
|
||||
o = s:option(Value, "rr_ttl_min", translate("Domain TTL Min"), translate("Minimum TTL for all domain result."))
|
||||
o = s:taboption("settings", Value, "rr_ttl_min", translate("Domain TTL Min"), translate("Minimum TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
---- rr-ttl-max
|
||||
o = s:option(Value, "rr_ttl_max", translate("Domain TTL Max"), translate("Maximum TTL for all domain result."))
|
||||
o = s:taboption("settings", Value, "rr_ttl_max", translate("Domain TTL Max"), translate("Maximum TTL for all domain result."))
|
||||
o.rempty = true
|
||||
|
||||
|
||||
----- custom settings
|
||||
custom = s:taboption("custom", Value, "Custom Settings",
|
||||
translate(""),
|
||||
translate("smartdns custom settings"))
|
||||
|
||||
custom.template = "cbi/tvalue"
|
||||
custom.rows = 20
|
||||
|
||||
function custom.cfgvalue(self, section)
|
||||
return nixio.fs.readfile("/etc/smartdns/custom.conf")
|
||||
end
|
||||
|
||||
function custom.write(self, section, value)
|
||||
value = value:gsub("\r\n?", "\n")
|
||||
nixio.fs.writefile("/etc/smartdns/custom.conf", value)
|
||||
end
|
||||
|
||||
|
||||
-- Upstream servers
|
||||
s = m:section(TypedSection, "server", translate("Upstream Servers"), translate("Upstream Servers, support UDP, TCP protocol. " ..
|
||||
"Please configure multiple DNS servers, including multiple foreign DNS servers."))
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
/etc/config/smartdns
|
||||
/etc/smartdns/address.conf
|
||||
/etc/smartdns/custom.conf
|
||||
|
||||
11
package/openwrt/custom.conf
Normal file
11
package/openwrt/custom.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
# Add custom settings here.
|
||||
|
||||
# set log level
|
||||
# log-level [level], level=error, warn, info, debug
|
||||
# log-level error
|
||||
|
||||
# log-size k,m,g
|
||||
# log-size 128k
|
||||
|
||||
# log-file /var/log/smartdns.log
|
||||
# log-num 2
|
||||
@@ -8,6 +8,7 @@ SERVICE_DAEMONIZE=1
|
||||
BASECONFIGFILE="/etc/smartdns/smartdns.conf"
|
||||
SMARTDNS_CONF="/var/etc/smartdns.conf"
|
||||
ADDRESS_CONF="/etc/smartdns/address.conf"
|
||||
CUSTOM_CONF="/etc/smartdns/custom.conf"
|
||||
SMARTDNS_CONF_TMP="${SMARTDNS_CONF}.tmp"
|
||||
|
||||
set_iptable()
|
||||
@@ -141,8 +142,8 @@ start_service() {
|
||||
|
||||
config_foreach load_server "server"
|
||||
|
||||
echo "# address" >> $SMARTDNS_CONF_TMP
|
||||
grep "^ *address " $ADDRESS_CONF >> $SMARTDNS_CONF_TMP
|
||||
echo "conf-file $ADDRESS_CONF" >> $SMARTDNS_CONF_TMP
|
||||
echo "conf-file $CUSTOM_CONF" >> $SMARTDNS_CONF_TMP
|
||||
|
||||
config_get_bool "enabled" "$section" "enabled" '0'
|
||||
mv $SMARTDNS_CONF_TMP $SMARTDNS_CONF
|
||||
|
||||
@@ -7,6 +7,7 @@ SMARTDNS_DIR=$CURR_DIR/../../
|
||||
SMARTDNS_BIN=$SMARTDNS_DIR/src/smartdns
|
||||
SMARTDNS_CONF=$SMARTDNS_DIR/etc/smartdns/smartdns.conf
|
||||
ADDRESS_CONF=$CURR_DIR/address.conf
|
||||
CUSTOM_CONF=$CURR_DIR/custom.conf
|
||||
|
||||
showhelp()
|
||||
{
|
||||
@@ -32,6 +33,7 @@ build()
|
||||
|
||||
cp $SMARTDNS_CONF $ROOT/root/etc/smartdns/
|
||||
cp $ADDRESS_CONF $ROOT/root/etc/smartdns/
|
||||
cp $CUSTOM_CONF $ROOT/root/etc/smartdns/
|
||||
cp $CURR_DIR/files/etc $ROOT/root/ -af
|
||||
cp $SMARTDNS_BIN $ROOT/root/usr/sbin
|
||||
|
||||
|
||||
Reference in New Issue
Block a user