mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:07:35 +00:00
LookupServer: Cache DNS answers for TTL seconds
We now keep DNS answers around in a cache for TTL seconds after getting them the first time. The cache is capped at 256 responses for now. Suggested by @zecke in #10.
This commit is contained in:
parent
90a5907b44
commit
5e47508672
5 changed files with 71 additions and 17 deletions
|
@ -27,11 +27,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "DNSRequest.h"
|
||||
#include "DNSResponse.h"
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibCore/CObject.h>
|
||||
|
||||
class CLocalSocket;
|
||||
class CLocalServer;
|
||||
class DNSAnswer;
|
||||
|
||||
class LookupServer final : public CObject {
|
||||
C_OBJECT(LookupServer)
|
||||
|
@ -45,9 +47,8 @@ private:
|
|||
Vector<String> lookup(const String& hostname, bool& did_timeout, unsigned short record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
||||
|
||||
struct CachedLookup {
|
||||
time_t timestamp { 0 };
|
||||
unsigned short record_type { 0 };
|
||||
Vector<String> responses;
|
||||
DNSQuestion question;
|
||||
Vector<DNSAnswer> answers;
|
||||
};
|
||||
|
||||
RefPtr<CLocalServer> m_local_server;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue