|
@@ -35,6 +35,8 @@
|
|
|
#include <unistd.h>
|
|
|
#include <vector>
|
|
|
|
|
|
+extern int dns_ping_cap_force_enable;
|
|
|
+
|
|
|
namespace smartdns
|
|
|
{
|
|
|
|
|
@@ -65,7 +67,7 @@ void MockServer::Stop()
|
|
|
|
|
|
if (fd_ > 0) {
|
|
|
close(fd_);
|
|
|
- fd_ = -1;;
|
|
|
+ fd_ = -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -102,7 +104,7 @@ void MockServer::Run()
|
|
|
struct ServerRequestContext request;
|
|
|
memset(&request, 0, sizeof(request));
|
|
|
|
|
|
- int ret = dns_decode(packet, sizeof(packet_buff), in_buff, len);
|
|
|
+ ret = dns_decode(packet, sizeof(packet_buff), in_buff, len);
|
|
|
if (ret == 0) {
|
|
|
request.packet = packet;
|
|
|
query_id = packet->head.id;
|
|
@@ -324,6 +326,8 @@ void Server::StartPost(void *arg)
|
|
|
|
|
|
if (has_ipv6 == true) {
|
|
|
fast_ping_fake_ip_add(PING_TYPE_ICMP, "2001::", 64, 10);
|
|
|
+ fast_ping_fake_ip_add(PING_TYPE_TCP, "[2001::]:80", 64, 10);
|
|
|
+ fast_ping_fake_ip_add(PING_TYPE_TCP, "[2001::]:443", 64, 10);
|
|
|
dns_server_check_ipv6_ready();
|
|
|
}
|
|
|
}
|
|
@@ -342,7 +346,7 @@ bool Server::Start(const std::string &conf, enum CONF_TYPE type)
|
|
|
close(fds[0]);
|
|
|
}
|
|
|
|
|
|
- if (fds[0] > 0) {
|
|
|
+ if (fds[1] > 0) {
|
|
|
close(fds[1]);
|
|
|
}
|
|
|
};
|
|
@@ -387,6 +391,7 @@ cache-persist no
|
|
|
}
|
|
|
|
|
|
smartdns_reg_post_func(Server::StartPost, this);
|
|
|
+ dns_ping_cap_force_enable = 1;
|
|
|
smartdns_main(args.size(), argv, fds[1], 0);
|
|
|
_exit(1);
|
|
|
} else if (pid < 0) {
|
|
@@ -401,7 +406,9 @@ cache-persist no
|
|
|
}
|
|
|
|
|
|
smartdns_reg_post_func(Server::StartPost, this);
|
|
|
+ dns_ping_cap_force_enable = 1;
|
|
|
smartdns_main(args.size(), argv, fds[1], 1);
|
|
|
+ dns_ping_cap_force_enable = 0;
|
|
|
smartdns_reg_post_func(nullptr, nullptr);
|
|
|
});
|
|
|
} else {
|
|
@@ -443,7 +450,9 @@ void Server::Stop(bool graceful)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- waitpid(pid_, nullptr, 0);
|
|
|
+ if (pid_ > 0) {
|
|
|
+ waitpid(pid_, nullptr, 0);
|
|
|
+ }
|
|
|
|
|
|
pid_ = 0;
|
|
|
}
|