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 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 response->GetByteString(STUN_ATTR_NONCE); | 921 response->GetByteString(STUN_ATTR_NONCE); |
921 if (!nonce_attr) { | 922 if (!nonce_attr) { |
922 LOG(LS_ERROR) << "Missing STUN_ATTR_NONCE attribute in " | 923 LOG(LS_ERROR) << "Missing STUN_ATTR_NONCE attribute in " |
923 << "stale nonce error response."; | 924 << "stale nonce error response."; |
924 return false; | 925 return false; |
925 } | 926 } |
926 set_nonce(nonce_attr->GetString()); | 927 set_nonce(nonce_attr->GetString()); |
927 return true; | 928 return true; |
928 } | 929 } |
929 | 930 |
| 931 void TurnPort::ResetNonce() { |
| 932 hash_.clear(); |
| 933 nonce_.clear(); |
| 934 realm_.clear(); |
| 935 } |
| 936 |
930 static bool MatchesIP(TurnEntry* e, rtc::IPAddress ipaddr) { | 937 static bool MatchesIP(TurnEntry* e, rtc::IPAddress ipaddr) { |
931 return e->address().ipaddr() == ipaddr; | 938 return e->address().ipaddr() == ipaddr; |
932 } | 939 } |
933 bool TurnPort::HasPermission(const rtc::IPAddress& ipaddr) const { | 940 bool TurnPort::HasPermission(const rtc::IPAddress& ipaddr) const { |
934 return (std::find_if(entries_.begin(), entries_.end(), | 941 return (std::find_if(entries_.begin(), entries_.end(), |
935 std::bind2nd(std::ptr_fun(MatchesIP), ipaddr)) != entries_.end()); | 942 std::bind2nd(std::ptr_fun(MatchesIP), ipaddr)) != entries_.end()); |
936 } | 943 } |
937 | 944 |
938 static bool MatchesAddress(TurnEntry* e, rtc::SocketAddress addr) { | 945 static bool MatchesAddress(TurnEntry* e, rtc::SocketAddress addr) { |
939 return e->address() == addr; | 946 return e->address() == addr; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1500 } else { | 1507 } else { |
1501 state_ = STATE_UNBOUND; | 1508 state_ = STATE_UNBOUND; |
1502 port_->DestroyConnection(ext_addr_); | 1509 port_->DestroyConnection(ext_addr_); |
1503 } | 1510 } |
1504 } | 1511 } |
1505 void TurnEntry::OnChannelBindTimeout() { | 1512 void TurnEntry::OnChannelBindTimeout() { |
1506 state_ = STATE_UNBOUND; | 1513 state_ = STATE_UNBOUND; |
1507 port_->DestroyConnection(ext_addr_); | 1514 port_->DestroyConnection(ext_addr_); |
1508 } | 1515 } |
1509 } // namespace cricket | 1516 } // namespace cricket |
OLD | NEW |