| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 private: | 176 private: |
| 177 RelayEntry* entry_; | 177 RelayEntry* entry_; |
| 178 RelayConnection* connection_; | 178 RelayConnection* connection_; |
| 179 int64_t start_time_; | 179 int64_t start_time_; |
| 180 }; | 180 }; |
| 181 | 181 |
| 182 RelayPort::RelayPort(rtc::Thread* thread, | 182 RelayPort::RelayPort(rtc::Thread* thread, |
| 183 rtc::PacketSocketFactory* factory, | 183 rtc::PacketSocketFactory* factory, |
| 184 rtc::Network* network, | 184 rtc::Network* network, |
| 185 const rtc::IPAddress& ip, | |
| 186 uint16_t min_port, | 185 uint16_t min_port, |
| 187 uint16_t max_port, | 186 uint16_t max_port, |
| 188 const std::string& username, | 187 const std::string& username, |
| 189 const std::string& password) | 188 const std::string& password) |
| 190 : Port(thread, | 189 : Port(thread, |
| 191 RELAY_PORT_TYPE, | 190 RELAY_PORT_TYPE, |
| 192 factory, | 191 factory, |
| 193 network, | 192 network, |
| 194 ip, | |
| 195 min_port, | 193 min_port, |
| 196 max_port, | 194 max_port, |
| 197 username, | 195 username, |
| 198 password), | 196 password), |
| 199 ready_(false), | 197 ready_(false), |
| 200 error_(0) { | 198 error_(0) { |
| 201 entries_.push_back( | 199 entries_.push_back( |
| 202 new RelayEntry(this, rtc::SocketAddress())); | 200 new RelayEntry(this, rtc::SocketAddress())); |
| 203 // TODO: set local preference value for TCP based candidates. | 201 // TODO: set local preference value for TCP based candidates. |
| 204 } | 202 } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 | 480 |
| 483 // Try to set up our new socket. | 481 // Try to set up our new socket. |
| 484 LOG(LS_INFO) << "Connecting to relay via " << ProtoToString(ra->proto) << | 482 LOG(LS_INFO) << "Connecting to relay via " << ProtoToString(ra->proto) << |
| 485 " @ " << ra->address.ToSensitiveString(); | 483 " @ " << ra->address.ToSensitiveString(); |
| 486 | 484 |
| 487 rtc::AsyncPacketSocket* socket = NULL; | 485 rtc::AsyncPacketSocket* socket = NULL; |
| 488 | 486 |
| 489 if (ra->proto == PROTO_UDP) { | 487 if (ra->proto == PROTO_UDP) { |
| 490 // UDP sockets are simple. | 488 // UDP sockets are simple. |
| 491 socket = port_->socket_factory()->CreateUdpSocket( | 489 socket = port_->socket_factory()->CreateUdpSocket( |
| 492 rtc::SocketAddress(port_->ip(), 0), | 490 rtc::SocketAddress(port_->Network()->GetBestIP(), 0), port_->min_port(), |
| 493 port_->min_port(), port_->max_port()); | 491 port_->max_port()); |
| 494 } else if (ra->proto == PROTO_TCP || ra->proto == PROTO_SSLTCP) { | 492 } else if (ra->proto == PROTO_TCP || ra->proto == PROTO_SSLTCP) { |
| 495 int opts = (ra->proto == PROTO_SSLTCP) | 493 int opts = (ra->proto == PROTO_SSLTCP) |
| 496 ? rtc::PacketSocketFactory::OPT_TLS_FAKE | 494 ? rtc::PacketSocketFactory::OPT_TLS_FAKE |
| 497 : 0; | 495 : 0; |
| 498 socket = port_->socket_factory()->CreateClientTcpSocket( | 496 socket = port_->socket_factory()->CreateClientTcpSocket( |
| 499 rtc::SocketAddress(port_->ip(), 0), ra->address, | 497 rtc::SocketAddress(port_->Network()->GetBestIP(), 0), ra->address, |
| 500 port_->proxy(), port_->user_agent(), opts); | 498 port_->proxy(), port_->user_agent(), opts); |
| 501 } else { | 499 } else { |
| 502 LOG(LS_WARNING) << "Unknown protocol (" << ra->proto << ")"; | 500 LOG(LS_WARNING) << "Unknown protocol (" << ra->proto << ")"; |
| 503 } | 501 } |
| 504 | 502 |
| 505 if (!socket) { | 503 if (!socket) { |
| 506 LOG(LS_WARNING) << "Socket creation failed"; | 504 LOG(LS_WARNING) << "Socket creation failed"; |
| 507 } | 505 } |
| 508 | 506 |
| 509 // If we failed to get a socket, move on to the next protocol. | 507 // If we failed to get a socket, move on to the next protocol. |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 if (rtc::TimeMillis() - start_time_ <= kRetryTimeout) | 832 if (rtc::TimeMillis() - start_time_ <= kRetryTimeout) |
| 835 entry_->ScheduleKeepAlive(); | 833 entry_->ScheduleKeepAlive(); |
| 836 } | 834 } |
| 837 | 835 |
| 838 void AllocateRequest::OnTimeout() { | 836 void AllocateRequest::OnTimeout() { |
| 839 LOG(INFO) << "Allocate request timed out"; | 837 LOG(INFO) << "Allocate request timed out"; |
| 840 entry_->HandleConnectFailure(connection_->socket()); | 838 entry_->HandleConnectFailure(connection_->socket()); |
| 841 } | 839 } |
| 842 | 840 |
| 843 } // namespace cricket | 841 } // namespace cricket |
| OLD | NEW |