1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

LookupServer: Make lookup() return DNSAnswer's instead of strings

This way, we propagate proper TTL. None of the callers currently care, though.
This commit is contained in:
Sergey Bugaev 2021-02-14 16:57:41 +03:00 committed by Andreas Kling
parent 3fba6bfb5e
commit 19cfed329e
3 changed files with 40 additions and 23 deletions

View file

@ -50,9 +50,13 @@ void ClientConnection::die()
OwnPtr<Messages::LookupServer::LookupNameResponse> ClientConnection::handle(const Messages::LookupServer::LookupName& message)
{
auto addresses = LookupServer::the().lookup(message.name(), T_A);
if (addresses.is_empty())
auto answers = LookupServer::the().lookup(message.name(), T_A);
if (answers.is_empty())
return make<Messages::LookupServer::LookupNameResponse>(1, Vector<String>());
Vector<String> addresses;
for (auto& answer : answers) {
addresses.append(answer.record_data());
}
return make<Messages::LookupServer::LookupNameResponse>(0, move(addresses));
}
@ -66,9 +70,9 @@ OwnPtr<Messages::LookupServer::LookupAddressResponse> ClientConnection::handle(c
address[2],
address[1],
address[0]);
auto hosts = LookupServer::the().lookup(name, T_PTR);
if (hosts.is_empty())
auto answers = LookupServer::the().lookup(name, T_PTR);
if (answers.is_empty())
return make<Messages::LookupServer::LookupAddressResponse>(1, String());
return make<Messages::LookupServer::LookupAddressResponse>(0, hosts[0]);
return make<Messages::LookupServer::LookupAddressResponse>(0, answers[0].record_data());
}
}