dns_server: fix max ttl reply issue.

This commit is contained in:
Nick Peng
2023-05-09 23:22:08 +08:00
parent ed102cda03
commit 0340d272c3
9 changed files with 49 additions and 41 deletions

View File

@@ -39,17 +39,17 @@ TEST_F(DomainRule, bogus_nxdomain)
if (request->qtype != DNS_T_A) {
return smartdns::SERVER_REQUEST_SOA;
}
if (request->domain == "a.com") {
smartdns::MockServer::AddIP(request, request->domain.c_str(), "10.11.12.13", 611);
return smartdns::SERVER_REQUEST_OK;
}
if (request->domain == "a.com") {
smartdns::MockServer::AddIP(request, request->domain.c_str(), "10.11.12.13", 611);
return smartdns::SERVER_REQUEST_OK;
}
smartdns::MockServer::AddIP(request, request->domain.c_str(), "1.2.3.4", 611);
return smartdns::SERVER_REQUEST_OK;
});
/* this ip will be discard, but is reachable */
server.MockPing(PING_TYPE_ICMP, "1.2.3.4", 60, 10);
/* this ip will be discard, but is reachable */
server.MockPing(PING_TYPE_ICMP, "1.2.3.4", 60, 10);
server.Start(R"""(bind [::]:60053
server udp://127.0.0.1:61053 -blacklist-ip
@@ -64,7 +64,7 @@ cache-persist no)""");
ASSERT_EQ(client.GetAuthorityNum(), 1);
EXPECT_EQ(client.GetStatus(), "NXDOMAIN");
ASSERT_TRUE(client.Query("b.com", 60053));
ASSERT_TRUE(client.Query("b.com", 60053));
std::cout << client.GetResult() << std::endl;
ASSERT_EQ(client.GetAnswerNum(), 1);
EXPECT_EQ(client.GetStatus(), "NOERROR");