fix dns client bug when trailing dot

This commit is contained in:
kedixa
2021-12-03 21:12:17 +08:00
parent 38fd2d512c
commit 8167d20c46
2 changed files with 7 additions and 4 deletions

View File

@@ -252,7 +252,7 @@ WFDnsTask *WFDnsClient::create_dns_task(const std::string& name,
status.try_origin_state = DNS_STATUS_TRY_ORIGIN_FIRST;
if (!name.empty() && name.back() == '.')
status.next_domain = p->uris.size();
status.next_domain = p->search_list.size();
else if (__get_ndots(name) < p->ndots)
status.try_origin_state = DNS_STATUS_TRY_ORIGIN_LAST;

View File

@@ -237,9 +237,12 @@ public:
void set_request_name(const std::string& name)
{
this->request_name = name;
while (!this->request_name.empty() && this->request_name.back() == '.')
this->request_name.pop_back();
std::string req_name(name);
while (req_name.size() > 1 && req_name.back() == '.')
req_name.pop_back();
this->request_name = std::move(req_name);
}
protected: