Sfoglia il codice sorgente

Modify the detection method of smartdns

Nick Peng 5 anni fa
parent
commit
982002e836
4 ha cambiato i file con 50 aggiunte e 38 eliminazioni
  1. 18 18
      ReadMe.md
  2. 17 17
      ReadMe_en.md
  3. 10 3
      src/Makefile
  4. 5 0
      src/dns_server.c

+ 18 - 18
ReadMe.md

@@ -252,16 +252,16 @@ https://github.com/pymumu/smartdns/releases
 
 
 1. 检测服务是否配置成功。
 1. 检测服务是否配置成功。
 
 
-    使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+    使用`nslookup -querytype=ptr smartdns`查询域名  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns        name = smartdns.
     ```
     ```
 
 
 ### openwrt/LEDE
 ### openwrt/LEDE
@@ -296,16 +296,16 @@ https://github.com/pymumu/smartdns/releases
 
 
     * **检测转发服务是否配置成功**
     * **检测转发服务是否配置成功**
 
 
-        使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+        使用`nslookup -querytype=ptr smartdns`查询域名  
         看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
         看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
         ```shell
         ```shell
-        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
         Server:         192.168.1.1
         Server:         192.168.1.1
         Address:        192.168.1.1#53
         Address:        192.168.1.1#53
 
 
         Non-authoritative answer:
         Non-authoritative answer:
-        0.0.0.0.in-addr.arpa  name = smartdns.
+        smartdns        name = smartdns.
         ```
         ```
 
 
     * **界面提示重定向失败**
     * **界面提示重定向失败**
@@ -329,16 +329,16 @@ https://github.com/pymumu/smartdns/releases
 
 
     * **检测上游服务是否配置成功**
     * **检测上游服务是否配置成功**
 
 
-        * 方法一:使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+        * 方法一:使用`nslookup -querytype=ptr smartdns`查询域名  
         看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
         看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
         ```shell
         ```shell
-        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
         Server:         192.168.1.1
         Server:         192.168.1.1
         Address:        192.168.1.1#53
         Address:        192.168.1.1#53
 
 
         Non-authoritative answer:
         Non-authoritative answer:
-        0.0.0.0.in-addr.arpa  name = smartdns.
+        smartdns        name = smartdns.
         ```
         ```
 
 
         * 方法二:使用`nslookup`查询`www.baidu.com`域名,查看结果中百度的IP地址是否`只有一个`,如有多个IP地址返回,则表示未生效,请多尝试几个域名检查。
         * 方法二:使用`nslookup`查询`www.baidu.com`域名,查看结果中百度的IP地址是否`只有一个`,如有多个IP地址返回,则表示未生效,请多尝试几个域名检查。
@@ -393,16 +393,16 @@ https://github.com/pymumu/smartdns/releases
 
 
 1. 重启路由器生效服务
 1. 重启路由器生效服务
 
 
-    待路由器启动后,使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+    待路由器启动后,使用`nslookup -querytype=ptr smartdns`查询域名  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns        name = smartdns.
     ```
     ```
 
 
 1. 额外说明
 1. 额外说明
@@ -469,16 +469,16 @@ https://github.com/pymumu/smartdns/releases
 
 
 1. 重启路由器生效服务
 1. 重启路由器生效服务
 
 
-    待路由器启动后,使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+    待路由器启动后,使用`nslookup -querytype=ptr smartdns`查询域名  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns        name = smartdns.
     ```
     ```
 
 
     注意:若服务没有自动启动,则需要设置optwre/entware自动启动,具体方法参考optware/entware的文档。
     注意:若服务没有自动启动,则需要设置optwre/entware自动启动,具体方法参考optware/entware的文档。
@@ -526,16 +526,16 @@ https://github.com/pymumu/smartdns/releases
 
 
 1. 检测服务是否配置成功。
 1. 检测服务是否配置成功。
 
 
-    使用`nslookup -querytype=ptr 0.0.0.0`查询域名  
+    使用`nslookup -querytype=ptr smartdns`查询域名  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
     看命令结果中的`name`项目是否显示为`smartdns`或`主机名`,如`smartdns`则表示生效  
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns  name = smartdns.
     ```
     ```
 
 
 ## 配置参数
 ## 配置参数

+ 17 - 17
ReadMe_en.md

@@ -247,16 +247,16 @@ https://github.com/pymumu/smartdns/releases
 
 
 1. Check if the service is configured successfully
 1. Check if the service is configured successfully
 
 
-    Query domain name with `nslookup -querytype=ptr 0.0.0.0`  
+    Query domain name with `nslookup -querytype=ptr smartdns`  
     Check if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
     Check if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns         name = smartdns.
     ```
     ```
 
 
 ### openwrt/LEDE
 ### openwrt/LEDE
@@ -291,16 +291,16 @@ https://github.com/pymumu/smartdns/releases
 
 
     * **Check if the service is configured successfully**
     * **Check if the service is configured successfully**
 
 
-        Query domain name with `nslookup -querytype=ptr 0.0.0.0`
+        Query domain name with `nslookup -querytype=ptr smartdns`
         See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
         See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
         ```shell
         ```shell
-        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
         Server:         192.168.1.1
         Server:         192.168.1.1
         Address:        192.168.1.1#53
         Address:        192.168.1.1#53
 
 
         Non-authoritative answer:
         Non-authoritative answer:
-        0.0.0.0.in-addr.arpa  name = smartdns.
+        smartdns         name = smartdns.
         ```
         ```
 
 
     * **The interface prompts that the redirect failed**
     * **The interface prompts that the redirect failed**
@@ -328,12 +328,12 @@ https://github.com/pymumu/smartdns/releases
         See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
         See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
         ```shell
         ```shell
-        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+        pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
         Server:         192.168.1.1
         Server:         192.168.1.1
         Address:        192.168.1.1#53
         Address:        192.168.1.1#53
 
 
         Non-authoritative answer:
         Non-authoritative answer:
-        0.0.0.0.in-addr.arpa  name = smartdns.
+        smartdns         name = smartdns.
         ```
         ```
 
 
         * Method 2: Use `nslookup` to query the `www.baidu.com` domain name to see if the IP address of Baidu in the result is `only one. If there are multiple IP addresses returned, it means that it is not valid. Please try to check several domain names.
         * Method 2: Use `nslookup` to query the `www.baidu.com` domain name to see if the IP address of Baidu in the result is `only one. If there are multiple IP addresses returned, it means that it is not valid. Please try to check several domain names.
@@ -388,16 +388,16 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
 
 
 1. Restart router
 1. Restart router
 
 
-    After the router is started, use `nslookup -querytype=ptr 0.0.0.0` to query the domain name.  
+    After the router is started, use `nslookup -querytype=ptr smartdns` to query the domain name.  
     See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
     See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns         name = smartdns.
     ```
     ```
 
 
 1. Note
 1. Note
@@ -464,16 +464,16 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
 
 
 1. Restart the router to take effect
 1. Restart the router to take effect
 
 
-    After the router is started, use `nslookup -querytype=ptr 0.0.0.0` to query the domain name.
+    After the router is started, use `nslookup -querytype=ptr smartdns` to query the domain name.
     See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
     See if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
     ```shell
     ```shell
-    Pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    Pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server: 192.168.1.1
     Server: 192.168.1.1
     Address: 192.168.1.1#53
     Address: 192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa name = smartdns.
+    smartdns        name = smartdns.
     ```
     ```
 
 
     Note: If the service does not start automatically, you need to set optwre/entware to start automatically. For details, see the optware/entware documentation.
     Note: If the service does not start automatically, you need to set optwre/entware to start automatically. For details, see the optware/entware documentation.
@@ -521,16 +521,16 @@ Note: Merlin firmware is derived from ASUS firmware and can theoretically be use
 
 
 1. Check if the service is configured successfully
 1. Check if the service is configured successfully
 
 
-    Query domain name with `nslookup -querytype=ptr 0.0.0.0`  
+    Query domain name with `nslookup -querytype=ptr smartdns`  
     Check if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
     Check if the `name` item in the command result is displayed as `smartdns` or `hostname`, such as `smartdns`
 
 
     ```shell
     ```shell
-    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr 0.0.0.0
+    pi@raspberrypi:~/code/smartdns_build $ nslookup -querytype=ptr smartdns
     Server:         192.168.1.1
     Server:         192.168.1.1
     Address:        192.168.1.1#53
     Address:        192.168.1.1#53
 
 
     Non-authoritative answer:
     Non-authoritative answer:
-    0.0.0.0.in-addr.arpa  name = smartdns.
+    smartdns         name = smartdns.
     ```
     ```
 
 
 ## Configuration parameter
 ## Configuration parameter

+ 10 - 3
src/Makefile

@@ -17,18 +17,25 @@
 BIN=smartdns 
 BIN=smartdns 
 OBJS_LIB=lib/rbtree.o lib/art.o lib/bitops.o lib/radix.o lib/conf.o
 OBJS_LIB=lib/rbtree.o lib/art.o lib/bitops.o lib/radix.o lib/conf.o
 OBJS=smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o dns_conf.o dns_cache.o http_parse.o $(OBJS_LIB)
 OBJS=smartdns.o fast_ping.o dns_client.o dns_server.o dns.o util.o tlog.o dns_conf.o dns_cache.o http_parse.o $(OBJS_LIB)
-CFLAGS +=-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing 
+
+# cflags
+ifndef CFLAGS
+CFLAGS =-O2 -g -Wall -Wstrict-prototypes -fno-omit-frame-pointer -Wstrict-aliasing 
+endif
 override CFLAGS +=-Iinclude
 override CFLAGS +=-Iinclude
 override CFLAGS += -DBASE_FILE_NAME=\"$(notdir $<)\"
 override CFLAGS += -DBASE_FILE_NAME=\"$(notdir $<)\"
 ifdef VER
 ifdef VER
 override CFLAGS += -DSMARTDNS_VERION=\"$(VER)\"
 override CFLAGS += -DSMARTDNS_VERION=\"$(VER)\"
 endif
 endif
+
 CXXFLAGS=-O2 -g -Wall -std=c++11 
 CXXFLAGS=-O2 -g -Wall -std=c++11 
 override CXXFLAGS +=-Iinclude
 override CXXFLAGS +=-Iinclude
+
+# ldflags
 ifeq ($(STATIC), yes)
 ifeq ($(STATIC), yes)
-LDFLAGS += -lssl -lcrypto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl -static
+override LDFLAGS += -lssl -lcrypto -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl -static
 else
 else
-LDFLAGS += -lssl -lcrypto -lpthread 
+override LDFLAGS += -lssl -lcrypto -lpthread 
 endif
 endif
 
 
 .PHONY: all
 .PHONY: all

+ 5 - 0
src/dns_server.c

@@ -1688,6 +1688,11 @@ static int _dns_server_process_ptr(struct dns_request *request)
 		found = 1;
 		found = 1;
 	}
 	}
 
 
+	/* Determine if the smartdns service is in effect. */
+	if (found == 0 && strncmp(request->domain, "smartdns", sizeof("smartdns")) == 0) {
+		found = 1;
+	}
+
 	if (found == 0) {
 	if (found == 0) {
 		goto errout;
 		goto errout;
 	}
 	}