mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:08:10 +00:00
LookupServer+LibC: Pass IP addresses in binary
Now that we no longer depend on the textual IPC format, we can pass IP addresses in the format most code actually has and needs it: in binary. The only places we actually have to deal with textual address representation is: * When reading /etc/hosts, we have to parse textual addresses & convert them to binary; * When doing reverse lookups, we have to form a pseudo-hostname of the form x.x.x.x.in-addr.arpa. So we do the conversion in those two cases. This also increases uniformity between how we handle A (IPv4 address) and other resource record types. Namely, we now store the raw binary data as received from a DNS server.
This commit is contained in:
parent
04ff46bff4
commit
d8967e4dff
4 changed files with 12 additions and 19 deletions
|
@ -96,9 +96,10 @@ void LookupServer::load_etc_hosts()
|
|||
(u8)atoi(sections[2].characters()),
|
||||
(u8)atoi(sections[3].characters()),
|
||||
};
|
||||
auto raw_addr = addr.to_in_addr_t();
|
||||
|
||||
auto name = fields[1];
|
||||
m_etc_hosts.set(name, addr.to_string());
|
||||
m_etc_hosts.set(name, String { (const char*)&raw_addr, sizeof(raw_addr) });
|
||||
|
||||
IPv4Address reverse_addr {
|
||||
(u8)atoi(sections[3].characters()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue