Index: webrtc/p2p/base/turnport.cc |
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc |
index a34d25b612357d1e422468bcba1a3db029dc75bf..ee9bb4d8215f9c4ab3be8302acb9c97071f4fdd2 100644 |
--- a/webrtc/p2p/base/turnport.cc |
+++ b/webrtc/p2p/base/turnport.cc |
@@ -44,16 +44,15 @@ inline bool IsTurnChannelData(uint16_t msg_type) { |
return ((msg_type & 0xC000) == 0x4000); // MSB are 0b01 |
} |
-static int GetRelayPreference(cricket::ProtocolType proto, bool secure) { |
- int relay_preference = ICE_TYPE_PREFERENCE_RELAY; |
- if (proto == cricket::PROTO_TCP) { |
- relay_preference -= 1; |
- if (secure) |
- relay_preference -= 1; |
+static int GetRelayPreference(cricket::ProtocolType proto) { |
+ switch (proto) { |
+ case cricket::PROTO_TCP: |
+ return ICE_TYPE_PREFERENCE_RELAY_TCP; |
+ case cricket::PROTO_TLS: |
+ return ICE_TYPE_PREFERENCE_RELAY_TLS; |
+ default: |
+ return ICE_TYPE_PREFERENCE_RELAY_UDP; |
} |
- |
- ASSERT(relay_preference >= 0); |
- return relay_preference; |
} |
class TurnAllocateRequest : public StunRequest { |
@@ -322,13 +321,19 @@ bool TurnPort::CreateTurnClientSocket() { |
if (server_address_.proto == PROTO_UDP && !SharedSocket()) { |
socket_ = socket_factory()->CreateUdpSocket( |
rtc::SocketAddress(ip(), 0), min_port(), max_port()); |
- } else if (server_address_.proto == PROTO_TCP) { |
+ } else if (server_address_.proto == PROTO_TCP || |
+ server_address_.proto == PROTO_TLS) { |
ASSERT(!SharedSocket()); |
int opts = rtc::PacketSocketFactory::OPT_STUN; |
- // If secure bit is enabled in server address, use TLS over TCP. |
- if (server_address_.secure) { |
+ |
+ // Apply server address TLS and insecure bits to options. |
+ if (server_address_.proto == PROTO_TLS) { |
opts |= rtc::PacketSocketFactory::OPT_TLS; |
} |
pthatcher1
2016/12/07 21:29:36
I like the cleanup/refactoring going on here (the
Taylor Brandstetter
2016/12/08 01:36:40
I agree, if it's not too hard to pull the two apar
hnsl1
2016/12/12 16:08:13
Okay, I'll prepare a new CL where I do the PROTO_T
|
+ if (server_address_.flags & PROTO_FLAG_INSECURE_CERT_CHECK) { |
+ opts |= rtc::PacketSocketFactory::OPT_INSECURE_CERT_CHECK; |
+ } |
+ |
socket_ = socket_factory()->CreateClientTcpSocket( |
rtc::SocketAddress(ip(), 0), server_address_.address, |
proxy(), user_agent(), opts); |
@@ -356,7 +361,8 @@ bool TurnPort::CreateTurnClientSocket() { |
// TCP port is ready to send stun requests after the socket is connected, |
// while UDP port is ready to do so once the socket is created. |
- if (server_address_.proto == PROTO_TCP) { |
+ if (server_address_.proto == PROTO_TCP || |
+ server_address_.proto == PROTO_TLS) { |
socket_->SignalConnect.connect(this, &TurnPort::OnSocketConnect); |
socket_->SignalClose.connect(this, &TurnPort::OnSocketClose); |
} else { |
@@ -652,8 +658,8 @@ bool TurnPort::SetAlternateServer(const rtc::SocketAddress& address) { |
<< "] to TURN server [" |
<< address.ToSensitiveString() |
<< "]"; |
- server_address_ = ProtocolAddress(address, server_address_.proto, |
- server_address_.secure); |
+ server_address_ = |
+ ProtocolAddress(address, server_address_.proto, server_address_.flags); |
// Insert the current address to prevent redirection pingpong. |
attempted_server_addresses_.insert(server_address_.address); |
@@ -736,8 +742,7 @@ void TurnPort::OnAllocateSuccess(const rtc::SocketAddress& address, |
UDP_PROTOCOL_NAME, |
ProtoToString(server_address_.proto), // The first hop protocol. |
"", // TCP canddiate type, empty for turn candidates. |
- RELAY_PORT_TYPE, |
- GetRelayPreference(server_address_.proto, server_address_.secure), |
+ RELAY_PORT_TYPE, GetRelayPreference(server_address_.proto), |
server_priority_, true); |
} |