OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/tools/quic/chlo_extractor.h" | 5 #include "net/tools/quic/chlo_extractor.h" |
6 | 6 |
| 7 #include "base/strings/string_util.h" |
7 #include "net/quic/core/crypto/crypto_framer.h" | 8 #include "net/quic/core/crypto/crypto_framer.h" |
8 #include "net/quic/core/crypto/crypto_handshake_message.h" | 9 #include "net/quic/core/crypto/crypto_handshake_message.h" |
9 #include "net/quic/core/crypto/crypto_protocol.h" | 10 #include "net/quic/core/crypto/crypto_protocol.h" |
10 #include "net/quic/core/crypto/quic_decrypter.h" | 11 #include "net/quic/core/crypto/quic_decrypter.h" |
11 #include "net/quic/core/crypto/quic_encrypter.h" | 12 #include "net/quic/core/crypto/quic_encrypter.h" |
12 #include "net/quic/core/quic_framer.h" | 13 #include "net/quic/core/quic_framer.h" |
13 | 14 |
14 using base::StringPiece; | 15 using base::StringPiece; |
15 | 16 |
16 namespace net { | 17 namespace net { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 bool ChloFramerVisitor::OnUnauthenticatedHeader( | 86 bool ChloFramerVisitor::OnUnauthenticatedHeader( |
86 const QuicPacketHeader& header) { | 87 const QuicPacketHeader& header) { |
87 return true; | 88 return true; |
88 } | 89 } |
89 bool ChloFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) { | 90 bool ChloFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) { |
90 return true; | 91 return true; |
91 } | 92 } |
92 bool ChloFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) { | 93 bool ChloFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) { |
93 StringPiece data(frame.data_buffer, frame.data_length); | 94 StringPiece data(frame.data_buffer, frame.data_length); |
94 if (frame.stream_id == kCryptoStreamId && frame.offset == 0 && | 95 if (frame.stream_id == kCryptoStreamId && frame.offset == 0 && |
95 data.starts_with("CHLO")) { | 96 base::StartsWith(data, "CHLO", base::CompareCase::INSENSITIVE_ASCII)) { |
96 CryptoFramer crypto_framer; | 97 CryptoFramer crypto_framer; |
97 crypto_framer.set_visitor(this); | 98 crypto_framer.set_visitor(this); |
98 if (!crypto_framer.ProcessInput(data)) { | 99 if (!crypto_framer.ProcessInput(data)) { |
99 return false; | 100 return false; |
100 } | 101 } |
101 } | 102 } |
102 return true; | 103 return true; |
103 } | 104 } |
104 | 105 |
105 bool ChloFramerVisitor::OnAckFrame(const QuicAckFrame& frame) { | 106 bool ChloFramerVisitor::OnAckFrame(const QuicAckFrame& frame) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 QuicFramer framer(versions, QuicTime::Zero(), Perspective::IS_SERVER); | 164 QuicFramer framer(versions, QuicTime::Zero(), Perspective::IS_SERVER); |
164 ChloFramerVisitor visitor(&framer, delegate); | 165 ChloFramerVisitor visitor(&framer, delegate); |
165 framer.set_visitor(&visitor); | 166 framer.set_visitor(&visitor); |
166 if (!framer.ProcessPacket(packet)) { | 167 if (!framer.ProcessPacket(packet)) { |
167 return false; | 168 return false; |
168 } | 169 } |
169 return visitor.found_chlo(); | 170 return visitor.found_chlo(); |
170 } | 171 } |
171 | 172 |
172 } // namespace net | 173 } // namespace net |
OLD | NEW |