Loading Experiments.h +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class Experiments { "dot_validation_latency_factor", "dot_validation_latency_offset_ms", "doh", "doh_query_timeout_ms", "doh_probe_timeout_ms", "mdns_resolution", }; // This value is used in updateInternal as the default value if any flags can't be found. Loading PrivateDnsConfiguration.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -462,8 +462,13 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark, mPrivateDnsLog.push(std::move(record)); LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name; int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs); if (probeTimeout < 1000) { probeTimeout = 1000; } return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(), dohId.ipAddr.c_str(), mark, caCert.c_str(), 3000); dohId.ipAddr.c_str(), mark, caCert.c_str(), probeTimeout); } LOG(INFO) << __func__ << ": No suitable DoH server found"; Loading PrivateDnsConfiguration.h +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ struct PrivateDnsStatus { class PrivateDnsConfiguration { public: static constexpr int kDohQueryDefaultTimeoutMs = 30000; static constexpr int kDohProbeDefaultTimeoutMs = 60000; struct ServerIdentity { const netdutils::IPSockAddr sockaddr; const std::string provider; Loading res_send.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ using android::net::DnsQueryEvent; using android::net::DnsTlsDispatcher; using android::net::DnsTlsServer; using android::net::DnsTlsTransport; using android::net::Experiments; using android::net::IpVersion; using android::net::IV_IPV4; using android::net::IV_IPV6; Loading Loading @@ -1393,7 +1394,12 @@ ssize_t res_doh_send(ResState* statp, const Slice query, const Slice answer, int const unsigned netId = statp->netid; LOG(INFO) << __func__ << ": performing query over Https"; Stopwatch queryStopwatch; ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, /*timeoutMs*/ 2000); int queryTimeout = Experiments::getInstance()->getFlag( "doh_query_timeout_ms", PrivateDnsConfiguration::kDohQueryDefaultTimeoutMs); if (queryTimeout < 1000) { queryTimeout = 1000; } ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, queryTimeout); LOG(INFO) << __func__ << ": Https query result: " << result; if (result == RESULT_CAN_NOT_SEND) return RESULT_CAN_NOT_SEND; Loading tests/resolv_private_dns_test.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ using android::netdutils::Stopwatch; using std::chrono::milliseconds; const std::string kDohFlag("persist.device_config.netd_native.doh"); const std::string kDohQueryTimeoutFlag("persist.device_config.netd_native.doh_query_timeout_ms"); const std::string kDohProbeTimeoutFlag("persist.device_config.netd_native.doh_probe_timeout_ms"); namespace { Loading Loading @@ -153,6 +155,11 @@ class BasePrivateDnsTest : public BaseTest { protected: void SetUp() override { mDohScopedProp = make_unique<ScopedSystemProperties>(kDohFlag, "1"); mDohQueryTimeoutScopedProp = make_unique<ScopedSystemProperties>(kDohQueryTimeoutFlag, "1000"); unsigned int expectedProbeTimeout = kExpectedDohValidationTimeWhenTimeout.count(); mDohProbeTimeoutScopedProp = make_unique<ScopedSystemProperties>( kDohProbeTimeoutFlag, std::to_string(expectedProbeTimeout)); BaseTest::SetUp(); static const std::vector<DnsRecord> records = { Loading Loading @@ -195,7 +202,7 @@ class BasePrivateDnsTest : public BaseTest { std::this_thread::sleep_for(kExpectedDohValidationTimeWhenServerUnreachable); } static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{3000}; static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{1000}; static constexpr milliseconds kExpectedDohValidationTimeWhenServerUnreachable{1000}; static constexpr char kQueryHostname[] = "TransportParameterizedTest.example.com."; static constexpr char kQueryAnswerA[] = "1.2.3.4"; Loading @@ -207,8 +214,10 @@ class BasePrivateDnsTest : public BaseTest { test::DNSResponder doh_backend{"127.0.1.3", "53"}; test::DNSResponder dot_backend{"127.0.2.3", "53"}; // Used to enable DoH during the tests. // Used to enable DoH during the tests and set up a shorter timeout. std::unique_ptr<ScopedSystemProperties> mDohScopedProp; std::unique_ptr<ScopedSystemProperties> mDohQueryTimeoutScopedProp; std::unique_ptr<ScopedSystemProperties> mDohProbeTimeoutScopedProp; }; // Parameterized test for the combination of DoH and DoT. Loading Loading
Experiments.h +2 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,8 @@ class Experiments { "dot_validation_latency_factor", "dot_validation_latency_offset_ms", "doh", "doh_query_timeout_ms", "doh_probe_timeout_ms", "mdns_resolution", }; // This value is used in updateInternal as the default value if any flags can't be found. Loading
PrivateDnsConfiguration.cpp +6 −1 Original line number Diff line number Diff line Loading @@ -462,8 +462,13 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark, mPrivateDnsLog.push(std::move(record)); LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name; int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs); if (probeTimeout < 1000) { probeTimeout = 1000; } return doh_net_new(mDohDispatcher, netId, dohId.httpsTemplate.c_str(), dohId.host.c_str(), dohId.ipAddr.c_str(), mark, caCert.c_str(), 3000); dohId.ipAddr.c_str(), mark, caCert.c_str(), probeTimeout); } LOG(INFO) << __func__ << ": No suitable DoH server found"; Loading
PrivateDnsConfiguration.h +3 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,9 @@ struct PrivateDnsStatus { class PrivateDnsConfiguration { public: static constexpr int kDohQueryDefaultTimeoutMs = 30000; static constexpr int kDohProbeDefaultTimeoutMs = 60000; struct ServerIdentity { const netdutils::IPSockAddr sockaddr; const std::string provider; Loading
res_send.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -128,6 +128,7 @@ using android::net::DnsQueryEvent; using android::net::DnsTlsDispatcher; using android::net::DnsTlsServer; using android::net::DnsTlsTransport; using android::net::Experiments; using android::net::IpVersion; using android::net::IV_IPV4; using android::net::IV_IPV6; Loading Loading @@ -1393,7 +1394,12 @@ ssize_t res_doh_send(ResState* statp, const Slice query, const Slice answer, int const unsigned netId = statp->netid; LOG(INFO) << __func__ << ": performing query over Https"; Stopwatch queryStopwatch; ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, /*timeoutMs*/ 2000); int queryTimeout = Experiments::getInstance()->getFlag( "doh_query_timeout_ms", PrivateDnsConfiguration::kDohQueryDefaultTimeoutMs); if (queryTimeout < 1000) { queryTimeout = 1000; } ssize_t result = privateDnsConfiguration.dohQuery(netId, query, answer, queryTimeout); LOG(INFO) << __func__ << ": Https query result: " << result; if (result == RESULT_CAN_NOT_SEND) return RESULT_CAN_NOT_SEND; Loading
tests/resolv_private_dns_test.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ using android::netdutils::Stopwatch; using std::chrono::milliseconds; const std::string kDohFlag("persist.device_config.netd_native.doh"); const std::string kDohQueryTimeoutFlag("persist.device_config.netd_native.doh_query_timeout_ms"); const std::string kDohProbeTimeoutFlag("persist.device_config.netd_native.doh_probe_timeout_ms"); namespace { Loading Loading @@ -153,6 +155,11 @@ class BasePrivateDnsTest : public BaseTest { protected: void SetUp() override { mDohScopedProp = make_unique<ScopedSystemProperties>(kDohFlag, "1"); mDohQueryTimeoutScopedProp = make_unique<ScopedSystemProperties>(kDohQueryTimeoutFlag, "1000"); unsigned int expectedProbeTimeout = kExpectedDohValidationTimeWhenTimeout.count(); mDohProbeTimeoutScopedProp = make_unique<ScopedSystemProperties>( kDohProbeTimeoutFlag, std::to_string(expectedProbeTimeout)); BaseTest::SetUp(); static const std::vector<DnsRecord> records = { Loading Loading @@ -195,7 +202,7 @@ class BasePrivateDnsTest : public BaseTest { std::this_thread::sleep_for(kExpectedDohValidationTimeWhenServerUnreachable); } static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{3000}; static constexpr milliseconds kExpectedDohValidationTimeWhenTimeout{1000}; static constexpr milliseconds kExpectedDohValidationTimeWhenServerUnreachable{1000}; static constexpr char kQueryHostname[] = "TransportParameterizedTest.example.com."; static constexpr char kQueryAnswerA[] = "1.2.3.4"; Loading @@ -207,8 +214,10 @@ class BasePrivateDnsTest : public BaseTest { test::DNSResponder doh_backend{"127.0.1.3", "53"}; test::DNSResponder dot_backend{"127.0.2.3", "53"}; // Used to enable DoH during the tests. // Used to enable DoH during the tests and set up a shorter timeout. std::unique_ptr<ScopedSystemProperties> mDohScopedProp; std::unique_ptr<ScopedSystemProperties> mDohQueryTimeoutScopedProp; std::unique_ptr<ScopedSystemProperties> mDohProbeTimeoutScopedProp; }; // Parameterized test for the combination of DoH and DoT. Loading