1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 15:27:34 +00:00

LookupServer: Watch /etc/hosts for changes during runtime

This adds a FileWatcher to the LookupServer which watches '/etc/hosts'
for changes during runtime and reloads its contents. If the file is
deleted, m_etc_hosts will be cleared.

Since we now need to access '/etc/hosts' later during runtime, it needs
to be unveiled with read permissions.
This commit is contained in:
Max Wipfli 2021-06-07 20:26:09 +02:00 committed by Ali Mohammad Pur
parent 7b39db3bf4
commit 4efccbd030
3 changed files with 31 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include "DNSPacket.h"
#include "DNSServer.h"
#include "MulticastDNS.h"
#include <LibCore/FileWatcher.h>
#include <LibCore/Object.h>
namespace LookupServer {
@ -35,6 +36,7 @@ private:
RefPtr<DNSServer> m_dns_server;
RefPtr<MulticastDNS> m_mdns;
Vector<String> m_nameservers;
RefPtr<Core::FileWatcher> m_file_watcher;
HashMap<DNSName, Vector<DNSAnswer>, DNSName::Traits> m_etc_hosts;
HashMap<DNSName, Vector<DNSAnswer>, DNSName::Traits> m_lookup_cache;
};