This CL removes all usages of our custom ostream << overloads.
This prepares us for removing them altogether. Bug: webrtc:8982 Change-Id: I66002cc8d4bf0e07925766d568d2498422f0f38e Reviewed-on: https://webrtc-review.googlesource.com/64142 Commit-Queue: Jonas Olsson <jonasolsson@webrtc.org> Reviewed-by: Henrik Grunell <henrikg@webrtc.org> Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22707}
This commit is contained in:
parent
fe9d8178df
commit
abbe841721
@ -73,8 +73,9 @@ std::string Candidate::ToStringInternal(bool sensitive) const {
|
||||
sensitive ? address_.ToSensitiveString() : address_.ToString();
|
||||
ost << "Cand[" << transport_name_ << ":" << foundation_ << ":" << component_
|
||||
<< ":" << protocol_ << ":" << priority_ << ":" << address << ":" << type_
|
||||
<< ":" << related_address_ << ":" << username_ << ":" << password_ << ":"
|
||||
<< network_id_ << ":" << network_cost_ << ":" << generation_ << "]";
|
||||
<< ":" << related_address_.ToString() << ":" << username_ << ":"
|
||||
<< password_ << ":" << network_id_ << ":" << network_cost_ << ":"
|
||||
<< generation_ << "]";
|
||||
return ost.str();
|
||||
}
|
||||
|
||||
|
||||
@ -153,7 +153,7 @@ std::string ToString(RTCErrorType error);
|
||||
#define LOG_AND_RETURN_ERROR_EX(type, message, severity) \
|
||||
{ \
|
||||
RTC_DCHECK(type != RTCErrorType::NONE); \
|
||||
RTC_LOG(severity) << message << " (" << type << ")"; \
|
||||
RTC_LOG(severity) << message << " (" << ToString(type) << ")"; \
|
||||
return webrtc::RTCError(type, message); \
|
||||
}
|
||||
|
||||
|
||||
@ -58,15 +58,6 @@ struct MoveOnlyInt2 {
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Simple test for ostream operator for RTCErrorType.
|
||||
TEST(RTCErrorTypeTest, OstreamOperator) {
|
||||
std::ostringstream oss;
|
||||
oss << webrtc::RTCErrorType::NONE << ' '
|
||||
<< webrtc::RTCErrorType::INVALID_PARAMETER << ' '
|
||||
<< webrtc::RTCErrorType::INTERNAL_ERROR;
|
||||
EXPECT_EQ("NONE INVALID_PARAMETER INTERNAL_ERROR", oss.str());
|
||||
}
|
||||
|
||||
// Test that the default constructor creates a "no error" error.
|
||||
TEST(RTCErrorTest, DefaultConstructor) {
|
||||
RTCError e;
|
||||
|
||||
@ -75,6 +75,7 @@ rtc_static_library("audio") {
|
||||
"../modules/rtp_rtcp",
|
||||
"../modules/rtp_rtcp:rtp_rtcp_format",
|
||||
"../modules/utility",
|
||||
"../rtc_base:audio_format_to_string",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rate_limiter",
|
||||
"../rtc_base:rtc_base",
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "rtc_base/event.h"
|
||||
#include "rtc_base/function_view.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
@ -509,7 +510,8 @@ bool AudioSendStream::SetupSendCodec(AudioSendStream* stream,
|
||||
spec.payload_type, spec.format, new_config.codec_pair_id);
|
||||
|
||||
if (!encoder) {
|
||||
RTC_DLOG(LS_ERROR) << "Unable to create encoder for " << spec.format;
|
||||
RTC_DLOG(LS_ERROR) << "Unable to create encoder for "
|
||||
<< rtc::ToString(spec.format);
|
||||
return false;
|
||||
}
|
||||
// If a bitrate has been specified for the codec, use it over the
|
||||
|
||||
@ -33,6 +33,7 @@ rtc_source_set("call_interfaces") {
|
||||
"../api/audio:audio_mixer_api",
|
||||
"../api/audio_codecs:audio_codecs_api",
|
||||
"../modules/audio_processing:audio_processing_statistics",
|
||||
"../rtc_base:audio_format_to_string",
|
||||
"../rtc_base:rtc_base",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
]
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
|
||||
#include "call/audio_send_stream.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -67,7 +68,7 @@ std::string AudioSendStream::Config::SendCodecSpec::ToString() const {
|
||||
ss << ", cng_payload_type: "
|
||||
<< (cng_payload_type ? rtc::ToString(*cng_payload_type) : "<unset>");
|
||||
ss << ", payload_type: " << payload_type;
|
||||
ss << ", format: " << format;
|
||||
ss << ", format: " << rtc::ToString(format);
|
||||
ss << '}';
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@ -258,6 +258,7 @@ rtc_static_library("rtc_audio_video") {
|
||||
"../modules/audio_processing/aec_dump:aec_dump",
|
||||
"../modules/video_coding:video_codec_interface",
|
||||
"../modules/video_coding:video_coding",
|
||||
"../rtc_base:audio_format_to_string",
|
||||
"../rtc_base:checks",
|
||||
]
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/race_checker.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "rtc_base/stringutils.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
@ -689,7 +690,7 @@ AudioCodecs WebRtcVoiceEngine::CollectCodecs(
|
||||
}
|
||||
} else {
|
||||
RTC_LOG(LS_ERROR) << "Unable to assign payload type to format: "
|
||||
<< format;
|
||||
<< rtc::ToString(format);
|
||||
}
|
||||
|
||||
return opt_codec;
|
||||
@ -1529,7 +1530,7 @@ bool WebRtcVoiceMediaChannel::SetRecvCodecs(
|
||||
auto format = AudioCodecToSdpAudioFormat(codec);
|
||||
if (!IsCodec(codec, "cn") && !IsCodec(codec, "telephone-event") &&
|
||||
!engine()->decoder_factory_->IsSupportedDecoder(format)) {
|
||||
RTC_LOG(LS_ERROR) << "Unsupported codec: " << format;
|
||||
RTC_LOG(LS_ERROR) << "Unsupported codec: " << rtc::ToString(format);
|
||||
return false;
|
||||
}
|
||||
// We allow adding new codecs but don't allow changing the payload type of
|
||||
|
||||
@ -148,6 +148,7 @@ rtc_static_library("audio_coding") {
|
||||
":audio_coding_module_typedefs",
|
||||
":neteq",
|
||||
":rent_a_codec",
|
||||
"../../rtc_base:audio_format_to_string",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../api:optional",
|
||||
"../../logging:rtc_event_log_api",
|
||||
@ -1087,6 +1088,7 @@ rtc_static_library("neteq") {
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../common_audio",
|
||||
"../../common_audio:common_audio_c",
|
||||
"../../rtc_base:audio_format_to_string",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:gtest_prod",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include "rtc_base/format_macros.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -260,7 +261,8 @@ bool AcmReceiver::AddCodec(int rtp_payload_type,
|
||||
neteq_->RegisterPayloadType(rtp_payload_type, audio_format);
|
||||
if (!success) {
|
||||
RTC_LOG(LERROR) << "AcmReceiver::AddCodec failed for payload type "
|
||||
<< rtp_payload_type << ", decoder format " << audio_format;
|
||||
<< rtp_payload_type << ", decoder format "
|
||||
<< rtc::ToString(audio_format);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -95,7 +96,7 @@ AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const {
|
||||
RTC_DCHECK(factory_);
|
||||
decoder_ = factory_->MakeAudioDecoder(audio_format_, codec_pair_id_);
|
||||
}
|
||||
RTC_DCHECK(decoder_) << "Failed to create: " << audio_format_;
|
||||
RTC_DCHECK(decoder_) << "Failed to create: " << rtc::ToString(audio_format_);
|
||||
return decoder_.get();
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/sanitizer.h"
|
||||
#include "rtc_base/strings/audio_format_to_string.h"
|
||||
#include "rtc_base/system/fallthrough.h"
|
||||
#include "rtc_base/trace_event.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
@ -262,7 +263,8 @@ int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder,
|
||||
bool NetEqImpl::RegisterPayloadType(int rtp_payload_type,
|
||||
const SdpAudioFormat& audio_format) {
|
||||
RTC_LOG(LS_VERBOSE) << "NetEqImpl::RegisterPayloadType: payload type "
|
||||
<< rtp_payload_type << ", codec " << audio_format;
|
||||
<< rtp_payload_type << ", codec "
|
||||
<< rtc::ToString(audio_format);
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return decoder_database_->RegisterPayload(rtp_payload_type, audio_format) ==
|
||||
DecoderDatabase::kOK;
|
||||
|
||||
@ -337,11 +337,11 @@ bool RtpPacketizerH264::NextPacket(RtpPacketToSend* rtp_packet) {
|
||||
packets_.pop();
|
||||
input_fragments_.pop_front();
|
||||
} else if (packet.aggregated) {
|
||||
RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_);
|
||||
RTC_CHECK(H264PacketizationMode::NonInterleaved == packetization_mode_);
|
||||
bool is_last_packet = num_packets_left_ == 1;
|
||||
NextAggregatePacket(rtp_packet, is_last_packet);
|
||||
} else {
|
||||
RTC_CHECK_EQ(H264PacketizationMode::NonInterleaved, packetization_mode_);
|
||||
RTC_CHECK(H264PacketizationMode::NonInterleaved == packetization_mode_);
|
||||
NextFragmentPacket(rtp_packet);
|
||||
}
|
||||
RTC_DCHECK_LE(rtp_packet->payload_size(), max_payload_len_);
|
||||
|
||||
@ -443,7 +443,8 @@ void RelayConnection::OnSendPacket(const void* data, size_t size,
|
||||
rtc::PacketOptions options; // Default dscp set to NO_CHANGE.
|
||||
int sent = socket_->SendTo(data, size, GetAddress(), options);
|
||||
if (sent <= 0) {
|
||||
RTC_LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress()
|
||||
RTC_LOG(LS_VERBOSE) << "OnSendPacket: failed sending to "
|
||||
<< GetAddress().ToString()
|
||||
<< strerror(socket_->GetError());
|
||||
RTC_DCHECK(sent < 0);
|
||||
}
|
||||
@ -652,7 +653,7 @@ void RelayEntry::OnMessage(rtc::Message *pmsg) {
|
||||
if (current_connection_) {
|
||||
const ProtocolAddress* ra = current_connection_->protocol_address();
|
||||
RTC_LOG(LS_WARNING) << "Relay " << ra->proto << " connection to "
|
||||
<< ra->address << " timed out";
|
||||
<< ra->address.ToString() << " timed out";
|
||||
|
||||
// Currently we connect to each server address in sequence. If we
|
||||
// have more addresses to try, treat this is an error and move on to
|
||||
|
||||
@ -89,8 +89,9 @@ TEST_F(StunServerTest, TestGood) {
|
||||
EXPECT_EQ(1, mapped_addr->family());
|
||||
EXPECT_EQ(client_addr.port(), mapped_addr->port());
|
||||
if (mapped_addr->ipaddr() != client_addr.ipaddr()) {
|
||||
RTC_LOG(LS_WARNING) << "Warning: mapped IP (" << mapped_addr->ipaddr()
|
||||
<< ") != local IP (" << client_addr.ipaddr() << ")";
|
||||
RTC_LOG(LS_WARNING) << "Warning: mapped IP ("
|
||||
<< mapped_addr->ipaddr().ToString() << ") != local IP ("
|
||||
<< client_addr.ipaddr().ToString() << ")";
|
||||
}
|
||||
|
||||
delete msg;
|
||||
|
||||
@ -467,8 +467,8 @@ void TurnPort::OnSocketConnect(rtc::AsyncPacketSocket* socket) {
|
||||
server_address_.address = socket_->GetRemoteAddress();
|
||||
}
|
||||
|
||||
RTC_LOG(LS_INFO) << "TurnPort connected to " << socket->GetRemoteAddress()
|
||||
<< " using tcp.";
|
||||
RTC_LOG(LS_INFO) << "TurnPort connected to "
|
||||
<< socket->GetRemoteAddress().ToString() << " using tcp.";
|
||||
SendRequest(new TurnAllocateRequest(this), 0);
|
||||
}
|
||||
|
||||
@ -584,7 +584,8 @@ int TurnPort::SendTo(const void* data, size_t size,
|
||||
// Try to find an entry for this specific address; we should have one.
|
||||
TurnEntry* entry = FindEntry(addr);
|
||||
if (!entry) {
|
||||
RTC_LOG(LS_ERROR) << "Did not find the TurnEntry for address: " << addr;
|
||||
RTC_LOG(LS_ERROR) << "Did not find the TurnEntry for address "
|
||||
<< addr.ToString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -715,7 +715,7 @@ void TurnServerAllocation::HandleSendIndication(const TurnMessage* msg) {
|
||||
RTC_LOG(LS_WARNING) << ToString()
|
||||
<< ": Received send indication without permission"
|
||||
" peer="
|
||||
<< peer_attr->GetAddress();
|
||||
<< peer_attr->GetAddress().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,7 +739,8 @@ void TurnServerAllocation::HandleCreatePermissionRequest(
|
||||
AddPermission(peer_attr->GetAddress().ipaddr());
|
||||
|
||||
RTC_LOG(LS_INFO) << ToString()
|
||||
<< ": Created permission, peer=" << peer_attr->GetAddress();
|
||||
<< ": Created permission, peer="
|
||||
<< peer_attr->GetAddress().ToString();
|
||||
|
||||
// Send a success response.
|
||||
TurnMessage response;
|
||||
@ -789,7 +790,7 @@ void TurnServerAllocation::HandleChannelBindRequest(const TurnMessage* msg) {
|
||||
|
||||
RTC_LOG(LS_INFO) << ToString()
|
||||
<< ": Bound channel, id=" << channel_id
|
||||
<< ", peer=" << peer_attr->GetAddress();
|
||||
<< ", peer=" << peer_attr->GetAddress().ToString();
|
||||
|
||||
// Send a success response.
|
||||
TurnMessage response;
|
||||
@ -841,7 +842,8 @@ void TurnServerAllocation::OnExternalPacket(
|
||||
} else {
|
||||
RTC_LOG(LS_WARNING)
|
||||
<< ToString()
|
||||
<< ": Received external packet without permission, peer=" << addr;
|
||||
<< ": Received external packet without permission, peer="
|
||||
<< addr.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -540,8 +540,8 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
||||
|
||||
uint32_t total_candidates = 0;
|
||||
if (!host_candidate_addr.IsNil()) {
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp",
|
||||
rtc::SocketAddress(kPrivateAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp",
|
||||
rtc::SocketAddress(kPrivateAddr.ipaddr(), 0)));
|
||||
++total_candidates;
|
||||
}
|
||||
if (!stun_candidate_addr.IsNil()) {
|
||||
@ -549,20 +549,23 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
||||
if (host_candidate_addr.IsNil()) {
|
||||
related_address.SetIP(rtc::GetAnyIP(stun_candidate_addr.family()));
|
||||
}
|
||||
EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(stun_candidate_addr, 0), related_address);
|
||||
EXPECT_TRUE(HasCandidateWithRelatedAddr(
|
||||
candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(stun_candidate_addr, 0), related_address));
|
||||
++total_candidates;
|
||||
}
|
||||
if (!relay_candidate_udp_transport_addr.IsNil()) {
|
||||
EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
|
||||
EXPECT_TRUE(HasCandidateWithRelatedAddr(
|
||||
candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(relay_candidate_udp_transport_addr, 0),
|
||||
rtc::SocketAddress(stun_candidate_addr, 0));
|
||||
rtc::SocketAddress(stun_candidate_addr, 0)));
|
||||
++total_candidates;
|
||||
}
|
||||
if (!relay_candidate_tcp_transport_addr.IsNil()) {
|
||||
EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
|
||||
EXPECT_TRUE(HasCandidateWithRelatedAddr(
|
||||
candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(relay_candidate_tcp_transport_addr, 0),
|
||||
rtc::SocketAddress(stun_candidate_addr, 0));
|
||||
rtc::SocketAddress(stun_candidate_addr, 0)));
|
||||
++total_candidates;
|
||||
}
|
||||
|
||||
@ -604,9 +607,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
||||
const std::vector<Candidate>& ready_candidates =
|
||||
session_->ReadyCandidates();
|
||||
EXPECT_EQ(3U, ready_candidates.size());
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
}
|
||||
|
||||
void TestUdpTurnPortPrunesTcpTurnPort() {
|
||||
@ -644,9 +647,9 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
||||
const std::vector<Candidate>& ready_candidates =
|
||||
session_->ReadyCandidates();
|
||||
EXPECT_EQ(2U, ready_candidates.size());
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
}
|
||||
|
||||
void TestEachInterfaceHasItsOwnTurnPorts() {
|
||||
@ -694,20 +697,20 @@ class BasicPortAllocatorTest : public FakeClockBase,
|
||||
const std::vector<Candidate>& ready_candidates =
|
||||
session_->ReadyCandidates();
|
||||
EXPECT_EQ(10U, ready_candidates.size());
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp", kClientAddr2);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp",
|
||||
kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "udp",
|
||||
kClientIPv6Addr2);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp", kClientAddr2);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp",
|
||||
kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "local", "tcp",
|
||||
kClientIPv6Addr2);
|
||||
EXPECT_PRED4(HasCandidate, ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "udp", kClientAddr2));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(ready_candidates, "local", "udp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(ready_candidates, "local", "udp", kClientIPv6Addr2));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "tcp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "local", "tcp", kClientAddr2));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(ready_candidates, "local", "tcp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(ready_candidates, "local", "tcp", kClientIPv6Addr2));
|
||||
EXPECT_TRUE(HasCandidate(ready_candidates, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -791,7 +794,7 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Should only get one Wi-Fi candidate.
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
|
||||
}
|
||||
|
||||
// Test that when the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set and
|
||||
@ -817,8 +820,8 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Should only get two candidates, none of which is cell.
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", unknown1);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", unknown2);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", unknown1));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", unknown2));
|
||||
}
|
||||
|
||||
// Test that when the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set and
|
||||
@ -845,7 +848,7 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Should only get one Wi-Fi candidate.
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
|
||||
}
|
||||
|
||||
// Test that if the PORTALLOCATOR_DISABLE_COSTLY_NETWORKS flag is set, but the
|
||||
@ -866,7 +869,7 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Make sure we got the cell candidate.
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", cellular);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", cellular));
|
||||
}
|
||||
|
||||
// Test that if both PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set, and there is
|
||||
@ -889,8 +892,8 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Make sure we got both wifi and cell candidates.
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi_link_local);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", cellular);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi_link_local));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", cellular));
|
||||
}
|
||||
|
||||
// Test that if both PORTALLOCATOR_DISABLE_COSTLY_NETWORKS is set, and there is
|
||||
@ -916,8 +919,8 @@ TEST_F(BasicPortAllocatorTest,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Make sure we got only wifi candidates.
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", wifi_link_local);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", wifi_link_local));
|
||||
}
|
||||
|
||||
// Test that no more than allocator.max_ipv6_networks() IPv6 networks are used
|
||||
@ -940,8 +943,8 @@ TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitEnforced) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
// Ensure the expected two interfaces (eth0 and eth1) were used.
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr2);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr2));
|
||||
}
|
||||
|
||||
// Ensure that allocator.max_ipv6_networks() doesn't prevent IPv4 networks from
|
||||
@ -966,9 +969,9 @@ TEST_F(BasicPortAllocatorTest, MaxIpv6NetworksLimitDoesNotImpactIpv4Networks) {
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
// Ensure that only one IPv6 interface was used, but both IPv4 interfaces
|
||||
// were used.
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr2);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr2));
|
||||
}
|
||||
|
||||
// Test that we could use loopback interface as host candidate.
|
||||
@ -993,14 +996,14 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(7U, candidates_.size());
|
||||
EXPECT_EQ(4U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
|
||||
kRelaySslTcpIntAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
|
||||
}
|
||||
|
||||
// Test that when the same network interface is brought down and up, the
|
||||
@ -1092,7 +1095,7 @@ TEST_F(BasicPortAllocatorTest, CandidatesRegatheredAfterBindingFails) {
|
||||
// a single TCP active candidate, since that doesn't require creating a
|
||||
// socket).
|
||||
ASSERT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
candidate_allocation_done_ = false;
|
||||
|
||||
// Now simulate the interface coming up, with the newfound ability to bind
|
||||
@ -1104,11 +1107,11 @@ TEST_F(BasicPortAllocatorTest, CandidatesRegatheredAfterBindingFails) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Should get UDP and TCP candidate.
|
||||
ASSERT_EQ(2U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
// TODO(deadbeef): This is actually the same active TCP candidate as before.
|
||||
// We should extend this test to also verify that a server candidate is
|
||||
// gathered.
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
}
|
||||
|
||||
// Verify candidates with default step delay of 1sec.
|
||||
@ -1121,13 +1124,13 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsWithOneSecondStepDelay) {
|
||||
EXPECT_EQ(2U, ports_.size());
|
||||
ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 2000, fake_clock);
|
||||
EXPECT_EQ(3U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
|
||||
kRelaySslTcpIntAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
|
||||
ASSERT_EQ_SIMULATED_WAIT(7U, candidates_.size(), 1500, fake_clock);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
EXPECT_EQ(4U, ports_.size());
|
||||
EXPECT_TRUE(candidate_allocation_done_);
|
||||
// If we Stop gathering now, we shouldn't get a second "done" callback.
|
||||
@ -1184,14 +1187,14 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsPortRange) {
|
||||
for (const Candidate& candidate : candidates_) {
|
||||
// Check the port number for the UDP/STUN/TCP port objects.
|
||||
if (candidate.type() != RELAY_PORT_TYPE) {
|
||||
EXPECT_PRED3(CheckPort, candidate.address(), kMinPort, kMaxPort);
|
||||
EXPECT_TRUE(CheckPort(candidate.address(), kMinPort, kMaxPort));
|
||||
++num_nonrelay_candidates;
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(3, num_nonrelay_candidates);
|
||||
// Check the port number used to connect to the relay server.
|
||||
EXPECT_PRED3(CheckPort, relay_server_.GetConnection(0).source(), kMinPort,
|
||||
kMaxPort);
|
||||
EXPECT_TRUE(
|
||||
CheckPort(relay_server_.GetConnection(0).source(), kMinPort, kMaxPort));
|
||||
}
|
||||
|
||||
// Test that if we have no network adapters, we bind to the ANY address and
|
||||
@ -1221,8 +1224,8 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoAdapters) {
|
||||
// candidate for it is useless and shouldn't be signaled. So we only have
|
||||
// STUN/TURN candidates.
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
|
||||
// Again, two TURN candidates, using UDP/TCP for the first hop to the TURN
|
||||
// server.
|
||||
EXPECT_EQ(2,
|
||||
@ -1355,11 +1358,11 @@ TEST_F(BasicPortAllocatorTest, TestDisableUdpTurn) {
|
||||
EXPECT_EQ(2U, ports_.size());
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
Candidate turn_candidate;
|
||||
EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp", kTurnUdpExtAddr,
|
||||
&turn_candidate);
|
||||
EXPECT_TRUE(FindCandidate(candidates_, "relay", "udp", kTurnUdpExtAddr,
|
||||
&turn_candidate));
|
||||
// The TURN candidate should use TCP to contact the TURN server.
|
||||
EXPECT_EQ(TCP_PROTOCOL_NAME, turn_candidate.relay_protocol());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
}
|
||||
|
||||
// Disable for asan, see
|
||||
@ -1388,12 +1391,12 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSockets) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(5U, candidates_.size());
|
||||
EXPECT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
|
||||
kRelaySslTcpIntAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
|
||||
}
|
||||
|
||||
#endif // if !defined(ADDRESS_SANITIZER)
|
||||
@ -1411,12 +1414,12 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpSocketsNoTcpListen) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(5U, candidates_.size());
|
||||
EXPECT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
|
||||
kRelaySslTcpIntAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
|
||||
}
|
||||
|
||||
// Test that we don't crash or malfunction if we can't create any sockets.
|
||||
@ -1442,17 +1445,17 @@ TEST_F(BasicPortAllocatorTest, TestGetAllPortsNoUdpAllowed) {
|
||||
EXPECT_EQ_SIMULATED_WAIT(2U, candidates_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
EXPECT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
// RelayPort connection timeout is 3sec. TCP connection with RelayServer
|
||||
// will be tried after about 3 seconds.
|
||||
EXPECT_EQ_SIMULATED_WAIT(6U, candidates_.size(), 3500, fake_clock);
|
||||
EXPECT_EQ(3U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "tcp", kRelayTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "ssltcp",
|
||||
kRelaySslTcpIntAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp", kRelayUdpExtAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "tcp", kRelayTcpIntAddr));
|
||||
EXPECT_TRUE(
|
||||
HasCandidate(candidates_, "relay", "ssltcp", kRelaySslTcpIntAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp", kRelayUdpExtAddr));
|
||||
// We wait at least for a full STUN timeout, which
|
||||
// cricket::STUN_TOTAL_TIMEOUT seconds. But since 3-3.5 seconds
|
||||
// already passed (see above), we wait 3 seconds less than that.
|
||||
@ -1521,8 +1524,8 @@ TEST_F(BasicPortAllocatorTest, TestCandidateFilterWithRelayOnly) {
|
||||
session_->StartGettingPorts();
|
||||
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_EQ(1U, ports_.size()); // Only Relay port will be in ready state.
|
||||
@ -1593,9 +1596,9 @@ TEST_F(BasicPortAllocatorTest, TestEnableSharedUfrag) {
|
||||
ASSERT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(7U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
EXPECT_EQ(4U, ports_.size());
|
||||
for (const Candidate& candidate : candidates_) {
|
||||
EXPECT_EQ(kIceUfrag0, candidate.username());
|
||||
@ -1616,7 +1619,7 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNat) {
|
||||
ASSERT_EQ_SIMULATED_WAIT(6U, candidates_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
EXPECT_EQ(3U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
}
|
||||
@ -1635,9 +1638,9 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNat) {
|
||||
ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
ASSERT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
|
||||
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
@ -1663,11 +1666,11 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithoutNatUsingTurn) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
ASSERT_EQ(3U, candidates_.size());
|
||||
ASSERT_EQ(3U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
}
|
||||
|
||||
// Test that if prune_turn_ports is set, TCP TURN port will not be used
|
||||
@ -1790,11 +1793,11 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurn) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
ASSERT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0));
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0)));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
// Local port will be created first and then TURN port.
|
||||
@ -1828,13 +1831,15 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAsStun) {
|
||||
ASSERT_TRUE_SIMULATED_WAIT(candidate_allocation_done_,
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
Candidate stun_candidate;
|
||||
EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
|
||||
EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
|
||||
EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
|
||||
&stun_candidate));
|
||||
EXPECT_TRUE(HasCandidateWithRelatedAddr(
|
||||
candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
|
||||
stun_candidate.address());
|
||||
stun_candidate.address()));
|
||||
|
||||
// Local port will be created first and then TURN port.
|
||||
// TODO(deadbeef): This isn't something the BasicPortAllocator API contract
|
||||
@ -1863,9 +1868,9 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnTcpOnly) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(2U, candidates_.size());
|
||||
ASSERT_EQ(2U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0)));
|
||||
EXPECT_EQ(1U, ports_[0]->Candidates().size());
|
||||
EXPECT_EQ(1U, ports_[1]->Candidates().size());
|
||||
}
|
||||
@ -1890,14 +1895,15 @@ TEST_F(BasicPortAllocatorTest, TestNonSharedSocketWithNatUsingTurnAsStun) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(3U, candidates_.size());
|
||||
ASSERT_EQ(3U, ports_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
Candidate stun_candidate;
|
||||
EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
|
||||
EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
|
||||
&stun_candidate));
|
||||
Candidate turn_candidate;
|
||||
EXPECT_PRED5(FindCandidate, candidates_, "relay", "udp",
|
||||
EXPECT_TRUE(FindCandidate(candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
|
||||
&turn_candidate);
|
||||
&turn_candidate));
|
||||
// Not using shared socket, so the STUN request's server reflexive address
|
||||
// should be different than the TURN request's server reflexive address.
|
||||
EXPECT_NE(turn_candidate.related_address(), stun_candidate.address());
|
||||
@ -1926,13 +1932,15 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketWithNatUsingTurnAndStun) {
|
||||
|
||||
ASSERT_EQ_SIMULATED_WAIT(3U, candidates_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
Candidate stun_candidate;
|
||||
EXPECT_PRED5(FindCandidate, candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0), &stun_candidate);
|
||||
EXPECT_PRED5(HasCandidateWithRelatedAddr, candidates_, "relay", "udp",
|
||||
EXPECT_TRUE(FindCandidate(candidates_, "stun", "udp",
|
||||
rtc::SocketAddress(kNatUdpAddr.ipaddr(), 0),
|
||||
&stun_candidate));
|
||||
EXPECT_TRUE(HasCandidateWithRelatedAddr(
|
||||
candidates_, "relay", "udp",
|
||||
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
|
||||
stun_candidate.address());
|
||||
stun_candidate.address()));
|
||||
|
||||
// Don't bother waiting for STUN timeout, since we already verified
|
||||
// that we got a STUN candidate from the TURN server.
|
||||
@ -1952,7 +1960,7 @@ TEST_F(BasicPortAllocatorTest, TestSharedSocketNoUdpAllowed) {
|
||||
ASSERT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
// STUN timeout is 9.5sec. We need to wait to get candidate done signal.
|
||||
EXPECT_TRUE_SIMULATED_WAIT(candidate_allocation_done_, kStunTimeoutMs,
|
||||
fake_clock);
|
||||
@ -1978,7 +1986,7 @@ TEST_F(BasicPortAllocatorTest, TestNetworkPermissionBlocked) {
|
||||
EXPECT_EQ_SIMULATED_WAIT(1U, ports_.size(), kDefaultAllocationTimeout,
|
||||
fake_clock);
|
||||
EXPECT_EQ(1U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kPrivateAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kPrivateAddr));
|
||||
EXPECT_NE(0U, session_->flags() & PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION);
|
||||
}
|
||||
|
||||
@ -1996,10 +2004,10 @@ TEST_F(BasicPortAllocatorTest, TestEnableIPv6Addresses) {
|
||||
kDefaultAllocationTimeout, fake_clock);
|
||||
EXPECT_EQ(4U, ports_.size());
|
||||
EXPECT_EQ(4U, candidates_.size());
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "udp", kClientAddr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientIPv6Addr);
|
||||
EXPECT_PRED4(HasCandidate, candidates_, "local", "tcp", kClientAddr);
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "udp", kClientAddr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientIPv6Addr));
|
||||
EXPECT_TRUE(HasCandidate(candidates_, "local", "tcp", kClientAddr));
|
||||
}
|
||||
|
||||
TEST_F(BasicPortAllocatorTest, TestStopGettingPorts) {
|
||||
|
||||
@ -527,7 +527,7 @@ TEST_P(PeerConnectionIceTest, VerifyUfragPwdLength) {
|
||||
if (candidate_ip == address.ipaddr()) {
|
||||
return ::testing::AssertionSuccess();
|
||||
}
|
||||
candidate_hosts << "\n" << candidate_ip;
|
||||
candidate_hosts << "\n" << candidate_ip.ToString();
|
||||
}
|
||||
return ::testing::AssertionFailure()
|
||||
<< address_expr << " (host " << address.HostAsURIString()
|
||||
|
||||
@ -288,39 +288,39 @@ TEST(IPAddressTest, TestCopyCtor) {
|
||||
IPAddress addr(v4addr);
|
||||
IPAddress addr2(addr);
|
||||
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(INADDR_ANY);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(INADDR_LOOPBACK);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(kIPv4PublicAddr);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(kIPv4RFC1918Addr);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(in6addr_any);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(in6addr_loopback);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(kIPv6LinkLocalAddr);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr = IPAddress(kIPv6PublicAddr);
|
||||
addr2 = IPAddress(addr);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
}
|
||||
|
||||
TEST(IPAddressTest, TestEquality) {
|
||||
@ -446,46 +446,46 @@ TEST(IPAddressTest, TestFromString) {
|
||||
|
||||
EXPECT_TRUE(IPFromString(kIPv4AnyAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv4AnyAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(INADDR_LOOPBACK);
|
||||
EXPECT_TRUE(IPFromString(kIPv4LoopbackAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv4LoopbackAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(kIPv4RFC1918Addr);
|
||||
EXPECT_TRUE(IPFromString(kIPv4RFC1918AddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv4RFC1918AddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(kIPv4PublicAddr);
|
||||
EXPECT_TRUE(IPFromString(kIPv4PublicAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv4PublicAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(in6addr_any);
|
||||
EXPECT_TRUE(IPFromString(kIPv6AnyAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv6AnyAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(in6addr_loopback);
|
||||
EXPECT_TRUE(IPFromString(kIPv6LoopbackAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv6LoopbackAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(kIPv6LinkLocalAddr);
|
||||
EXPECT_TRUE(IPFromString(kIPv6LinkLocalAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv6LinkLocalAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(kIPv6PublicAddr);
|
||||
EXPECT_TRUE(IPFromString(kIPv6PublicAddrString, &addr));
|
||||
EXPECT_EQ(addr.ToString(), kIPv6PublicAddrString);
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
addr2 = IPAddress(kIPv4MappedRFC1918Addr);
|
||||
EXPECT_TRUE(IPFromString(kIPv4MappedV4StyleAddrString, &addr));
|
||||
EXPECT_PRED2(AreEqual, addr, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr, addr2));
|
||||
|
||||
// Broken cases, should set addr to AF_UNSPEC.
|
||||
EXPECT_PRED1(BrokenIPStringFails, kIPv4BrokenString1);
|
||||
|
||||
@ -232,11 +232,12 @@ void TestPhysicalInternal(const SocketAddress& int_addr) {
|
||||
}
|
||||
}
|
||||
if (ext_addr2.IsNil()) {
|
||||
RTC_LOG(LS_WARNING) << "No available IP of same family as " << int_addr;
|
||||
RTC_LOG(LS_WARNING) << "No available IP of same family as "
|
||||
<< int_addr.ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
RTC_LOG(LS_INFO) << "selected ip " << ext_addr2.ipaddr();
|
||||
RTC_LOG(LS_INFO) << "selected ip " << ext_addr2.ipaddr().ToString();
|
||||
|
||||
SocketAddress ext_addrs[4] = {
|
||||
SocketAddress(ext_addr1),
|
||||
|
||||
@ -201,13 +201,13 @@ void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) {
|
||||
server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
|
||||
sink.Monitor(client1.get());
|
||||
EXPECT_EQ(AsyncSocket::CS_CLOSED, client1->GetState());
|
||||
EXPECT_PRED1(IsUnspecOrEmptyIP, client1->GetLocalAddress().ipaddr());
|
||||
EXPECT_TRUE(IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr()));
|
||||
|
||||
std::unique_ptr<AsyncSocket> client2(
|
||||
server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
|
||||
sink.Monitor(client2.get());
|
||||
EXPECT_EQ(AsyncSocket::CS_CLOSED, client2->GetState());
|
||||
EXPECT_PRED1(IsUnspecOrEmptyIP, client2->GetLocalAddress().ipaddr());
|
||||
EXPECT_TRUE(IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr()));
|
||||
|
||||
// Create server and listen.
|
||||
std::unique_ptr<AsyncSocket> server(
|
||||
|
||||
@ -224,7 +224,7 @@ void SocketTest::ConnectInternal(const IPAddress& loopback) {
|
||||
ss_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
|
||||
sink.Monitor(client.get());
|
||||
EXPECT_EQ(AsyncSocket::CS_CLOSED, client->GetState());
|
||||
EXPECT_PRED1(IsUnspecOrEmptyIP, client->GetLocalAddress().ipaddr());
|
||||
EXPECT_TRUE(IsUnspecOrEmptyIP(client->GetLocalAddress().ipaddr()));
|
||||
|
||||
// Create server and listen.
|
||||
std::unique_ptr<AsyncSocket> server(
|
||||
|
||||
@ -26,12 +26,11 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "rtc_base/byteorder.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/nethelpers.h"
|
||||
#include "rtc_base/strings/string_builder.h"
|
||||
|
||||
#if defined(WEBRTC_WIN)
|
||||
#include "rtc_base/win32.h"
|
||||
@ -161,21 +160,21 @@ std::string SocketAddress::HostAsSensitiveURIString() const {
|
||||
}
|
||||
|
||||
std::string SocketAddress::PortAsString() const {
|
||||
std::ostringstream ost;
|
||||
ost << port_;
|
||||
return ost.str();
|
||||
return std::to_string(port_);
|
||||
}
|
||||
|
||||
std::string SocketAddress::ToString() const {
|
||||
std::ostringstream ost;
|
||||
ost << *this;
|
||||
return ost.str();
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << HostAsURIString() << ":" << port();
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
std::string SocketAddress::ToSensitiveString() const {
|
||||
std::ostringstream ost;
|
||||
ost << HostAsSensitiveURIString() << ":" << port();
|
||||
return ost.str();
|
||||
char buf[1024];
|
||||
rtc::SimpleStringBuilder sb(buf);
|
||||
sb << HostAsSensitiveURIString() << ":" << port();
|
||||
return sb.str();
|
||||
}
|
||||
|
||||
bool SocketAddress::FromString(const std::string& str) {
|
||||
|
||||
@ -255,34 +255,34 @@ bool AreUnequal(const SocketAddress& addr1,
|
||||
TEST(SocketAddressTest, TestEqualityOperators) {
|
||||
SocketAddress addr1("1.2.3.4", 5678);
|
||||
SocketAddress addr2("1.2.3.4", 5678);
|
||||
EXPECT_PRED2(AreEqual, addr1, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress("0.0.0.1", 5678);
|
||||
EXPECT_PRED2(AreUnequal, addr1, addr2);
|
||||
EXPECT_TRUE(AreUnequal(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress("1.2.3.4", 1234);
|
||||
EXPECT_PRED2(AreUnequal, addr1, addr2);
|
||||
EXPECT_TRUE(AreUnequal(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress(kTestV6AddrString, 5678);
|
||||
EXPECT_PRED2(AreUnequal, addr1, addr2);
|
||||
EXPECT_TRUE(AreUnequal(addr1, addr2));
|
||||
|
||||
addr1 = SocketAddress(kTestV6AddrString, 5678);
|
||||
EXPECT_PRED2(AreEqual, addr1, addr2);
|
||||
EXPECT_TRUE(AreEqual(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress(kTestV6AddrString, 1234);
|
||||
EXPECT_PRED2(AreUnequal, addr1, addr2);
|
||||
EXPECT_TRUE(AreUnequal(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress("fe80::1", 5678);
|
||||
EXPECT_PRED2(AreUnequal, addr1, addr2);
|
||||
EXPECT_TRUE(AreUnequal(addr1, addr2));
|
||||
|
||||
SocketAddress addr3("a.b.c.d", 1);
|
||||
SocketAddress addr4("b.b.c.d", 1);
|
||||
EXPECT_PRED2(AreUnequal, addr3, addr4);
|
||||
EXPECT_PRED2(AreEqual, addr3, addr3);
|
||||
EXPECT_TRUE(AreUnequal(addr3, addr4));
|
||||
EXPECT_TRUE(AreEqual(addr3, addr3));
|
||||
|
||||
addr3.SetIP(addr1.ip());
|
||||
addr4.SetIP(addr1.ip());
|
||||
EXPECT_PRED2(AreEqual,addr3, addr4);
|
||||
EXPECT_TRUE(AreEqual(addr3, addr4));
|
||||
}
|
||||
|
||||
bool IsLessThan(const SocketAddress& addr1, const SocketAddress& addr2) {
|
||||
@ -299,19 +299,19 @@ TEST(SocketAddressTest, TestComparisonOperator) {
|
||||
EXPECT_FALSE(addr2 < addr1);
|
||||
|
||||
addr2 = SocketAddress("1.2.3.4", 5679);
|
||||
EXPECT_PRED2(IsLessThan, addr1, addr2);
|
||||
EXPECT_TRUE(IsLessThan(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress("2.2.3.4", 49152);
|
||||
EXPECT_PRED2(IsLessThan, addr1, addr2);
|
||||
EXPECT_TRUE(IsLessThan(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress(kTestV6AddrString, 5678);
|
||||
EXPECT_PRED2(IsLessThan, addr1, addr2);
|
||||
EXPECT_TRUE(IsLessThan(addr1, addr2));
|
||||
|
||||
addr1 = SocketAddress("fe80::1", 5678);
|
||||
EXPECT_PRED2(IsLessThan, addr2, addr1);
|
||||
EXPECT_TRUE(IsLessThan(addr2, addr1));
|
||||
|
||||
addr2 = SocketAddress("fe80::1", 5679);
|
||||
EXPECT_PRED2(IsLessThan, addr1, addr2);
|
||||
EXPECT_TRUE(IsLessThan(addr1, addr2));
|
||||
|
||||
addr2 = SocketAddress("fe80::1", 5678);
|
||||
EXPECT_FALSE(addr1 < addr2);
|
||||
@ -319,7 +319,7 @@ TEST(SocketAddressTest, TestComparisonOperator) {
|
||||
|
||||
SocketAddress addr3("a.b.c.d", 1);
|
||||
SocketAddress addr4("b.b.c.d", 1);
|
||||
EXPECT_PRED2(IsLessThan, addr3, addr4);
|
||||
EXPECT_TRUE(IsLessThan(addr3, addr4));
|
||||
}
|
||||
|
||||
TEST(SocketAddressTest, TestToSensitiveString) {
|
||||
|
||||
@ -81,7 +81,7 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> {
|
||||
}
|
||||
|
||||
int Connect(const std::string& hostname, const rtc::SocketAddress& address) {
|
||||
RTC_LOG(LS_INFO) << "Initiating connection with " << address;
|
||||
RTC_LOG(LS_INFO) << "Initiating connection with " << address.ToString();
|
||||
|
||||
int rv = ssl_adapter_->Connect(address);
|
||||
|
||||
@ -157,7 +157,7 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> {
|
||||
|
||||
RTC_LOG(LS_INFO) << ((ssl_mode_ == rtc::SSL_MODE_DTLS) ? "UDP" : "TCP")
|
||||
<< " server listening on "
|
||||
<< server_socket_->GetLocalAddress();
|
||||
<< server_socket_->GetLocalAddress().ToString();
|
||||
}
|
||||
|
||||
rtc::SocketAddress GetAddress() const {
|
||||
|
||||
@ -312,6 +312,7 @@ bool ends_with(const char *s1, const char *s2);
|
||||
// Remove leading and trailing whitespaces.
|
||||
std::string string_trim(const std::string& s);
|
||||
|
||||
// TODO(jonasolsson): replace with absl::Hex when that becomes available.
|
||||
std::string ToHex(const int i);
|
||||
} // namespace rtc
|
||||
|
||||
|
||||
@ -409,7 +409,8 @@ void VirtualSocket::OnMessage(Message* pmsg) {
|
||||
} else if ((SOCK_STREAM == type_) && (CS_CONNECTING == state_)) {
|
||||
CompleteConnect(data->addr, true);
|
||||
} else {
|
||||
RTC_LOG(LS_VERBOSE) << "Socket at " << local_addr_ << " is not listening";
|
||||
RTC_LOG(LS_VERBOSE) << "Socket at " << local_addr_.ToString()
|
||||
<< " is not listening";
|
||||
server_->Disconnect(server_->LookupBinding(data->addr));
|
||||
}
|
||||
delete data;
|
||||
@ -805,7 +806,8 @@ int VirtualSocketServer::Connect(VirtualSocket* socket,
|
||||
VirtualSocket* remote = LookupBinding(remote_addr);
|
||||
if (!CanInteractWith(socket, remote)) {
|
||||
RTC_LOG(LS_INFO) << "Address family mismatch between "
|
||||
<< socket->GetLocalAddress() << " and " << remote_addr;
|
||||
<< socket->GetLocalAddress().ToString() << " and "
|
||||
<< remote_addr.ToString();
|
||||
return -1;
|
||||
}
|
||||
if (remote != nullptr) {
|
||||
@ -813,7 +815,7 @@ int VirtualSocketServer::Connect(VirtualSocket* socket,
|
||||
msg_queue_->PostDelayed(RTC_FROM_HERE, delay, remote, MSG_ID_CONNECT,
|
||||
new MessageAddress(addr));
|
||||
} else {
|
||||
RTC_LOG(LS_INFO) << "No one listening at " << remote_addr;
|
||||
RTC_LOG(LS_INFO) << "No one listening at " << remote_addr.ToString();
|
||||
msg_queue_->PostDelayed(RTC_FROM_HERE, delay, socket, MSG_ID_DISCONNECT);
|
||||
}
|
||||
return 0;
|
||||
@ -856,17 +858,18 @@ int VirtualSocketServer::SendUdp(VirtualSocket* socket,
|
||||
dummy_socket->SetLocalAddress(remote_addr);
|
||||
if (!CanInteractWith(socket, dummy_socket.get())) {
|
||||
RTC_LOG(LS_VERBOSE) << "Incompatible address families: "
|
||||
<< socket->GetLocalAddress() << " and "
|
||||
<< remote_addr;
|
||||
<< socket->GetLocalAddress().ToString() << " and "
|
||||
<< remote_addr.ToString();
|
||||
return -1;
|
||||
}
|
||||
RTC_LOG(LS_VERBOSE) << "No one listening at " << remote_addr;
|
||||
RTC_LOG(LS_VERBOSE) << "No one listening at " << remote_addr.ToString();
|
||||
return static_cast<int>(data_size);
|
||||
}
|
||||
|
||||
if (!CanInteractWith(socket, recipient)) {
|
||||
RTC_LOG(LS_VERBOSE) << "Incompatible address families: "
|
||||
<< socket->GetLocalAddress() << " and " << remote_addr;
|
||||
<< socket->GetLocalAddress().ToString() << " and "
|
||||
<< remote_addr.ToString();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user