config: add option -no-cache and -response-mode for domain-rules and add some test cases.

This commit is contained in:
Nick Peng
2023-03-24 21:58:41 +08:00
parent 4f2867b7f4
commit dd23c5fc31
16 changed files with 1004 additions and 66 deletions

View File

@@ -28,22 +28,13 @@ TEST(server, cname)
smartdns::Server server;
server_upstream.Start("udp://0.0.0.0:61053", [](struct smartdns::ServerRequestContext *request) {
std::string domain = request->domain;
if (request->domain.length() == 0) {
return smartdns::SERVER_REQUEST_ERROR;
if (request->qtype != DNS_T_A) {
return smartdns::SERVER_REQUEST_SOA;
}
if (request->qtype == DNS_T_A) {
unsigned char addr[4] = {1, 2, 3, 4};
dns_add_A(request->response_packet, DNS_RRS_AN, domain.c_str(), 61, addr);
} else if (request->qtype == DNS_T_AAAA) {
unsigned char addr[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
dns_add_AAAA(request->response_packet, DNS_RRS_AN, domain.c_str(), 61, addr);
} else {
return smartdns::SERVER_REQUEST_ERROR;
}
EXPECT_EQ(domain, "e.com");
unsigned char addr[4] = {1, 2, 3, 4};
dns_add_A(request->response_packet, DNS_RRS_AN, request->domain.c_str(), 611, addr);
EXPECT_EQ(request->domain, "e.com");
request->response_packet->head.rcode = DNS_RC_NOERROR;
return smartdns::SERVER_REQUEST_OK;