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

Commit bf52841c authored by Mike Yu's avatar Mike Yu
Browse files

Add toString for DnsTlsServer

This toString() will output the IP address as well as the provider
hostname. It makes the log clearer to tell us whether a private DNS
is for opportunistic or strict mode.

Test: atest
Change-Id: Ie260ced35be234190e6fca137c45a8944ff0d35c
parent 930b664a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ std::list<DnsTlsServer> DnsTlsDispatcher::getOrderedAndUsableServerList(
                if (!xport->usable()) {
                    // Don't use this xport. It will be removed after timeout
                    // (IDLE_TIMEOUT minutes).
                    LOG(DEBUG) << "Skip using DoT server " << tlsServer.toIpString() << " on "
                    LOG(DEBUG) << "Skip using DoT server " << tlsServer.toString() << " on "
                               << netId;
                    continue;
                }
@@ -231,7 +231,7 @@ DnsTlsTransport::Response DnsTlsDispatcher::query(const DnsTlsServer& server, un
            // a new xport will be created.
            const auto result = PrivateDnsConfiguration::getInstance().requestDotValidation(
                    netId, PrivateDnsConfiguration::ServerIdentity{server}, mark);
            LOG(WARNING) << "Requested validation for " << server.toIpString() << " with mark 0x"
            LOG(WARNING) << "Requested validation for " << server.toString() << " with mark 0x"
                         << std::hex << mark << ", "
                         << (result.ok() ? "succeeded" : "failed: " + result.error().message());
        }
@@ -327,7 +327,7 @@ DnsTlsDispatcher::Transport* DnsTlsDispatcher::addTransport(const DnsTlsServer&
    ret = new Transport(server, mark, netId, mFactory.get(), triggerThr, unusableThr, queryTimeout);
    LOG(INFO) << "Transport is initialized with { " << triggerThr << ", " << unusableThr << ", "
              << queryTimeout << "ms }"
              << " for server { " << server.toIpString() << "/" << server.name << " }";
              << " for server " << server.toString();

    mStore[key].reset(ret);

+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <algorithm>

#include <android-base/format.h>
#include <netdutils/InternetAddresses.h>

namespace {
@@ -130,5 +131,9 @@ std::string DnsTlsServer::toIpString() const {
    return netdutils::IPSockAddr::toIPSockAddr(ss).ip().toString();
}

std::string DnsTlsServer::toString() const {
    return fmt::format("{{{}/{}}}", toIpString(), name);
}

}  // namespace net
}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ struct DnsTlsServer {

    bool wasExplicitlyConfigured() const;
    std::string toIpString() const;
    std::string toString() const;

    std::string provider() const { return name; }
    netdutils::IPSockAddr addr() const { return netdutils::IPSockAddr::toIPSockAddr(ss); }
+2 −2
Original line number Diff line number Diff line
@@ -365,11 +365,11 @@ void PrivateDnsConfiguration::startDotValidation(const ServerIdentity& identity,
        while (true) {
            // ::validate() is a blocking call that performs network operations.
            // It can take milliseconds to minutes, up to the SYN retry limit.
            LOG(WARNING) << "Validating DnsTlsServer " << server.toIpString() << " with mark 0x"
            LOG(WARNING) << "Validating DnsTlsServer " << server.toString() << " with mark 0x"
                         << std::hex << server.validationMark();
            const bool success = DnsTlsTransport::validate(server, server.validationMark());
            LOG(WARNING) << "validateDnsTlsServer returned " << success << " for "
                         << server.toIpString();
                         << server.toString();

            const bool needs_reeval =
                    this->recordDotValidation(identity, netId, success, isRevalidation);