OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2012 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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 LOG_J(LS_INFO, this) << "Allocating a new socket after " | 426 LOG_J(LS_INFO, this) << "Allocating a new socket after " |
427 << "STUN_ERROR_ALLOCATION_MISMATCH, retry = " | 427 << "STUN_ERROR_ALLOCATION_MISMATCH, retry = " |
428 << allocate_mismatch_retries_ + 1; | 428 << allocate_mismatch_retries_ + 1; |
429 if (SharedSocket()) { | 429 if (SharedSocket()) { |
430 ResetSharedSocket(); | 430 ResetSharedSocket(); |
431 } else { | 431 } else { |
432 delete socket_; | 432 delete socket_; |
433 } | 433 } |
434 socket_ = NULL; | 434 socket_ = NULL; |
435 | 435 |
| 436 ResetNonce(); |
436 PrepareAddress(); | 437 PrepareAddress(); |
437 ++allocate_mismatch_retries_; | 438 ++allocate_mismatch_retries_; |
438 } | 439 } |
439 | 440 |
440 Connection* TurnPort::CreateConnection(const Candidate& address, | 441 Connection* TurnPort::CreateConnection(const Candidate& address, |
441 CandidateOrigin origin) { | 442 CandidateOrigin origin) { |
442 // TURN-UDP can only connect to UDP candidates. | 443 // TURN-UDP can only connect to UDP candidates. |
443 if (!SupportsProtocol(address.protocol())) { | 444 if (!SupportsProtocol(address.protocol())) { |
444 return NULL; | 445 return NULL; |
445 } | 446 } |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 response->GetByteString(STUN_ATTR_NONCE); | 927 response->GetByteString(STUN_ATTR_NONCE); |
927 if (!nonce_attr) { | 928 if (!nonce_attr) { |
928 LOG(LS_ERROR) << "Missing STUN_ATTR_NONCE attribute in " | 929 LOG(LS_ERROR) << "Missing STUN_ATTR_NONCE attribute in " |
929 << "stale nonce error response."; | 930 << "stale nonce error response."; |
930 return false; | 931 return false; |
931 } | 932 } |
932 set_nonce(nonce_attr->GetString()); | 933 set_nonce(nonce_attr->GetString()); |
933 return true; | 934 return true; |
934 } | 935 } |
935 | 936 |
| 937 void TurnPort::ResetNonce() { |
| 938 hash_.clear(); |
| 939 nonce_.clear(); |
| 940 realm_.clear(); |
| 941 } |
| 942 |
936 static bool MatchesIP(TurnEntry* e, rtc::IPAddress ipaddr) { | 943 static bool MatchesIP(TurnEntry* e, rtc::IPAddress ipaddr) { |
937 return e->address().ipaddr() == ipaddr; | 944 return e->address().ipaddr() == ipaddr; |
938 } | 945 } |
939 bool TurnPort::HasPermission(const rtc::IPAddress& ipaddr) const { | 946 bool TurnPort::HasPermission(const rtc::IPAddress& ipaddr) const { |
940 return (std::find_if(entries_.begin(), entries_.end(), | 947 return (std::find_if(entries_.begin(), entries_.end(), |
941 std::bind2nd(std::ptr_fun(MatchesIP), ipaddr)) != entries_.end()); | 948 std::bind2nd(std::ptr_fun(MatchesIP), ipaddr)) != entries_.end()); |
942 } | 949 } |
943 | 950 |
944 static bool MatchesAddress(TurnEntry* e, rtc::SocketAddress addr) { | 951 static bool MatchesAddress(TurnEntry* e, rtc::SocketAddress addr) { |
945 return e->address() == addr; | 952 return e->address() == addr; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 } else { | 1513 } else { |
1507 state_ = STATE_UNBOUND; | 1514 state_ = STATE_UNBOUND; |
1508 port_->DestroyConnection(ext_addr_); | 1515 port_->DestroyConnection(ext_addr_); |
1509 } | 1516 } |
1510 } | 1517 } |
1511 void TurnEntry::OnChannelBindTimeout() { | 1518 void TurnEntry::OnChannelBindTimeout() { |
1512 state_ = STATE_UNBOUND; | 1519 state_ = STATE_UNBOUND; |
1513 port_->DestroyConnection(ext_addr_); | 1520 port_->DestroyConnection(ext_addr_); |
1514 } | 1521 } |
1515 } // namespace cricket | 1522 } // namespace cricket |
OLD | NEW |