| 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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 return false; | 417 return false; |
| 418 } | 418 } |
| 419 | 419 |
| 420 // Verify the HMAC. | 420 // Verify the HMAC. |
| 421 if (nonce.substr(sizeof(then) * 2) != rtc::ComputeHmac( | 421 if (nonce.substr(sizeof(then) * 2) != rtc::ComputeHmac( |
| 422 rtc::DIGEST_MD5, nonce_key_, std::string(p, sizeof(then)))) { | 422 rtc::DIGEST_MD5, nonce_key_, std::string(p, sizeof(then)))) { |
| 423 return false; | 423 return false; |
| 424 } | 424 } |
| 425 | 425 |
| 426 // Validate the timestamp. | 426 // Validate the timestamp. |
| 427 return rtc::Time64() - then < kNonceTimeout; | 427 return rtc::TimeMillis() - then < kNonceTimeout; |
| 428 } | 428 } |
| 429 | 429 |
| 430 TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) { | 430 TurnServerAllocation* TurnServer::FindAllocation(TurnServerConnection* conn) { |
| 431 AllocationMap::const_iterator it = allocations_.find(*conn); | 431 AllocationMap::const_iterator it = allocations_.find(*conn); |
| 432 return (it != allocations_.end()) ? it->second : NULL; | 432 return (it != allocations_.end()) ? it->second : NULL; |
| 433 } | 433 } |
| 434 | 434 |
| 435 TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn, | 435 TurnServerAllocation* TurnServer::CreateAllocation(TurnServerConnection* conn, |
| 436 int proto, | 436 int proto, |
| 437 const std::string& key) { | 437 const std::string& key) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 458 << ", code=" << code << ", reason=" << reason; | 458 << ", code=" << code << ", reason=" << reason; |
| 459 SendStun(conn, &resp); | 459 SendStun(conn, &resp); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void TurnServer::SendErrorResponseWithRealmAndNonce( | 462 void TurnServer::SendErrorResponseWithRealmAndNonce( |
| 463 TurnServerConnection* conn, const StunMessage* msg, | 463 TurnServerConnection* conn, const StunMessage* msg, |
| 464 int code, const std::string& reason) { | 464 int code, const std::string& reason) { |
| 465 TurnMessage resp; | 465 TurnMessage resp; |
| 466 InitErrorResponse(msg, code, reason, &resp); | 466 InitErrorResponse(msg, code, reason, &resp); |
| 467 | 467 |
| 468 int64_t timestamp = rtc::Time64(); | 468 int64_t timestamp = rtc::TimeMillis(); |
| 469 if (ts_for_next_nonce_) { | 469 if (ts_for_next_nonce_) { |
| 470 timestamp = ts_for_next_nonce_; | 470 timestamp = ts_for_next_nonce_; |
| 471 ts_for_next_nonce_ = 0; | 471 ts_for_next_nonce_ = 0; |
| 472 } | 472 } |
| 473 VERIFY(resp.AddAttribute( | 473 VERIFY(resp.AddAttribute( |
| 474 new StunByteStringAttribute(STUN_ATTR_NONCE, GenerateNonce(timestamp)))); | 474 new StunByteStringAttribute(STUN_ATTR_NONCE, GenerateNonce(timestamp)))); |
| 475 VERIFY(resp.AddAttribute(new StunByteStringAttribute( | 475 VERIFY(resp.AddAttribute(new StunByteStringAttribute( |
| 476 STUN_ATTR_REALM, realm_))); | 476 STUN_ATTR_REALM, realm_))); |
| 477 SendStun(conn, &resp); | 477 SendStun(conn, &resp); |
| 478 } | 478 } |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 thread_->PostDelayed(kChannelTimeout, this, MSG_ALLOCATION_TIMEOUT); | 948 thread_->PostDelayed(kChannelTimeout, this, MSG_ALLOCATION_TIMEOUT); |
| 949 } | 949 } |
| 950 | 950 |
| 951 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { | 951 void TurnServerAllocation::Channel::OnMessage(rtc::Message* msg) { |
| 952 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); | 952 ASSERT(msg->message_id == MSG_ALLOCATION_TIMEOUT); |
| 953 SignalDestroyed(this); | 953 SignalDestroyed(this); |
| 954 delete this; | 954 delete this; |
| 955 } | 955 } |
| 956 | 956 |
| 957 } // namespace cricket | 957 } // namespace cricket |
| OLD | NEW |