Loading Android.bp +18 −39 Original line number Diff line number Diff line Loading @@ -326,24 +326,25 @@ filegroup { ], } rust_ffi_static { name: "libdoh_ffi", crate_name: "doh", srcs: ["doh.rs"], edition: "2018", rlibs: [ doh_rust_deps = [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche", "libring", "libtokio", "liburl", ], ] rust_ffi_static { name: "libdoh_ffi", crate_name: "doh", srcs: ["doh/doh.rs"], edition: "2018", rlibs: doh_rust_deps + ["libquiche"], prefer_rlib: true, shared_libs: [ Loading @@ -361,25 +362,14 @@ rust_ffi_static { rust_test { name: "doh_unit_test", crate_name: "doh", srcs: ["doh.rs"], srcs: ["doh/doh.rs"], edition: "2018", test_suites: ["general-tests"], auto_gen_config: true, // Used to enable root permission for the test. // TODO: remove after 'require_root' is supported in rust_test. test_config_template: ":resolv_rust_test_config_template", rustlibs: [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche_static", "libring", "libtokio", "liburl", ], rustlibs: doh_rust_deps + ["libquiche_static"], min_sdk_version: "29", } Loading @@ -387,21 +377,10 @@ rust_test { rust_ffi_static { name: "libdoh_ffi_for_test", crate_name: "doh", srcs: ["doh.rs"], srcs: ["doh/doh.rs"], edition: "2018", rlibs: [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche_static", "libring", "libtokio", "liburl", ], rlibs: doh_rust_deps + ["libquiche_static"], prefer_rlib: true, // TODO(b/194022174), for unit tests to run on the Android 10 platform, // libunwind must be statically linked. Loading DnsResolver.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ bool resolv_init(const ResolverNetdCallbacks* callbacks) { // TODO(b/170539625): restore log level to WARNING after clarifying flaky tests. const bool isDebug = isUserDebugBuild(); resolv_set_log_severity(isDebug ? android::base::DEBUG : android::base::WARNING); doh_init_logger(isDebug ? LOG_LEVEL_DEBUG : LOG_LEVEL_WARN); doh_init_logger(isDebug ? DOH_LOG_LEVEL_DEBUG : DOH_LOG_LEVEL_WARN); using android::net::gApiLevel; gApiLevel = getApiLevel(); using android::net::gResNetdCallbacks; Loading PrivateDnsConfiguration.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "ResolverEventReporter.h" #include "doh.h" #include "netd_resolv/resolv.h" #include "resolv_cache.h" #include "resolv_private.h" #include "util.h" Loading Loading @@ -476,6 +477,7 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark, dohId.status); mPrivateDnsLog.push(std::move(record)); LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name; resolv_stats_set_addrs(netId, PROTO_DOH, {dohId.ipAddr}, 443); int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs); Loading @@ -495,6 +497,7 @@ void PrivateDnsConfiguration::clearDohLocked(unsigned netId) { LOG(DEBUG) << "PrivateDnsConfiguration::clearDohLocked (" << netId << ")"; if (mDohDispatcher != nullptr) doh_net_delete(mDohDispatcher, netId); mDohTracker.erase(netId); resolv_stats_set_addrs(netId, PROTO_DOH, {}, 443); } void PrivateDnsConfiguration::clearDoh(unsigned netId) { Loading @@ -507,7 +510,7 @@ ssize_t PrivateDnsConfiguration::dohQuery(unsigned netId, const Slice query, con { std::lock_guard guard(mPrivateDnsLock); // It's safe because mDohDispatcher won't be deleted after initializing. if (mDohDispatcher == nullptr) return RESULT_CAN_NOT_SEND; if (mDohDispatcher == nullptr) return DOH_RESULT_CAN_NOT_SEND; } return doh_query(mDohDispatcher, netId, query.base(), query.size(), answer.base(), answer.size(), timeoutMs); Loading ResolverController.cpp +4 −13 Original line number Diff line number Diff line Loading @@ -228,22 +228,13 @@ int ResolverController::setResolverConfiguration(const ResolverParamsParcel& res } if (isDoHEnabled()) { if (err = privateDnsConfiguration.setDoh(resolverParams.netId, netcontext.app_mark, tlsServers, resolverParams.tlsName, resolverParams.caCertificate); err != 0) { return err; } auto result = privateDnsConfiguration.getDohServer(resolverParams.netId); if (result.ok()) { const netdutils::IPSockAddr sockAddr = result.value(); if (err = resolv_stats_set_addrs(resolverParams.netId, PROTO_DOH, {sockAddr.ip().toString()}, sockAddr.port()); err != 0) { err = privateDnsConfiguration.setDoh(resolverParams.netId, netcontext.app_mark, tlsServers, resolverParams.tlsName, resolverParams.caCertificate); if (err != 0) { return err; } } } res_params res_params = {}; res_params.sample_validity = resolverParams.sampleValiditySeconds; Loading doh.h +11 −8 Original line number Diff line number Diff line Loading @@ -26,28 +26,28 @@ #include <sys/types.h> /// The return code of doh_query means that there is no answer. static const ssize_t RESULT_INTERNAL_ERROR = -1; static const ssize_t DOH_RESULT_INTERNAL_ERROR = -1; /// The return code of doh_query means that query can't be sent. static const ssize_t RESULT_CAN_NOT_SEND = -2; static const ssize_t DOH_RESULT_CAN_NOT_SEND = -2; /// The return code of doh_query to indicate that the query timed out. static const ssize_t RESULT_TIMEOUT = -255; static const ssize_t DOH_RESULT_TIMEOUT = -255; /// The error log level. static const uint32_t LOG_LEVEL_ERROR = 0; static const uint32_t DOH_LOG_LEVEL_ERROR = 0; /// The warning log level. static const uint32_t LOG_LEVEL_WARN = 1; static const uint32_t DOH_LOG_LEVEL_WARN = 1; /// The info log level. static const uint32_t LOG_LEVEL_INFO = 2; static const uint32_t DOH_LOG_LEVEL_INFO = 2; /// The debug log level. static const uint32_t LOG_LEVEL_DEBUG = 3; static const uint32_t DOH_LOG_LEVEL_DEBUG = 3; /// The trace log level. static const uint32_t LOG_LEVEL_TRACE = 4; static const uint32_t DOH_LOG_LEVEL_TRACE = 4; /// Context for a running DoH engine. struct DohDispatcher; Loading @@ -60,9 +60,12 @@ using TagSocketCallback = void (*)(int32_t sock); extern "C" { /// Performs static initialization for android logger. /// If an invalid level is passed, defaults to logging errors only. /// If called more than once, it will have no effect on subsequent calls. void doh_init_logger(uint32_t level); /// Set the log level. /// If an invalid level is passed, defaults to logging errors only. void doh_set_log_level(uint32_t level); /// Performs the initialization for the DoH engine. Loading Loading
Android.bp +18 −39 Original line number Diff line number Diff line Loading @@ -326,24 +326,25 @@ filegroup { ], } rust_ffi_static { name: "libdoh_ffi", crate_name: "doh", srcs: ["doh.rs"], edition: "2018", rlibs: [ doh_rust_deps = [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche", "libring", "libtokio", "liburl", ], ] rust_ffi_static { name: "libdoh_ffi", crate_name: "doh", srcs: ["doh/doh.rs"], edition: "2018", rlibs: doh_rust_deps + ["libquiche"], prefer_rlib: true, shared_libs: [ Loading @@ -361,25 +362,14 @@ rust_ffi_static { rust_test { name: "doh_unit_test", crate_name: "doh", srcs: ["doh.rs"], srcs: ["doh/doh.rs"], edition: "2018", test_suites: ["general-tests"], auto_gen_config: true, // Used to enable root permission for the test. // TODO: remove after 'require_root' is supported in rust_test. test_config_template: ":resolv_rust_test_config_template", rustlibs: [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche_static", "libring", "libtokio", "liburl", ], rustlibs: doh_rust_deps + ["libquiche_static"], min_sdk_version: "29", } Loading @@ -387,21 +377,10 @@ rust_test { rust_ffi_static { name: "libdoh_ffi_for_test", crate_name: "doh", srcs: ["doh.rs"], srcs: ["doh/doh.rs"], edition: "2018", rlibs: [ "libandroid_logger", "libanyhow", "libbase64_rust", "libfutures", "liblibc", "liblog_rust", "libquiche_static", "libring", "libtokio", "liburl", ], rlibs: doh_rust_deps + ["libquiche_static"], prefer_rlib: true, // TODO(b/194022174), for unit tests to run on the Android 10 platform, // libunwind must be statically linked. Loading
DnsResolver.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ bool resolv_init(const ResolverNetdCallbacks* callbacks) { // TODO(b/170539625): restore log level to WARNING after clarifying flaky tests. const bool isDebug = isUserDebugBuild(); resolv_set_log_severity(isDebug ? android::base::DEBUG : android::base::WARNING); doh_init_logger(isDebug ? LOG_LEVEL_DEBUG : LOG_LEVEL_WARN); doh_init_logger(isDebug ? DOH_LOG_LEVEL_DEBUG : DOH_LOG_LEVEL_WARN); using android::net::gApiLevel; gApiLevel = getApiLevel(); using android::net::gResNetdCallbacks; Loading
PrivateDnsConfiguration.cpp +4 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ #include "ResolverEventReporter.h" #include "doh.h" #include "netd_resolv/resolv.h" #include "resolv_cache.h" #include "resolv_private.h" #include "util.h" Loading Loading @@ -476,6 +477,7 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark, dohId.status); mPrivateDnsLog.push(std::move(record)); LOG(INFO) << __func__ << ": Upgrading server to DoH: " << name; resolv_stats_set_addrs(netId, PROTO_DOH, {dohId.ipAddr}, 443); int probeTimeout = Experiments::getInstance()->getFlag("doh_probe_timeout_ms", kDohProbeDefaultTimeoutMs); Loading @@ -495,6 +497,7 @@ void PrivateDnsConfiguration::clearDohLocked(unsigned netId) { LOG(DEBUG) << "PrivateDnsConfiguration::clearDohLocked (" << netId << ")"; if (mDohDispatcher != nullptr) doh_net_delete(mDohDispatcher, netId); mDohTracker.erase(netId); resolv_stats_set_addrs(netId, PROTO_DOH, {}, 443); } void PrivateDnsConfiguration::clearDoh(unsigned netId) { Loading @@ -507,7 +510,7 @@ ssize_t PrivateDnsConfiguration::dohQuery(unsigned netId, const Slice query, con { std::lock_guard guard(mPrivateDnsLock); // It's safe because mDohDispatcher won't be deleted after initializing. if (mDohDispatcher == nullptr) return RESULT_CAN_NOT_SEND; if (mDohDispatcher == nullptr) return DOH_RESULT_CAN_NOT_SEND; } return doh_query(mDohDispatcher, netId, query.base(), query.size(), answer.base(), answer.size(), timeoutMs); Loading
ResolverController.cpp +4 −13 Original line number Diff line number Diff line Loading @@ -228,22 +228,13 @@ int ResolverController::setResolverConfiguration(const ResolverParamsParcel& res } if (isDoHEnabled()) { if (err = privateDnsConfiguration.setDoh(resolverParams.netId, netcontext.app_mark, tlsServers, resolverParams.tlsName, resolverParams.caCertificate); err != 0) { return err; } auto result = privateDnsConfiguration.getDohServer(resolverParams.netId); if (result.ok()) { const netdutils::IPSockAddr sockAddr = result.value(); if (err = resolv_stats_set_addrs(resolverParams.netId, PROTO_DOH, {sockAddr.ip().toString()}, sockAddr.port()); err != 0) { err = privateDnsConfiguration.setDoh(resolverParams.netId, netcontext.app_mark, tlsServers, resolverParams.tlsName, resolverParams.caCertificate); if (err != 0) { return err; } } } res_params res_params = {}; res_params.sample_validity = resolverParams.sampleValiditySeconds; Loading
doh.h +11 −8 Original line number Diff line number Diff line Loading @@ -26,28 +26,28 @@ #include <sys/types.h> /// The return code of doh_query means that there is no answer. static const ssize_t RESULT_INTERNAL_ERROR = -1; static const ssize_t DOH_RESULT_INTERNAL_ERROR = -1; /// The return code of doh_query means that query can't be sent. static const ssize_t RESULT_CAN_NOT_SEND = -2; static const ssize_t DOH_RESULT_CAN_NOT_SEND = -2; /// The return code of doh_query to indicate that the query timed out. static const ssize_t RESULT_TIMEOUT = -255; static const ssize_t DOH_RESULT_TIMEOUT = -255; /// The error log level. static const uint32_t LOG_LEVEL_ERROR = 0; static const uint32_t DOH_LOG_LEVEL_ERROR = 0; /// The warning log level. static const uint32_t LOG_LEVEL_WARN = 1; static const uint32_t DOH_LOG_LEVEL_WARN = 1; /// The info log level. static const uint32_t LOG_LEVEL_INFO = 2; static const uint32_t DOH_LOG_LEVEL_INFO = 2; /// The debug log level. static const uint32_t LOG_LEVEL_DEBUG = 3; static const uint32_t DOH_LOG_LEVEL_DEBUG = 3; /// The trace log level. static const uint32_t LOG_LEVEL_TRACE = 4; static const uint32_t DOH_LOG_LEVEL_TRACE = 4; /// Context for a running DoH engine. struct DohDispatcher; Loading @@ -60,9 +60,12 @@ using TagSocketCallback = void (*)(int32_t sock); extern "C" { /// Performs static initialization for android logger. /// If an invalid level is passed, defaults to logging errors only. /// If called more than once, it will have no effect on subsequent calls. void doh_init_logger(uint32_t level); /// Set the log level. /// If an invalid level is passed, defaults to logging errors only. void doh_set_log_level(uint32_t level); /// Performs the initialization for the DoH engine. Loading