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

Commit cb206f26 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Make resolverOptions optional in DnsResolver.

The only change is currently to make resolverOptions optional.

Test: m
Bug: 194048056
Change-Id: I42a07d2bad1b3ee0e66e3f4e2a0f068686e1d1a3
Merged-In: I42a07d2bad1b3ee0e66e3f4e2a0f068686e1d1a3
parent 81f081cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ cc_library_headers {
    ],
}

dnsresolver_aidl_interface_lateststable_version = "V8"
dnsresolver_aidl_interface_lateststable_version = "V9"

cc_library_static {
    name: "dnsresolver_aidl_interface-lateststable-ndk_platform",
+17 −12
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@
#include "util.h"

using aidl::android::net::IDnsResolver;
using aidl::android::net::ResolverOptionsParcel;
using android::base::StringAppendF;
using android::net::DnsQueryEvent;
using android::net::DnsStats;
@@ -1600,7 +1601,7 @@ std::vector<std::string> getCustomizedTableByName(const size_t netid, const char

int resolv_set_nameservers(unsigned netid, const std::vector<std::string>& servers,
                           const std::vector<std::string>& domains, const res_params& params,
                           const aidl::android::net::ResolverOptionsParcel& resolverOptions,
                           const std::optional<ResolverOptionsParcel> optionalResolverOptions,
                           const std::vector<int32_t>& transportTypes) {
    std::vector<std::string> nameservers = filter_nameservers(servers);
    const int numservers = static_cast<int>(nameservers.size());
@@ -1655,6 +1656,9 @@ int resolv_set_nameservers(unsigned netid, const std::vector<std::string>& serve
        return -EINVAL;
    }
    netconfig->customizedTable.clear();

    if (optionalResolverOptions.has_value()) {
        const ResolverOptionsParcel& resolverOptions = optionalResolverOptions.value();
        for (const auto& host : resolverOptions.hosts) {
            if (!host.hostName.empty() && !host.ipAddr.empty())
                netconfig->customizedTable.emplace(host.hostName, host.ipAddr);
@@ -1668,6 +1672,7 @@ int resolv_set_nameservers(unsigned netid, const std::vector<std::string>& serve
        }
        netconfig->tc_mode = resolverOptions.tcMode;
        netconfig->enforceDnsUid = resolverOptions.enforceDnsUid;
    }

    netconfig->transportTypes = transportTypes;

+1 −4
Original line number Diff line number Diff line
@@ -79,10 +79,7 @@ std::vector<std::string> getCustomizedTableByName(const size_t netid, const char
// TODO: Pass all of ResolverParamsParcel and remove the res_params argument.
int resolv_set_nameservers(unsigned netid, const std::vector<std::string>& servers,
                           const std::vector<std::string>& domains, const res_params& params,
                           const aidl::android::net::ResolverOptionsParcel& resolverOptions =
                                   {{} /* hosts */,
                                    aidl::android::net::IDnsResolver::TC_MODE_DEFAULT,
                                    false /* enforceDnsUid */},
                           std::optional<aidl::android::net::ResolverOptionsParcel> resolverOptions,
                           const std::vector<int32_t>& transportTypes = {});

// Creates the cache associated with the given network.
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ static const char* ANDROID_DNS_MODE = "ANDROID_DNS_MODE";

using aidl::android::net::IDnsResolver;
using aidl::android::net::INetd;
using aidl::android::net::ResolverOptionsParcel;
using aidl::android::net::ResolverParamsParcel;
using android::net::ResolverStats;

@@ -77,6 +78,7 @@ ResolverParamsParcel DnsResponderClient::makeResolverParamsParcel(
    paramsParcel.tlsServers = tlsServers;
    paramsParcel.tlsFingerprints = {};
    paramsParcel.caCertificate = caCert;
    paramsParcel.resolverOptions = ResolverOptionsParcel{};  // optional, must be explicitly set.

    // Note, do not remove this otherwise the ResolverTest#ConnectTlsServerTimeout won't pass in M4
    // module.
+3 −2
Original line number Diff line number Diff line
@@ -208,9 +208,10 @@ class DnsResolverBinderTest : public ::testing::Test {
        return o;
    }

    std::string toString(const ResolverOptionsParcel& parms) {
    std::string toString(const std::optional<ResolverOptionsParcel>& parms) {
        if (!parms.has_value()) return "(null)";
        return fmt::format("ResolverOptionsParcel{{hosts: [{}], tcMode: {}, enforceDnsUid: {}}}",
                           toString(parms.hosts), parms.tcMode, parms.enforceDnsUid);
                           toString(parms->hosts), parms->tcMode, parms->enforceDnsUid);
    }

    std::string toString(const ResolverParamsParcel& parms) {
Loading