OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "net/quic/core/crypto/quic_encrypter.h" | 30 #include "net/quic/core/crypto/quic_encrypter.h" |
31 #include "net/quic/core/crypto/quic_random.h" | 31 #include "net/quic/core/crypto/quic_random.h" |
32 #include "net/quic/core/proto/source_address_token.pb.h" | 32 #include "net/quic/core/proto/source_address_token.pb.h" |
33 #include "net/quic/core/quic_bug_tracker.h" | 33 #include "net/quic/core/quic_bug_tracker.h" |
34 #include "net/quic/core/quic_flags.h" | 34 #include "net/quic/core/quic_flags.h" |
35 #include "net/quic/core/quic_packets.h" | 35 #include "net/quic/core/quic_packets.h" |
36 #include "net/quic/core/quic_socket_address_coder.h" | 36 #include "net/quic/core/quic_socket_address_coder.h" |
37 #include "net/quic/core/quic_utils.h" | 37 #include "net/quic/core/quic_utils.h" |
38 #include "net/quic/platform/api/quic_clock.h" | 38 #include "net/quic/platform/api/quic_clock.h" |
39 #include "net/quic/platform/api/quic_reference_counted.h" | 39 #include "net/quic/platform/api/quic_reference_counted.h" |
| 40 #include "net/quic/platform/api/quic_text_utils.h" |
40 | 41 |
41 using base::StringPiece; | 42 using base::StringPiece; |
42 using crypto::SecureHash; | 43 using crypto::SecureHash; |
43 using std::string; | 44 using std::string; |
44 | 45 |
45 namespace net { | 46 namespace net { |
46 | 47 |
47 namespace { | 48 namespace { |
48 | 49 |
49 // kMultiplier is the multiple of the CHLO message size that a REJ message | 50 // kMultiplier is the multiple of the CHLO message size that a REJ message |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 if (!config.get()) { | 308 if (!config.get()) { |
308 LOG(WARNING) << "Failed to parse server config message"; | 309 LOG(WARNING) << "Failed to parse server config message"; |
309 return nullptr; | 310 return nullptr; |
310 } | 311 } |
311 | 312 |
312 { | 313 { |
313 QuicWriterMutexLock locked(&configs_lock_); | 314 QuicWriterMutexLock locked(&configs_lock_); |
314 if (configs_.find(config->id) != configs_.end()) { | 315 if (configs_.find(config->id) != configs_.end()) { |
315 LOG(WARNING) << "Failed to add config because another with the same " | 316 LOG(WARNING) << "Failed to add config because another with the same " |
316 "server config id already exists: " | 317 "server config id already exists: " |
317 << QuicUtils::HexEncode(config->id); | 318 << QuicTextUtils::HexEncode(config->id); |
318 return nullptr; | 319 return nullptr; |
319 } | 320 } |
320 | 321 |
321 configs_[config->id] = config; | 322 configs_[config->id] = config; |
322 SelectNewPrimaryConfig(now); | 323 SelectNewPrimaryConfig(now); |
323 DCHECK(primary_config_.get()); | 324 DCHECK(primary_config_.get()); |
324 DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), | 325 DCHECK_EQ(configs_.find(primary_config_->id)->second.get(), |
325 primary_config_.get()); | 326 primary_config_.get()); |
326 } | 327 } |
327 | 328 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 QuicWriterMutexLock locked(&configs_lock_); | 365 QuicWriterMutexLock locked(&configs_lock_); |
365 ConfigMap new_configs; | 366 ConfigMap new_configs; |
366 | 367 |
367 for (std::vector<QuicReferenceCountedPointer<Config>>::const_iterator i = | 368 for (std::vector<QuicReferenceCountedPointer<Config>>::const_iterator i = |
368 parsed_configs.begin(); | 369 parsed_configs.begin(); |
369 i != parsed_configs.end(); ++i) { | 370 i != parsed_configs.end(); ++i) { |
370 QuicReferenceCountedPointer<Config> config = *i; | 371 QuicReferenceCountedPointer<Config> config = *i; |
371 | 372 |
372 ConfigMap::iterator it = configs_.find(config->id); | 373 ConfigMap::iterator it = configs_.find(config->id); |
373 if (it != configs_.end()) { | 374 if (it != configs_.end()) { |
374 VLOG(1) << "Keeping scid: " << QuicUtils::HexEncode(config->id) | 375 VLOG(1) << "Keeping scid: " << QuicTextUtils::HexEncode(config->id) |
375 << " orbit: " | 376 << " orbit: " |
376 << QuicUtils::HexEncode( | 377 << QuicTextUtils::HexEncode( |
377 reinterpret_cast<const char*>(config->orbit), kOrbitSize) | 378 reinterpret_cast<const char*>(config->orbit), kOrbitSize) |
378 << " new primary_time " << config->primary_time.ToUNIXSeconds() | 379 << " new primary_time " << config->primary_time.ToUNIXSeconds() |
379 << " old primary_time " | 380 << " old primary_time " |
380 << it->second->primary_time.ToUNIXSeconds() << " new priority " | 381 << it->second->primary_time.ToUNIXSeconds() << " new priority " |
381 << config->priority << " old priority " << it->second->priority; | 382 << config->priority << " old priority " << it->second->priority; |
382 // Update primary_time and priority. | 383 // Update primary_time and priority. |
383 it->second->primary_time = config->primary_time; | 384 it->second->primary_time = config->primary_time; |
384 it->second->priority = config->priority; | 385 it->second->priority = config->priority; |
385 new_configs.insert(*it); | 386 new_configs.insert(*it); |
386 } else { | 387 } else { |
387 VLOG(1) << "Adding scid: " << QuicUtils::HexEncode(config->id) | 388 VLOG(1) << "Adding scid: " << QuicTextUtils::HexEncode(config->id) |
388 << " orbit: " | 389 << " orbit: " |
389 << QuicUtils::HexEncode( | 390 << QuicTextUtils::HexEncode( |
390 reinterpret_cast<const char*>(config->orbit), kOrbitSize) | 391 reinterpret_cast<const char*>(config->orbit), kOrbitSize) |
391 << " primary_time " << config->primary_time.ToUNIXSeconds() | 392 << " primary_time " << config->primary_time.ToUNIXSeconds() |
392 << " priority " << config->priority; | 393 << " priority " << config->priority; |
393 new_configs.insert(std::make_pair(config->id, config)); | 394 new_configs.insert(std::make_pair(config->id, config)); |
394 } | 395 } |
395 } | 396 } |
396 | 397 |
397 configs_.swap(new_configs); | 398 configs_.swap(new_configs); |
398 SelectNewPrimaryConfig(now); | 399 SelectNewPrimaryConfig(now); |
399 DCHECK(primary_config_.get()); | 400 DCHECK(primary_config_.get()); |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 } else { | 1091 } else { |
1091 next_config_promotion_time_ = config->primary_time; | 1092 next_config_promotion_time_ = config->primary_time; |
1092 } | 1093 } |
1093 | 1094 |
1094 if (primary_config_) { | 1095 if (primary_config_) { |
1095 primary_config_->is_primary = false; | 1096 primary_config_->is_primary = false; |
1096 } | 1097 } |
1097 primary_config_ = new_primary; | 1098 primary_config_ = new_primary; |
1098 new_primary->is_primary = true; | 1099 new_primary->is_primary = true; |
1099 DVLOG(1) << "New primary config. orbit: " | 1100 DVLOG(1) << "New primary config. orbit: " |
1100 << QuicUtils::HexEncode( | 1101 << QuicTextUtils::HexEncode( |
1101 reinterpret_cast<const char*>(primary_config_->orbit), | 1102 reinterpret_cast<const char*>(primary_config_->orbit), |
1102 kOrbitSize); | 1103 kOrbitSize); |
1103 if (primary_config_changed_cb_.get() != nullptr) { | 1104 if (primary_config_changed_cb_.get() != nullptr) { |
1104 primary_config_changed_cb_->Run(primary_config_->id); | 1105 primary_config_changed_cb_->Run(primary_config_->id); |
1105 } | 1106 } |
1106 | 1107 |
1107 return; | 1108 return; |
1108 } | 1109 } |
1109 | 1110 |
1110 // All config's primary times are in the past. We should make the most recent | 1111 // All config's primary times are in the past. We should make the most recent |
1111 // and highest priority candidate primary. | 1112 // and highest priority candidate primary. |
1112 QuicReferenceCountedPointer<Config> new_primary = best_candidate; | 1113 QuicReferenceCountedPointer<Config> new_primary = best_candidate; |
1113 if (primary_config_) { | 1114 if (primary_config_) { |
1114 primary_config_->is_primary = false; | 1115 primary_config_->is_primary = false; |
1115 } | 1116 } |
1116 primary_config_ = new_primary; | 1117 primary_config_ = new_primary; |
1117 new_primary->is_primary = true; | 1118 new_primary->is_primary = true; |
1118 DVLOG(1) << "New primary config. orbit: " | 1119 DVLOG(1) << "New primary config. orbit: " |
1119 << QuicUtils::HexEncode( | 1120 << QuicTextUtils::HexEncode( |
1120 reinterpret_cast<const char*>(primary_config_->orbit), | 1121 reinterpret_cast<const char*>(primary_config_->orbit), |
1121 kOrbitSize) | 1122 kOrbitSize) |
1122 << " scid: " << QuicUtils::HexEncode(primary_config_->id); | 1123 << " scid: " << QuicTextUtils::HexEncode(primary_config_->id); |
1123 next_config_promotion_time_ = QuicWallTime::Zero(); | 1124 next_config_promotion_time_ = QuicWallTime::Zero(); |
1124 if (primary_config_changed_cb_.get() != nullptr) { | 1125 if (primary_config_changed_cb_.get() != nullptr) { |
1125 primary_config_changed_cb_->Run(primary_config_->id); | 1126 primary_config_changed_cb_->Run(primary_config_->id); |
1126 } | 1127 } |
1127 } | 1128 } |
1128 | 1129 |
1129 class QuicCryptoServerConfig::EvaluateClientHelloCallback | 1130 class QuicCryptoServerConfig::EvaluateClientHelloCallback |
1130 : public ProofSource::Callback { | 1131 : public ProofSource::Callback { |
1131 public: | 1132 public: |
1132 EvaluateClientHelloCallback( | 1133 EvaluateClientHelloCallback( |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2024 expiry_time(QuicWallTime::Zero()), | 2025 expiry_time(QuicWallTime::Zero()), |
2025 priority(0), | 2026 priority(0), |
2026 source_address_token_boxer(nullptr) {} | 2027 source_address_token_boxer(nullptr) {} |
2027 | 2028 |
2028 QuicCryptoServerConfig::Config::~Config() {} | 2029 QuicCryptoServerConfig::Config::~Config() {} |
2029 | 2030 |
2030 QuicSignedServerConfig::QuicSignedServerConfig() {} | 2031 QuicSignedServerConfig::QuicSignedServerConfig() {} |
2031 QuicSignedServerConfig::~QuicSignedServerConfig() {} | 2032 QuicSignedServerConfig::~QuicSignedServerConfig() {} |
2032 | 2033 |
2033 } // namespace net | 2034 } // namespace net |
OLD | NEW |