1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

LookupServer: Unbreak reverse DNS lookups

We were ignoring everything but A records in DNS responses. This broke
reverse lookups which obviously want the PTR records.

Fix this by filtering on the requested record type instead of always A.
This commit is contained in:
Andreas Kling 2021-01-30 12:06:51 +01:00
parent 489d413fc7
commit 1c6f278677

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -263,7 +263,7 @@ Vector<String> LookupServer::lookup(const String& hostname, const String& namese
Vector<String, 8> responses; Vector<String, 8> responses;
Vector<DNSAnswer, 8> cacheable_answers; Vector<DNSAnswer, 8> cacheable_answers;
for (auto& answer : response.answers()) { for (auto& answer : response.answers()) {
if (answer.type() != T_A) if (answer.type() != record_type)
continue; continue;
responses.append(answer.record_data()); responses.append(answer.record_data());
if (!answer.has_expired()) if (!answer.has_expired())