Refactor, prerequisite for DNS-over-TLS pipelining
This change should have no effect on behavior, but it divides functionality
out into classes in a way that will enable pipelining.
It also adds unit tests for the newly divided functionality.
Test: Unit and integration tests pass.
Bug: 63448521
Change-Id: I08948be304b7a3e4ba10f754ef58bd41db6824c4
diff --git a/server/dns/DnsTlsServer.h b/server/dns/DnsTlsServer.h
index f11c2e3..c9cbd46 100644
--- a/server/dns/DnsTlsServer.h
+++ b/server/dns/DnsTlsServer.h
@@ -35,8 +35,15 @@
// Allow sockaddr_storage to be promoted to DnsTlsServer automatically.
DnsTlsServer(const sockaddr_storage& ss) : ss(ss) {}
+ enum class Response : uint8_t { success, network_error, limit_error, internal_error };
+
+ struct Result {
+ Response code;
+ std::vector<uint8_t> response;
+ };
+
// The server location, including IP and port.
- sockaddr_storage ss;
+ sockaddr_storage ss = {};
// A set of SHA256 public key fingerprints. If this set is nonempty, the server
// must present a self-consistent certificate chain that contains a certificate