Support DNS resolution matching a specified IP family.
The input SocketAddress for STUN host lookup is constructed with just
the hostname, so the family is AF_UNSPEC. So added an overload with a
target family to distinguish this from the family of the input addr.
Bug: webrtc:14319, webrtc:14131
Change-Id: Ia5ac5aa2e894e0c4dfb4417e3e8a76a6cec3ea71
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/270624
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Sameer Vijaykar <samvi@google.com>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@google.com>
Cr-Commit-Position: refs/heads/main@{#37750}
diff --git a/api/async_dns_resolver.h b/api/async_dns_resolver.h
index 138503b..82d80de 100644
--- a/api/async_dns_resolver.h
+++ b/api/async_dns_resolver.h
@@ -14,6 +14,7 @@
#include <functional>
#include <memory>
+#include "rtc_base/checks.h"
#include "rtc_base/socket_address.h"
#include "rtc_base/system/rtc_export.h"
@@ -63,6 +64,10 @@
// Start address resolution of the hostname in `addr`.
virtual void Start(const rtc::SocketAddress& addr,
std::function<void()> callback) = 0;
+ // Start address resolution of the hostname in `addr` matching `family`.
+ virtual void Start(const rtc::SocketAddress& addr,
+ int family,
+ std::function<void()> callback) = 0;
virtual const AsyncDnsResolverResult& result() const = 0;
};
@@ -79,6 +84,14 @@
virtual std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAndResolve(
const rtc::SocketAddress& addr,
std::function<void()> callback) = 0;
+ // Creates an AsyncDnsResolver and starts resolving the name to an address
+ // matching the specified family. The callback will be called when resolution
+ // is finished. The callback will be called on the sequence that the caller
+ // runs on.
+ virtual std::unique_ptr<webrtc::AsyncDnsResolverInterface> CreateAndResolve(
+ const rtc::SocketAddress& addr,
+ int family,
+ std::function<void()> callback) = 0;
// Creates an AsyncDnsResolver and does not start it.
// For backwards compatibility, will be deprecated and removed.
// One has to do a separate Start() call on the