| 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 // A binary wrapper for QuicClient. | 5 // A binary wrapper for QuicClient. |
| 6 // Connects to a host using QUIC, sends a request to the provided URL, and | 6 // Connects to a host using QUIC, sends a request to the provided URL, and |
| 7 // displays the response. | 7 // displays the response. |
| 8 // | 8 // |
| 9 // Some usage examples: | 9 // Some usage examples: |
| 10 // | 10 // |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "base/command_line.h" | 44 #include "base/command_line.h" |
| 45 #include "base/logging.h" | 45 #include "base/logging.h" |
| 46 #include "base/message_loop/message_loop.h" | 46 #include "base/message_loop/message_loop.h" |
| 47 #include "base/strings/string_number_conversions.h" | 47 #include "base/strings/string_number_conversions.h" |
| 48 #include "base/strings/string_split.h" | 48 #include "base/strings/string_split.h" |
| 49 #include "base/strings/string_util.h" | 49 #include "base/strings/string_util.h" |
| 50 #include "net/base/ip_endpoint.h" | 50 #include "net/base/ip_endpoint.h" |
| 51 #include "net/base/net_errors.h" | 51 #include "net/base/net_errors.h" |
| 52 #include "net/base/privacy_mode.h" | 52 #include "net/base/privacy_mode.h" |
| 53 #include "net/cert/cert_verifier.h" | 53 #include "net/cert/cert_verifier.h" |
| 54 #include "net/cert/multi_log_ct_verifier.h" |
| 54 #include "net/http/transport_security_state.h" | 55 #include "net/http/transport_security_state.h" |
| 55 #include "net/log/net_log.h" | 56 #include "net/log/net_log.h" |
| 56 #include "net/quic/crypto/proof_verifier_chromium.h" | 57 #include "net/quic/crypto/proof_verifier_chromium.h" |
| 57 #include "net/quic/quic_protocol.h" | 58 #include "net/quic/quic_protocol.h" |
| 58 #include "net/quic/quic_server_id.h" | 59 #include "net/quic/quic_server_id.h" |
| 59 #include "net/quic/quic_utils.h" | 60 #include "net/quic/quic_utils.h" |
| 60 #include "net/spdy/spdy_header_block.h" | 61 #include "net/spdy/spdy_header_block.h" |
| 61 #include "net/tools/epoll_server/epoll_server.h" | 62 #include "net/tools/epoll_server/epoll_server.h" |
| 62 #include "net/tools/quic/quic_client.h" | 63 #include "net/tools/quic/quic_client.h" |
| 63 #include "net/tools/quic/spdy_balsa_utils.h" | 64 #include "net/tools/quic/spdy_balsa_utils.h" |
| 64 #include "net/tools/quic/synchronous_host_resolver.h" | 65 #include "net/tools/quic/synchronous_host_resolver.h" |
| 65 #include "url/gurl.h" | 66 #include "url/gurl.h" |
| 66 | 67 |
| 67 using base::StringPiece; | 68 using base::StringPiece; |
| 68 using net::CertVerifier; | 69 using net::CertVerifier; |
| 70 using net::CTVerifier; |
| 71 using net::MultiLogCTVerifier; |
| 69 using net::ProofVerifierChromium; | 72 using net::ProofVerifierChromium; |
| 70 using net::TransportSecurityState; | 73 using net::TransportSecurityState; |
| 71 using std::cout; | 74 using std::cout; |
| 72 using std::cerr; | 75 using std::cerr; |
| 73 using std::string; | 76 using std::string; |
| 74 using std::vector; | 77 using std::vector; |
| 75 using std::endl; | 78 using std::endl; |
| 76 | 79 |
| 77 // The IP or hostname the quic client will connect to. | 80 // The IP or hostname the quic client will connect to. |
| 78 string FLAGS_host = ""; | 81 string FLAGS_host = ""; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); | 237 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); |
| 235 } | 238 } |
| 236 // For secure QUIC we need to verify the cert chain. | 239 // For secure QUIC we need to verify the cert chain. |
| 237 scoped_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); | 240 scoped_ptr<CertVerifier> cert_verifier(CertVerifier::CreateDefault()); |
| 238 if (line->HasSwitch("disable-certificate-verification")) { | 241 if (line->HasSwitch("disable-certificate-verification")) { |
| 239 cert_verifier.reset(new FakeCertVerifier()); | 242 cert_verifier.reset(new FakeCertVerifier()); |
| 240 } | 243 } |
| 241 scoped_ptr<TransportSecurityState> transport_security_state( | 244 scoped_ptr<TransportSecurityState> transport_security_state( |
| 242 new TransportSecurityState); | 245 new TransportSecurityState); |
| 243 transport_security_state.reset(new TransportSecurityState); | 246 transport_security_state.reset(new TransportSecurityState); |
| 247 scoped_ptr<CTVerifier> ct_verifier(new MultiLogCTVerifier()); |
| 244 ProofVerifierChromium* proof_verifier = new ProofVerifierChromium( | 248 ProofVerifierChromium* proof_verifier = new ProofVerifierChromium( |
| 245 cert_verifier.get(), nullptr, transport_security_state.get()); | 249 cert_verifier.get(), nullptr, transport_security_state.get(), |
| 250 ct_verifier.get()); |
| 246 net::tools::QuicClient client(net::IPEndPoint(ip_addr, FLAGS_port), server_id, | 251 net::tools::QuicClient client(net::IPEndPoint(ip_addr, FLAGS_port), server_id, |
| 247 versions, &epoll_server, proof_verifier); | 252 versions, &epoll_server, proof_verifier); |
| 248 client.set_initial_max_packet_length( | 253 client.set_initial_max_packet_length( |
| 249 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); | 254 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); |
| 250 if (!client.Initialize()) { | 255 if (!client.Initialize()) { |
| 251 cerr << "Failed to initialize client." << endl; | 256 cerr << "Failed to initialize client." << endl; |
| 252 return 1; | 257 return 1; |
| 253 } | 258 } |
| 254 if (!client.Connect()) { | 259 if (!client.Connect()) { |
| 255 net::QuicErrorCode error = client.session()->error(); | 260 net::QuicErrorCode error = client.session()->error(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return 0; | 326 return 0; |
| 322 } else { | 327 } else { |
| 323 cout << "Request failed (redirect " << response_code << ")." << endl; | 328 cout << "Request failed (redirect " << response_code << ")." << endl; |
| 324 return 1; | 329 return 1; |
| 325 } | 330 } |
| 326 } else { | 331 } else { |
| 327 cerr << "Request failed (" << response_code << ")." << endl; | 332 cerr << "Request failed (" << response_code << ")." << endl; |
| 328 return 1; | 333 return 1; |
| 329 } | 334 } |
| 330 } | 335 } |
| OLD | NEW |