aboutsummaryrefslogtreecommitdiff
path: root/api/candidate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'api/candidate.cc')
-rw-r--r--api/candidate.cc19
1 files changed, 16 insertions, 3 deletions
diff --git a/api/candidate.cc b/api/candidate.cc
index c857f89c3c..d5fe3a0672 100644
--- a/api/candidate.cc
+++ b/api/candidate.cc
@@ -12,6 +12,7 @@
#include "rtc_base/helpers.h"
#include "rtc_base/ip_address.h"
+#include "rtc_base/logging.h"
#include "rtc_base/strings/string_builder.h"
namespace cricket {
@@ -129,9 +130,21 @@ Candidate Candidate::ToSanitizedCopy(bool use_hostname_address,
bool filter_related_address) const {
Candidate copy(*this);
if (use_hostname_address) {
- rtc::SocketAddress hostname_only_addr(address().hostname(),
- address().port());
- copy.set_address(hostname_only_addr);
+ rtc::IPAddress ip;
+ if (address().hostname().empty()) {
+ // IP needs to be redacted, but no hostname available.
+ rtc::SocketAddress redacted_addr("redacted-ip.invalid", address().port());
+ copy.set_address(redacted_addr);
+ } else if (IPFromString(address().hostname(), &ip)) {
+ // The hostname is an IP literal, and needs to be redacted too.
+ rtc::SocketAddress redacted_addr("redacted-literal.invalid",
+ address().port());
+ copy.set_address(redacted_addr);
+ } else {
+ rtc::SocketAddress hostname_only_addr(address().hostname(),
+ address().port());
+ copy.set_address(hostname_only_addr);
+ }
}
if (filter_related_address) {
copy.set_related_address(