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

@@ -255,6 +255,11 @@ bool Client::ParserResult()
answer_num_ = std::stoi(match[1]);
}
std::regex reg_authority_num(", AUTHORITY: ([0-9]+),");
if (std::regex_search(result_, match, reg_authority_num)) {
records_authority_num_ = std::stoi(match[1]);
}
std::regex reg_status(", status: ([A-Z]+),");
if (std::regex_search(result_, match, reg_status)) {
status_ = match[1];
@@ -301,6 +306,19 @@ bool Client::ParserResult()
}
}
std::regex reg_authority(";; AUTHORITY SECTION:\\n((?:.|\\n|\\r\\n)+?)\\n{2,}",
std::regex::ECMAScript | std::regex::optimize);
if (std::regex_search(result_, match, reg_authority)) {
if (ParserRecord(match[1], records_authority_) == false) {
return false;
}
if (records_authority_num_ != records_authority_.size()) {
std::cout << "DIG FAILED: Num Not Match\n" << result_ << std::endl;
return false;
}
}
std::regex reg_addition(";; ADDITIONAL SECTION:\\n((?:.|\\n|\\r\\n)+?)\\n{2,}",
std::regex::ECMAScript | std::regex::optimize);
if (std::regex_search(result_, match, reg_answer)) {