mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
LookupServer: Rename "custom_hosts" => "etc_hosts"
This makes it more obvious that these mappings come from /etc/hosts.
This commit is contained in:
parent
c26560ec26
commit
90a5907b44
2 changed files with 4 additions and 5 deletions
|
@ -62,7 +62,6 @@ LookupServer::LookupServer()
|
||||||
|
|
||||||
void LookupServer::load_etc_hosts()
|
void LookupServer::load_etc_hosts()
|
||||||
{
|
{
|
||||||
dbg() << "Loading hosts from /etc/hosts";
|
|
||||||
auto file = CFile::construct("/etc/hosts");
|
auto file = CFile::construct("/etc/hosts");
|
||||||
if (!file->open(CIODevice::ReadOnly))
|
if (!file->open(CIODevice::ReadOnly))
|
||||||
return;
|
return;
|
||||||
|
@ -82,7 +81,7 @@ void LookupServer::load_etc_hosts()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto name = fields[1];
|
auto name = fields[1];
|
||||||
m_dns_custom_hostnames.set(name, addr.to_string());
|
m_etc_hosts.set(name, addr.to_string());
|
||||||
|
|
||||||
IPv4Address reverse_addr {
|
IPv4Address reverse_addr {
|
||||||
(u8)atoi(sections[3].characters()),
|
(u8)atoi(sections[3].characters()),
|
||||||
|
@ -93,7 +92,7 @@ void LookupServer::load_etc_hosts()
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append(reverse_addr.to_string());
|
builder.append(reverse_addr.to_string());
|
||||||
builder.append(".in-addr.arpa");
|
builder.append(".in-addr.arpa");
|
||||||
m_dns_custom_hostnames.set(builder.to_string(), name);
|
m_etc_hosts.set(builder.to_string(), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ void LookupServer::service_client(RefPtr<CLocalSocket> socket)
|
||||||
|
|
||||||
Vector<String> responses;
|
Vector<String> responses;
|
||||||
|
|
||||||
if (auto known_host = m_dns_custom_hostnames.get(hostname)) {
|
if (auto known_host = m_etc_hosts.get(hostname)) {
|
||||||
responses.append(known_host.value());
|
responses.append(known_host.value());
|
||||||
} else if (!hostname.is_empty()) {
|
} else if (!hostname.is_empty()) {
|
||||||
bool did_timeout;
|
bool did_timeout;
|
||||||
|
|
|
@ -52,6 +52,6 @@ private:
|
||||||
|
|
||||||
RefPtr<CLocalServer> m_local_server;
|
RefPtr<CLocalServer> m_local_server;
|
||||||
String m_nameserver;
|
String m_nameserver;
|
||||||
HashMap<String, String> m_dns_custom_hostnames;
|
HashMap<String, String> m_etc_hosts;
|
||||||
HashMap<String, CachedLookup> m_lookup_cache;
|
HashMap<String, CachedLookup> m_lookup_cache;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue