| 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 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 RTC_DCHECK(!ap.destination().IsNil()); | 235 RTC_DCHECK(!ap.destination().IsNil()); |
| 236 | 236 |
| 237 // If this connection already exists, then forward the traffic. | 237 // If this connection already exists, then forward the traffic. |
| 238 ConnectionMap::iterator piter = connections_.find(ap); | 238 ConnectionMap::iterator piter = connections_.find(ap); |
| 239 if (piter != connections_.end()) { | 239 if (piter != connections_.end()) { |
| 240 // TODO: Check the HMAC. | 240 // TODO: Check the HMAC. |
| 241 RelayServerConnection* ext_conn = piter->second; | 241 RelayServerConnection* ext_conn = piter->second; |
| 242 RelayServerConnection* int_conn = | 242 RelayServerConnection* int_conn = |
| 243 ext_conn->binding()->GetInternalConnection( | 243 ext_conn->binding()->GetInternalConnection( |
| 244 ext_conn->addr_pair().source()); | 244 ext_conn->addr_pair().source()); |
| 245 RTC_DCHECK(int_conn != NULL); | 245 RTC_DCHECK(int_conn != nullptr); |
| 246 int_conn->Send(bytes, size, ext_conn->addr_pair().source()); | 246 int_conn->Send(bytes, size, ext_conn->addr_pair().source()); |
| 247 ext_conn->Lock(); // allow outgoing packets | 247 ext_conn->Lock(); // allow outgoing packets |
| 248 return; | 248 return; |
| 249 } | 249 } |
| 250 | 250 |
| 251 // The first packet should always be a STUN / TURN packet. If it isn't, then | 251 // The first packet should always be a STUN / TURN packet. If it isn't, then |
| 252 // we should just ignore this packet. | 252 // we should just ignore this packet. |
| 253 RelayMessage msg; | 253 RelayMessage msg; |
| 254 rtc::ByteBufferReader buf(bytes, size); | 254 rtc::ByteBufferReader buf(bytes, size); |
| 255 if (!msg.Read(&buf)) { | 255 if (!msg.Read(&buf)) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 283 ext_conn->binding()->AddExternalConnection(ext_conn); | 283 ext_conn->binding()->AddExternalConnection(ext_conn); |
| 284 AddConnection(ext_conn); | 284 AddConnection(ext_conn); |
| 285 | 285 |
| 286 // We always know where external packets should be forwarded, so we can lock | 286 // We always know where external packets should be forwarded, so we can lock |
| 287 // them from the beginning. | 287 // them from the beginning. |
| 288 ext_conn->Lock(); | 288 ext_conn->Lock(); |
| 289 | 289 |
| 290 // Send this message on the appropriate internal connection. | 290 // Send this message on the appropriate internal connection. |
| 291 RelayServerConnection* int_conn = ext_conn->binding()->GetInternalConnection( | 291 RelayServerConnection* int_conn = ext_conn->binding()->GetInternalConnection( |
| 292 ext_conn->addr_pair().source()); | 292 ext_conn->addr_pair().source()); |
| 293 RTC_DCHECK(int_conn != NULL); | 293 RTC_DCHECK(int_conn != nullptr); |
| 294 int_conn->Send(bytes, size, ext_conn->addr_pair().source()); | 294 int_conn->Send(bytes, size, ext_conn->addr_pair().source()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool RelayServer::HandleStun( | 297 bool RelayServer::HandleStun( |
| 298 const char* bytes, size_t size, const rtc::SocketAddress& remote_addr, | 298 const char* bytes, size_t size, const rtc::SocketAddress& remote_addr, |
| 299 rtc::AsyncPacketSocket* socket, std::string* username, | 299 rtc::AsyncPacketSocket* socket, std::string* username, |
| 300 StunMessage* msg) { | 300 StunMessage* msg) { |
| 301 | 301 |
| 302 // Parse this into a stun message. Eat the message if this fails. | 302 // Parse this into a stun message. Eat the message if this fails. |
| 303 rtc::ByteBufferReader buf(bytes, size); | 303 rtc::ByteBufferReader buf(bytes, size); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // This call will result in all of the necessary clean-up. We can't call | 547 // This call will result in all of the necessary clean-up. We can't call |
| 548 // delete here, because you can't delete an object that is signaling you. | 548 // delete here, because you can't delete an object that is signaling you. |
| 549 thread_->Dispose(binding); | 549 thread_->Dispose(binding); |
| 550 } | 550 } |
| 551 | 551 |
| 552 void RelayServer::AcceptConnection(rtc::AsyncSocket* server_socket) { | 552 void RelayServer::AcceptConnection(rtc::AsyncSocket* server_socket) { |
| 553 // Check if someone is trying to connect to us. | 553 // Check if someone is trying to connect to us. |
| 554 rtc::SocketAddress accept_addr; | 554 rtc::SocketAddress accept_addr; |
| 555 rtc::AsyncSocket* accepted_socket = | 555 rtc::AsyncSocket* accepted_socket = |
| 556 server_socket->Accept(&accept_addr); | 556 server_socket->Accept(&accept_addr); |
| 557 if (accepted_socket != NULL) { | 557 if (accepted_socket != nullptr) { |
| 558 // We had someone trying to connect, now check which protocol to | 558 // We had someone trying to connect, now check which protocol to |
| 559 // use and create a packet socket. | 559 // use and create a packet socket. |
| 560 RTC_DCHECK(server_sockets_[server_socket] == cricket::PROTO_TCP || | 560 RTC_DCHECK(server_sockets_[server_socket] == cricket::PROTO_TCP || |
| 561 server_sockets_[server_socket] == cricket::PROTO_SSLTCP); | 561 server_sockets_[server_socket] == cricket::PROTO_SSLTCP); |
| 562 if (server_sockets_[server_socket] == cricket::PROTO_SSLTCP) { | 562 if (server_sockets_[server_socket] == cricket::PROTO_SSLTCP) { |
| 563 accepted_socket = new rtc::AsyncSSLServerSocket(accepted_socket); | 563 accepted_socket = new rtc::AsyncSSLServerSocket(accepted_socket); |
| 564 } | 564 } |
| 565 rtc::AsyncTCPSocket* tcp_socket = | 565 rtc::AsyncTCPSocket* tcp_socket = |
| 566 new rtc::AsyncTCPSocket(accepted_socket, false); | 566 new rtc::AsyncTCPSocket(accepted_socket, false); |
| 567 | 567 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 server_->thread()->PostDelayed(RTC_FROM_HERE, lifetime_, this, | 744 server_->thread()->PostDelayed(RTC_FROM_HERE, lifetime_, this, |
| 745 MSG_LIFETIME_TIMER); | 745 MSG_LIFETIME_TIMER); |
| 746 } | 746 } |
| 747 | 747 |
| 748 } else { | 748 } else { |
| 749 RTC_NOTREACHED(); | 749 RTC_NOTREACHED(); |
| 750 } | 750 } |
| 751 } | 751 } |
| 752 | 752 |
| 753 } // namespace cricket | 753 } // namespace cricket |
| OLD | NEW |