Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5185ef47 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7608400 from c7ea829f to tm-release

Change-Id: Ie333565b400ce63f5b303f2b35b760b9a06cc85e
parents e471b93a c7ea829f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include <android-base/format.h>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
#include <android/binder_ibinder.h>
#include <netdutils/Slice.h>
#include <netdutils/ThreadUtil.h>
#include <sys/socket.h>
@@ -444,6 +445,9 @@ int PrivateDnsConfiguration::setDoh(int32_t netId, uint32_t mark,
        const auto& doh = entry.getDohIdentity(sortedServers, name);
        if (!doh.ok()) continue;

        // The internal tests are supposed to have root permission.
        if (entry.forTesting && AIBinder_getCallingUid() != AID_ROOT) continue;

        auto it = mDohTracker.find(netId);
        // Skip if the same server already exists and its status == success.
        if (it != mDohTracker.end() && it->second == doh.value() &&
+13 −3
Original line number Diff line number Diff line
@@ -200,6 +200,7 @@ class PrivateDnsConfiguration {
        std::set<std::string> ips;
        std::string host;
        std::string httpsTemplate;
        bool forTesting;
        base::Result<DohIdentity> getDohIdentity(const std::vector<std::string>& ips,
                                                 const std::string& host) const {
            if (!host.empty() && this->host != host) return Errorf("host {} not matched", host);
@@ -215,15 +216,24 @@ class PrivateDnsConfiguration {

    // TODO: Move below DoH relevant stuff into Rust implementation.
    std::map<unsigned, DohIdentity> mDohTracker GUARDED_BY(mPrivateDnsLock);
    std::array<DohProviderEntry, 2> mAvailableDoHProviders = {{
    std::array<DohProviderEntry, 3> mAvailableDoHProviders = {{
            {"Google",
             {"2001:4860:4860::8888", "2001:4860:4860::8844", "8.8.8.8", "8.8.4.4"},
             "dns.google",
             "https://dns.google/dns-query"},
             "https://dns.google/dns-query",
             false},
            {"Cloudflare",
             {"2606:4700::6810:f8f9", "2606:4700::6810:f9f9", "104.16.248.249", "104.16.249.249"},
             "cloudflare-dns.com",
             "https://cloudflare-dns.com/dns-query"},
             "https://cloudflare-dns.com/dns-query",
             false},

            // The DoH provider for testing.
            {"ResolverTestProvider",
             {"127.0.0.3", "::1"},
             "example.com",
             "https://example.com/dns-query",
             true},
    }};

    struct RecordEntry {
+3 −2
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ using android::net::IV_IPV6;
using android::net::IV_UNKNOWN;
using android::net::LinuxErrno;
using android::net::NetworkDnsEventReported;
using android::net::NS_T_AAAA;
using android::net::NS_T_INVALID;
using android::net::NsRcode;
using android::net::NsType;
@@ -472,7 +473,7 @@ int res_nsend(ResState* statp, const uint8_t* buf, int buflen, uint8_t* ans, int
        Stopwatch queryStopwatch;
        resplen = send_mdns(statp, buffer, ans, anssiz, &terrno, rcode);
        const IPSockAddr& receivedMdnsAddr =
                (getQueryType(buf, buflen) == T_AAAA) ? mdns_addrs[0] : mdns_addrs[1];
                (getQueryType(buf, buflen) == NS_T_AAAA) ? mdns_addrs[0] : mdns_addrs[1];
        DnsQueryEvent* mDnsQueryEvent = addDnsQueryEvent(statp->event);
        mDnsQueryEvent->set_cache_hit(static_cast<CacheStatus>(cache_status));
        mDnsQueryEvent->set_latency_micros(saturate_cast<int32_t>(queryStopwatch.timeTakenUs()));
@@ -1215,7 +1216,7 @@ static int send_dg(ResState* statp, res_params* params, const uint8_t* buf, int
static int send_mdns(ResState* statp, std::span<const uint8_t> buf, uint8_t* ans, int anssiz,
                     int* terrno, int* rcode) {
    const sockaddr_storage ss =
            (getQueryType(buf.data(), buf.size()) == T_AAAA) ? mdns_addrs[0] : mdns_addrs[1];
            (getQueryType(buf.data(), buf.size()) == NS_T_AAAA) ? mdns_addrs[0] : mdns_addrs[1];
    const sockaddr* mdnsap = reinterpret_cast<const sockaddr*>(&ss);
    unique_fd fd;

+3 −0
Original line number Diff line number Diff line
@@ -160,7 +160,9 @@ cc_test {
    srcs: [
        "dns_responder/dns_responder.cpp",
        "dnsresolver_binder_test.cpp",
        "doh_frontend.cpp",
        "resolv_integration_test.cpp",
        "resolv_private_dns_test.cpp",
        "tun_forwarder.cpp",
    ],
    header_libs: [
@@ -188,6 +190,7 @@ cc_test {
        "netd_event_listener_interface-lateststable-ndk_platform",
        "libipchecksum",
        "resolv_unsolicited_listener",
        "libdoh_frontend_ffi",
    ],
    // This test talks to the DnsResolver module over a binary protocol on a socket, so keep it as
    // multilib setting is worth because we might be able to get some coverage for the case where
+9 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "packages_modules_DnsResolver_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["packages_modules_DnsResolver_license"],
}

rust_ffi_static {
    name: "libdoh_frontend_ffi",
    crate_name: "doh_frontend_ffi",
Loading