Loading DnsTlsQueryMap.h +6 −2 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace net { // All methods are thread-safe and non-blocking. // All methods are thread-safe and non-blocking. class DnsTlsQueryMap { class DnsTlsQueryMap { public: public: enum class Response : uint8_t { success, network_error, limit_error, internal_error }; struct Query { struct Query { // The new ID number assigned to this query. // The new ID number assigned to this query. uint16_t newId; uint16_t newId; Loading @@ -41,8 +43,10 @@ class DnsTlsQueryMap { const netdutils::Slice query; const netdutils::Slice query; }; }; typedef DnsTlsServer::Response Response; struct Result { typedef DnsTlsServer::Result Result; Response code; std::vector<uint8_t> response; }; struct QueryFuture { struct QueryFuture { QueryFuture(Query query, std::future<Result> result) QueryFuture(Query query, std::future<Result> result) Loading DnsTlsServer.h +0 −7 Original line number Original line Diff line number Diff line Loading @@ -37,13 +37,6 @@ struct DnsTlsServer { // Allow sockaddr_storage to be promoted to DnsTlsServer automatically. // Allow sockaddr_storage to be promoted to DnsTlsServer automatically. DnsTlsServer(const sockaddr_storage& ss) : ss(ss) {} 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. // The server location, including IP and port. sockaddr_storage ss = {}; sockaddr_storage ss = {}; Loading DnsTlsTransport.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -46,8 +46,8 @@ class DnsTlsTransport : public IDnsTlsSocketObserver { : mMark(mark), mServer(server), mFactory(factory) {} : mMark(mark), mServer(server), mFactory(factory) {} ~DnsTlsTransport(); ~DnsTlsTransport(); typedef DnsTlsServer::Response Response; using Response = DnsTlsQueryMap::Response; typedef DnsTlsServer::Result Result; using Result = DnsTlsQueryMap::Result; // Given a |query|, this method sends it to the server and returns the result asynchronously. // Given a |query|, this method sends it to the server and returns the result asynchronously. std::future<Result> query(const netdutils::Slice query) EXCLUDES(mLock); std::future<Result> query(const netdutils::Slice query) EXCLUDES(mLock); Loading resolv_tls_unit_test.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -180,9 +180,9 @@ TEST_F(TransportTest, IdReuse) { DnsTlsTransport transport(SERVER1, MARK, &factory); DnsTlsTransport transport(SERVER1, MARK, &factory); for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) { // Send a query. // Send a query. std::future<DnsTlsServer::Result> f = transport.query(makeSlice(QUERY)); std::future<DnsTlsTransport::Result> f = transport.query(makeSlice(QUERY)); // Wait for the response. // Wait for the response. DnsTlsServer::Result r = f.get(); DnsTlsTransport::Result r = f.get(); EXPECT_EQ(DnsTlsTransport::Response::success, r.code); EXPECT_EQ(DnsTlsTransport::Response::success, r.code); // All queries should have an observed ID of zero, because it is returned to the ID pool // All queries should have an observed ID of zero, because it is returned to the ID pool Loading Loading
DnsTlsQueryMap.h +6 −2 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ namespace net { // All methods are thread-safe and non-blocking. // All methods are thread-safe and non-blocking. class DnsTlsQueryMap { class DnsTlsQueryMap { public: public: enum class Response : uint8_t { success, network_error, limit_error, internal_error }; struct Query { struct Query { // The new ID number assigned to this query. // The new ID number assigned to this query. uint16_t newId; uint16_t newId; Loading @@ -41,8 +43,10 @@ class DnsTlsQueryMap { const netdutils::Slice query; const netdutils::Slice query; }; }; typedef DnsTlsServer::Response Response; struct Result { typedef DnsTlsServer::Result Result; Response code; std::vector<uint8_t> response; }; struct QueryFuture { struct QueryFuture { QueryFuture(Query query, std::future<Result> result) QueryFuture(Query query, std::future<Result> result) Loading
DnsTlsServer.h +0 −7 Original line number Original line Diff line number Diff line Loading @@ -37,13 +37,6 @@ struct DnsTlsServer { // Allow sockaddr_storage to be promoted to DnsTlsServer automatically. // Allow sockaddr_storage to be promoted to DnsTlsServer automatically. DnsTlsServer(const sockaddr_storage& ss) : ss(ss) {} 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. // The server location, including IP and port. sockaddr_storage ss = {}; sockaddr_storage ss = {}; Loading
DnsTlsTransport.h +2 −2 Original line number Original line Diff line number Diff line Loading @@ -46,8 +46,8 @@ class DnsTlsTransport : public IDnsTlsSocketObserver { : mMark(mark), mServer(server), mFactory(factory) {} : mMark(mark), mServer(server), mFactory(factory) {} ~DnsTlsTransport(); ~DnsTlsTransport(); typedef DnsTlsServer::Response Response; using Response = DnsTlsQueryMap::Response; typedef DnsTlsServer::Result Result; using Result = DnsTlsQueryMap::Result; // Given a |query|, this method sends it to the server and returns the result asynchronously. // Given a |query|, this method sends it to the server and returns the result asynchronously. std::future<Result> query(const netdutils::Slice query) EXCLUDES(mLock); std::future<Result> query(const netdutils::Slice query) EXCLUDES(mLock); Loading
resolv_tls_unit_test.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -180,9 +180,9 @@ TEST_F(TransportTest, IdReuse) { DnsTlsTransport transport(SERVER1, MARK, &factory); DnsTlsTransport transport(SERVER1, MARK, &factory); for (int i = 0; i < 100; ++i) { for (int i = 0; i < 100; ++i) { // Send a query. // Send a query. std::future<DnsTlsServer::Result> f = transport.query(makeSlice(QUERY)); std::future<DnsTlsTransport::Result> f = transport.query(makeSlice(QUERY)); // Wait for the response. // Wait for the response. DnsTlsServer::Result r = f.get(); DnsTlsTransport::Result r = f.get(); EXPECT_EQ(DnsTlsTransport::Response::success, r.code); EXPECT_EQ(DnsTlsTransport::Response::success, r.code); // All queries should have an observed ID of zero, because it is returned to the ID pool // All queries should have an observed ID of zero, because it is returned to the ID pool Loading