diff --git a/package/luci/files/luci/controller/smartdns.lua b/package/luci/files/luci/controller/smartdns.lua
index c69b422..3d51462 100644
--- a/package/luci/files/luci/controller/smartdns.lua
+++ b/package/luci/files/luci/controller/smartdns.lua
@@ -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
diff --git a/package/luci/files/luci/i18n/smartdns.zh-cn.po b/package/luci/files/luci/i18n/smartdns.zh-cn.po
index c894668..6fd77e9 100644
--- a/package/luci/files/luci/i18n/smartdns.zh-cn.po
+++ b/package/luci/files/luci/i18n/smartdns.zh-cn.po
@@ -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 "重定向"
diff --git a/package/luci/files/luci/model/cbi/smartdns.lua b/package/luci/files/luci/model/cbi/smartdns.lua
index 75db311..8784954 100644
--- a/package/luci/files/luci/model/cbi/smartdns.lua
+++ b/package/luci/files/luci/model/cbi/smartdns.lua
@@ -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
diff --git a/package/luci/files/luci/view/smartdns/smartdns_status.htm b/package/luci/files/luci/view/smartdns/smartdns_status.htm
index 14de190..b67e790 100644
--- a/package/luci/files/luci/view/smartdns/smartdns_status.htm
+++ b/package/luci/files/luci/view/smartdns/smartdns_status.htm
@@ -10,9 +10,11 @@ XHR.poll(3, '<%=luci.dispatcher.build_url("admin", "services", "smartdns", "stat
if (data.ipv4_works == 0) {
links += "
<%:IPV4 53 Port Redirect Failure%>"
}
-
- if (data.ipv6_works == 0) {
- links += "
<%:IPV6 53 Port Redirect Failure%>"
+
+ if (data.ipv6_works != 2) {
+ if (data.ipv6_works == 0) {
+ links += "
<%:IPV6 53 Port Redirect Failure%>"
+ }
}
}
} else {
diff --git a/package/openwrt/files/etc/init.d/smartdns b/package/openwrt/files/etc/init.d/smartdns
index 9f82bb7..77245bd 100644
--- a/package/openwrt/files/etc/init.d/smartdns
+++ b/package/openwrt/files/etc/init.d/smartdns
@@ -13,12 +13,17 @@ SMARTDNS_CONF_TMP="${SMARTDNS_CONF}.tmp"
set_iptable()
{
- IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F: '{print $2}'`"
+ local ipv6_server=$1
+ IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}'`"
for IP in $IPS
do
iptables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $SMARTDNS_PORT >/dev/null 2>&1
done
+ if [ "$ipv6_server" == 0 ]; then
+ return
+ fi
+
IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`"
for IP in $IPS
do
@@ -29,12 +34,17 @@ set_iptable()
clear_iptable()
{
- IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F: '{print $2}'`"
+ local ipv6_server=$1
+ IPS="`ifconfig | grep "inet addr" | grep -v ":127" | grep "Bcast" | awk '{print $2}' | awk -F : '{print $2}'`"
for IP in $IPS
do
iptables -t nat -D PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $SMARTDNS_PORT >/dev/null 2>&1
done
+ if [ "$ipv6_server" == 0 ]; then
+ return
+ fi
+
IPS="`ifconfig | grep "inet6 addr" | grep -v " fe80::" | grep -v " ::1" | grep "Global" | awk '{print $3}'`"
for IP in $IPS
do
@@ -89,7 +99,12 @@ start_service() {
fi
config_get "port" "$section" "port" "5353"
- conf_append "bind" "[::]:$port"
+ config_get "ipv6_server" "$section" "ipv6_server" "1"
+ if [ "$ipv6_server" = "1" ]; then
+ conf_append "bind" "[::]:$port"
+ else
+ conf_append "bind" ":$port"
+ fi
SMARTDNS_PORT="$port"
mkdir -p $(dirname $SMARTDNS_CONF)
@@ -137,7 +152,7 @@ start_service() {
clear_iptable
config_get_bool "redirect" "$section" "redirect" '0'
if [ "$redirect" -eq 1 ]; then
- set_iptable
+ set_iptable $ipv6_server
fi
config_foreach load_server "server"
diff --git a/src/fast_ping.c b/src/fast_ping.c
index 7777408..559b920 100644
--- a/src/fast_ping.c
+++ b/src/fast_ping.c
@@ -109,6 +109,7 @@ struct fast_ping_struct {
static struct fast_ping_struct ping;
static atomic_t ping_sid = ATOMIC_INIT(0);
+static int bool_print_log = 1;
uint16_t _fast_ping_checksum(uint16_t *header, size_t len)
{
@@ -325,6 +326,14 @@ static int _fast_ping_sendping_v6(struct ping_host_struct *ping_host)
if (errno == ENETUNREACH) {
goto errout;
}
+
+ if (errno == EACCES) {
+ if (bool_print_log == 0) {
+ goto errout;
+ }
+ bool_print_log = 0;
+ }
+
char ping_host_name[PING_MAX_HOSTLEN];
tlog(TLOG_ERROR, "sendto %s, id %d, %s", gethost_by_addr(ping_host_name, (struct sockaddr *)&ping_host->addr, ping_host->addr_len), ping_host->sid,
strerror(err));
@@ -398,6 +407,14 @@ static int _fast_ping_sendping_tcp(struct ping_host_struct *ping_host)
if (errno == ENETUNREACH) {
goto errout;
}
+
+ if (errno == EACCES) {
+ if (bool_print_log == 0) {
+ goto errout;
+ }
+ bool_print_log = 0;
+ }
+
tlog(TLOG_ERROR, "connect %s, id %d, %s", gethost_by_addr(ping_host_name, (struct sockaddr *)&ping_host->addr, ping_host->addr_len), ping_host->sid,
strerror(errno));
goto errout;
@@ -1048,6 +1065,7 @@ int fast_ping_init(void)
pthread_attr_t attr;
int epollfd = -1;
int ret;
+ bool_print_log = 1;
if (ping.epoll_fd > 0) {
return -1;
diff --git a/src/smartdns.c b/src/smartdns.c
index 6e7ba5b..a14f2c1 100644
--- a/src/smartdns.c
+++ b/src/smartdns.c
@@ -198,8 +198,8 @@ int smartdns_init(void)
goto errout;
}
- tlog_setlogscreen(1);
- tlog_setlevel(TLOG_INFO);
+ /* tlog_setlogscreen(1); */
+ tlog_setlevel(dns_conf_log_level);
if (dns_conf_server_num <= 0) {
if (smartdns_load_from_resolv() != 0) {