aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Yu <yumike@google.com>2023-07-10 03:35:34 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-07-10 03:35:34 +0000
commitaf465d9d56dc0c1642397004fcf5383607a31b0c (patch)
treeb7714dc8316598f81f7762336a29753a7f4dccc9
parentfb137123a8c763b7a95a013fabd97435032be17c (diff)
parentbf52841c57f05b9caff97c80d2d86d59ecf609e4 (diff)
downloadDnsResolver-af465d9d56dc0c1642397004fcf5383607a31b0c.tar.gz
Add toString for DnsTlsServer am: bf52841c57
Original change: https://android-review.googlesource.com/c/platform/packages/modules/DnsResolver/+/2651940 Change-Id: Ib9889db55f1298f8f0b38d3dea5e1133871153f3 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--DnsTlsDispatcher.cpp6
-rw-r--r--DnsTlsServer.cpp5
-rw-r--r--DnsTlsServer.h1
-rw-r--r--PrivateDnsConfiguration.cpp4
4 files changed, 11 insertions, 5 deletions
diff --git a/DnsTlsDispatcher.cpp b/DnsTlsDispatcher.cpp
index 452d28b8..6e0ced2a 100644
--- a/DnsTlsDispatcher.cpp
+++ b/DnsTlsDispatcher.cpp
@@ -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);
diff --git a/DnsTlsServer.cpp b/DnsTlsServer.cpp
index 89ea8417..76825317 100644
--- a/DnsTlsServer.cpp
+++ b/DnsTlsServer.cpp
@@ -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
diff --git a/DnsTlsServer.h b/DnsTlsServer.h
index ef364942..9d2ac5e6 100644
--- a/DnsTlsServer.h
+++ b/DnsTlsServer.h
@@ -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); }
diff --git a/PrivateDnsConfiguration.cpp b/PrivateDnsConfiguration.cpp
index 013cd1a5..d32d1007 100644
--- a/PrivateDnsConfiguration.cpp
+++ b/PrivateDnsConfiguration.cpp
@@ -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);