summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/p2p/base/turn_port.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/p2p/base/turn_port.cc')
-rw-r--r--third_party/libwebrtc/p2p/base/turn_port.cc26
1 files changed, 12 insertions, 14 deletions
diff --git a/third_party/libwebrtc/p2p/base/turn_port.cc b/third_party/libwebrtc/p2p/base/turn_port.cc
index e6f5e77114..1fb3b38bfd 100644
--- a/third_party/libwebrtc/p2p/base/turn_port.cc
+++ b/third_party/libwebrtc/p2p/base/turn_port.cc
@@ -228,6 +228,7 @@ TurnPort::TurnPort(TaskQueueBase* thread,
password,
field_trials),
server_address_(server_address),
+ server_url_(ReconstructServerUrl()),
tls_alpn_protocols_(tls_alpn_protocols),
tls_elliptic_curves_(tls_elliptic_curves),
tls_cert_verifier_(tls_cert_verifier),
@@ -271,6 +272,7 @@ TurnPort::TurnPort(TaskQueueBase* thread,
password,
field_trials),
server_address_(server_address),
+ server_url_(ReconstructServerUrl()),
tls_alpn_protocols_(tls_alpn_protocols),
tls_elliptic_curves_(tls_elliptic_curves),
tls_cert_verifier_(tls_cert_verifier),
@@ -583,9 +585,8 @@ Connection* TurnPort::CreateConnection(const Candidate& remote_candidate,
// and TURN candidate later.
for (size_t index = 0; index < Candidates().size(); ++index) {
const Candidate& local_candidate = Candidates()[index];
- if (local_candidate.type() == RELAY_PORT_TYPE &&
- local_candidate.address().family() ==
- remote_candidate.address().family()) {
+ if (local_candidate.is_relay() && local_candidate.address().family() ==
+ remote_candidate.address().family()) {
ProxyConnection* conn =
new ProxyConnection(NewWeakPtr(), index, remote_candidate);
// Create an entry, if needed, so we can get our permissions set up
@@ -886,7 +887,7 @@ void TurnPort::OnAllocateSuccess(const rtc::SocketAddress& address,
ProtoToString(server_address_.proto), // The first hop protocol.
"", // TCP candidate type, empty for turn candidates.
RELAY_PORT_TYPE, GetRelayPreference(server_address_.proto),
- server_priority_, ReconstructedServerUrl(), true);
+ server_priority_, server_url_, true);
}
void TurnPort::OnAllocateError(int error_code, absl::string_view reason) {
@@ -902,9 +903,8 @@ void TurnPort::OnAllocateError(int error_code, absl::string_view reason) {
address.clear();
port = 0;
}
- SignalCandidateError(
- this, IceCandidateErrorEvent(address, port, ReconstructedServerUrl(),
- error_code, reason));
+ SignalCandidateError(this, IceCandidateErrorEvent(address, port, server_url_,
+ error_code, reason));
}
void TurnPort::OnRefreshError() {
@@ -1255,15 +1255,13 @@ bool TurnPort::SetEntryChannelId(const rtc::SocketAddress& address,
return true;
}
-std::string TurnPort::ReconstructedServerUrl() {
- // draft-petithuguenin-behave-turn-uris-01
- // turnURI = scheme ":" turn-host [ ":" turn-port ]
+std::string TurnPort::ReconstructServerUrl() {
+ // https://www.rfc-editor.org/rfc/rfc7065#section-3.1
+ // turnURI = scheme ":" host [ ":" port ]
// [ "?transport=" transport ]
// scheme = "turn" / "turns"
// transport = "udp" / "tcp" / transport-ext
// transport-ext = 1*unreserved
- // turn-host = IP-literal / IPv4address / reg-name
- // turn-port = *DIGIT
std::string scheme = "turn";
std::string transport = "tcp";
switch (server_address_.proto) {
@@ -1278,7 +1276,7 @@ std::string TurnPort::ReconstructedServerUrl() {
break;
}
rtc::StringBuilder url;
- url << scheme << ":" << server_address_.address.hostname() << ":"
+ url << scheme << ":" << server_address_.address.HostAsURIString() << ":"
<< server_address_.address.port() << "?transport=" << transport;
return url.Release();
}
@@ -1802,7 +1800,7 @@ int TurnEntry::Send(const void* data,
// If the channel is bound, we can send the data as a Channel Message.
buf.WriteUInt16(channel_id_);
buf.WriteUInt16(static_cast<uint16_t>(size));
- buf.WriteBytes(reinterpret_cast<const char*>(data), size);
+ buf.WriteBytes(reinterpret_cast<const uint8_t*>(data), size);
}
rtc::PacketOptions modified_options(options);
modified_options.info_signaled_after_sent.turn_overhead_bytes =