| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/quic_crypto_client_stream.h" | 5 #include "net/quic/core/quic_crypto_client_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "net/quic/core/crypto/crypto_protocol.h" | 13 #include "net/quic/core/crypto/crypto_protocol.h" |
| 14 #include "net/quic/core/crypto/crypto_utils.h" | 14 #include "net/quic/core/crypto/crypto_utils.h" |
| 15 #include "net/quic/core/crypto/null_encrypter.h" | 15 #include "net/quic/core/crypto/null_encrypter.h" |
| 16 #include "net/quic/core/quic_flags.h" | 16 #include "net/quic/core/quic_flags.h" |
| 17 #include "net/quic/core/quic_packets.h" | 17 #include "net/quic/core/quic_packets.h" |
| 18 #include "net/quic/core/quic_session.h" | 18 #include "net/quic/core/quic_session.h" |
| 19 #include "net/quic/core/quic_utils.h" | 19 #include "net/quic/core/quic_utils.h" |
| 20 #include "net/quic/platform/api/quic_str_cat.h" |
| 20 | 21 |
| 21 using std::string; | 22 using std::string; |
| 22 | 23 |
| 23 namespace net { | 24 namespace net { |
| 24 | 25 |
| 26 const int QuicCryptoClientStream::kMaxClientHellos; |
| 27 |
| 25 QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) | 28 QuicCryptoClientStreamBase::QuicCryptoClientStreamBase(QuicSession* session) |
| 26 : QuicCryptoStream(session) {} | 29 : QuicCryptoStream(session) {} |
| 27 | 30 |
| 28 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: | 31 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: |
| 29 ChannelIDSourceCallbackImpl(QuicCryptoClientStream* stream) | 32 ChannelIDSourceCallbackImpl(QuicCryptoClientStream* stream) |
| 30 : stream_(stream) {} | 33 : stream_(stream) {} |
| 31 | 34 |
| 32 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: | 35 QuicCryptoClientStream::ChannelIDSourceCallbackImpl:: |
| 33 ~ChannelIDSourceCallbackImpl() {} | 36 ~ChannelIDSourceCallbackImpl() {} |
| 34 | 37 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 273 } |
| 271 return; | 274 return; |
| 272 } | 275 } |
| 273 | 276 |
| 274 // Send the client hello in plaintext. | 277 // Send the client hello in plaintext. |
| 275 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_NONE); | 278 session()->connection()->SetDefaultEncryptionLevel(ENCRYPTION_NONE); |
| 276 encryption_established_ = false; | 279 encryption_established_ = false; |
| 277 if (num_client_hellos_ > kMaxClientHellos) { | 280 if (num_client_hellos_ > kMaxClientHellos) { |
| 278 CloseConnectionWithDetails( | 281 CloseConnectionWithDetails( |
| 279 QUIC_CRYPTO_TOO_MANY_REJECTS, | 282 QUIC_CRYPTO_TOO_MANY_REJECTS, |
| 280 base::StringPrintf("More than %u rejects", kMaxClientHellos).c_str()); | 283 QuicStrCat("More than ", kMaxClientHellos, " rejects")); |
| 281 return; | 284 return; |
| 282 } | 285 } |
| 283 num_client_hellos_++; | 286 num_client_hellos_++; |
| 284 | 287 |
| 285 CryptoHandshakeMessage out; | 288 CryptoHandshakeMessage out; |
| 286 DCHECK(session() != nullptr); | 289 DCHECK(session() != nullptr); |
| 287 DCHECK(session()->config() != nullptr); | 290 DCHECK(session()->config() != nullptr); |
| 288 // Send all the options, regardless of whether we're sending an | 291 // Send all the options, regardless of whether we're sending an |
| 289 // inchoate or subsequent hello. | 292 // inchoate or subsequent hello. |
| 290 session()->config()->ToHandshakeMessage(&out); | 293 session()->config()->ToHandshakeMessage(&out); |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 670 } |
| 668 for (size_t i = 0; i < num_their_proof_demands; i++) { | 671 for (size_t i = 0; i < num_their_proof_demands; i++) { |
| 669 if (their_proof_demands[i] == kCHID) { | 672 if (their_proof_demands[i] == kCHID) { |
| 670 return true; | 673 return true; |
| 671 } | 674 } |
| 672 } | 675 } |
| 673 return false; | 676 return false; |
| 674 } | 677 } |
| 675 | 678 |
| 676 } // namespace net | 679 } // namespace net |
| OLD | NEW |