mirror of
https://github.com/RGBCube/serenity
synced 2026-01-21 23:21:00 +00:00
The implementation is extremely basic, and is far from fully conforming to the spec. Among other things, it does not really work in case there are multiple network adapters. Nevertheless, it works quite well for the simple case! You can now do this on your host machine: $ ping courage.local and same on your Serenity box: $ ping host-machine-name.local
42 lines
1 KiB
C++
42 lines
1 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "DNSName.h"
|
|
#include "DNSPacket.h"
|
|
#include "DNSServer.h"
|
|
#include "MulticastDNS.h"
|
|
#include <LibCore/Object.h>
|
|
|
|
namespace LookupServer {
|
|
|
|
class DNSAnswer;
|
|
|
|
class LookupServer final : public Core::Object {
|
|
C_OBJECT(LookupServer);
|
|
|
|
public:
|
|
static LookupServer& the();
|
|
Vector<DNSAnswer> lookup(const DNSName& name, unsigned short record_type);
|
|
|
|
private:
|
|
LookupServer();
|
|
|
|
void load_etc_hosts();
|
|
void put_in_cache(const DNSAnswer&);
|
|
|
|
Vector<DNSAnswer> lookup(const DNSName& hostname, const String& nameserver, bool& did_get_response, unsigned short record_type, ShouldRandomizeCase = ShouldRandomizeCase::Yes);
|
|
|
|
RefPtr<Core::LocalServer> m_local_server;
|
|
RefPtr<DNSServer> m_dns_server;
|
|
RefPtr<MulticastDNS> m_mdns;
|
|
Vector<String> m_nameservers;
|
|
HashMap<DNSName, Vector<DNSAnswer>, DNSName::Traits> m_etc_hosts;
|
|
HashMap<DNSName, Vector<DNSAnswer>, DNSName::Traits> m_lookup_cache;
|
|
};
|
|
|
|
}
|