Add ipv6 option

This commit is contained in:
Nick Peng
2018-09-04 00:12:48 +08:00
parent 92956e9bd3
commit eeb3f5fd75
7 changed files with 66 additions and 10 deletions

View File

@@ -21,14 +21,21 @@ end
function act_status()
local e={}
local ipv6_server;
e.ipv6_works = 2;
e.ipv4_works = 2;
e.ipv6_server = 1;
e.redirect = smartdns.get_config_option("smartdns", "smartdns", "redirect", nil);
e.local_port = smartdns.get_config_option("smartdns", "smartdns", "port", nil);
ipv6_server = smartdns.get_config_option("smartdns", "smartdns", "ipv6_server", 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 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
if ipv6_server == "1" then
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.ipv6_works = 2
end
else
e.redirect = 0
end

View File

@@ -40,6 +40,12 @@ msgstr "IPV4 53端口重定向失败"
msgid "IPV6 53 Port Redirect Failure"
msgstr "IPV6 53端口重定向失败"
msgid "IPV6 Server"
msgstr "IPV6服务器"
msgid "Enable IPV6 DNS Server"
msgstr "启用IPV6服务器"
msgid "Redirect"
msgstr "重定向"

View File

@@ -36,6 +36,14 @@ o.default = 5353
o.datatype = "port"
o.rempty = false
---- Support IPV6
o = s:taboption("settings", Flag, "ipv6_server", translate("IPV6 Server"), translate("Enable IPV6 DNS Server"))
o.rmempty = false
o.default = o.enabled
o.cfgvalue = function(...)
return Flag.cfgvalue(...) or "1"
end
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

View File

@@ -10,9 +10,11 @@ XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "stat
if (data.ipv4_works == 0) {
links += "<br></br><b><font color=red><%:IPV4 53 Port Redirect Failure%></font></b>"
}
if (data.ipv6_works == 0) {
links += "<br></br><b><font color=red><%:IPV6 53 Port Redirect Failure%></font></b>"
if (data.ipv6_works != 2) {
if (data.ipv6_works == 0) {
links += "<br></br><b><font color=red><%:IPV6 53 Port Redirect Failure%></font></b>"
}
}
}
} else {