Fixed error that DNS server only return NXDOMAIN

This commit is contained in:
WolverinDEV 2019-11-23 22:27:02 +01:00
parent 00c2502001
commit bbe9f9f05f
2 changed files with 4 additions and 1 deletions

View File

@ -58,7 +58,7 @@ void WebDNSHandler::handle_message(const std::shared_ptr<DNSServerBinding>& bind
}
}
if(parser.answers().empty())
if(response.answer_count() == 0)
response.header().set_response_code(rcode::NXDOMAIN);
else
response.header().set_response_code(rcode::NOERROR);

View File

@ -207,6 +207,9 @@ namespace ts::dns {
return this->_answers[index];
}
inline size_t answer_count() const { return this->_answers.size(); }
inline size_t query_count() const { return this->_queries.size(); }
size_t build(char* /* buffer */, size_t /* max length */, std::string& /* error */);
private:
builder::DNSHeader _header{};