mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:27:45 +00:00
LookupServer: Implement basic mDNS support :^)
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
This commit is contained in:
parent
fd76e07399
commit
bb06e720de
6 changed files with 251 additions and 1 deletions
|
@ -46,6 +46,7 @@ LookupServer::LookupServer()
|
|||
m_dns_server = DNSServer::construct(this);
|
||||
// TODO: drop root privileges here.
|
||||
}
|
||||
m_mdns = MulticastDNS::construct(this);
|
||||
|
||||
m_local_server = Core::LocalServer::construct(this);
|
||||
m_local_server->on_ready_to_accept = [this]() {
|
||||
|
@ -150,6 +151,14 @@ Vector<DNSAnswer> LookupServer::lookup(const DNSName& name, unsigned short recor
|
|||
return answers;
|
||||
}
|
||||
|
||||
// Look up .local names using mDNS instead of DNS nameservers.
|
||||
if (name.as_string().ends_with(".local")) {
|
||||
answers = m_mdns->lookup(name, record_type);
|
||||
for (auto& answer : answers)
|
||||
put_in_cache(answer);
|
||||
return answers;
|
||||
}
|
||||
|
||||
// Third, ask the upstream nameservers.
|
||||
for (auto& nameserver : m_nameservers) {
|
||||
dbgln_if(LOOKUPSERVER_DEBUG, "Doing lookup using nameserver '{}'", nameserver);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue