tree: b5c462ca3116f88e99d484a65b6330cbf1d7f60e [path history] [tgz]
  1. README.md
  2. big_endian.cc
  3. big_endian.h
  4. dns_protocol.h
  5. dns_query.cc
  6. dns_query.h
  7. dns_query_test.cc
  8. dns_response.cc
  9. dns_response.h
  10. dns_response_test.cc
  11. dns_util.cc
  12. dns_util.h
  13. io_buffer.cc
  14. io_buffer.h
patchpanel/dns/README.md

DNS

This directory contains DNS library which is a modified copy of Chromium's DNS code (net/dns). The current files are taken from milestone M88 of the code with the latest commit hash of ad67ec1efbf21306b583c4daf34cf2ba4c591237.

DNS library is used by:

  • Patchpanel's multicast forwarder.
  • DNS proxy for DNS over HTTPS.

It provides DNS functionalities of:

  • Parsing DNS queries.
  • Create raw DNS responses from DNS queries' answers.

Modifications

The code here is a modification of Chromium's DNS code. The modification is done to minimize the code imported. Currently, the necessary functions we want are:

  • DnsQuery::Parse (for parsing queries),
  • DnsResponse::WriteHeader, WriteAnswer, ... (for writing raw responses).

The modification process is done by importing only the necessary functions, followed by importing the minimal amount of code necessary to make the necessary functions work. For example, functionality of writing DNS queries and parsing DNS responses are removed.

Below are the changes made:

  • Namespaces are changed from net to patchpanel.
  • All the necessary files are flattened into one directory.
  • Update NET_EXPORT with BRILLO_EXPORT.
  • Remove all unneeded functionality.

Alternatives Considered

An alternative is to having a modified copy of the Chromium's DNS code is to port the DNS code to libchrome. Although it avoids having to copy and maintain duplicated code, it has the downsides of needing to continuously update the code alongside libchrome uprevs and having to include the whole DNS code.

Another option would be to use a low level library like libbind9. One disadvantage of going with this approach is introducing additional payload by adding the development package. The API of the library is also fairly complicated and prone to introducing semantic bugs.