Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: net/tools/quic/quic_simple_client_bin.cc

Issue 1393713003: Remove insecure QUIC support from Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/url_request/url_request_context_builder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 using std::cout; 71 using std::cout;
72 using std::cerr; 72 using std::cerr;
73 using std::map; 73 using std::map;
74 using std::string; 74 using std::string;
75 using std::vector; 75 using std::vector;
76 using std::endl; 76 using std::endl;
77 77
78 // The IP or hostname the quic client will connect to. 78 // The IP or hostname the quic client will connect to.
79 string FLAGS_host = ""; 79 string FLAGS_host = "";
80 // The port to connect to. 80 // The port to connect to.
81 int32 FLAGS_port = 80; 81 int32 FLAGS_port = 0;
82 // If set, send a POST with this body. 82 // If set, send a POST with this body.
83 string FLAGS_body = ""; 83 string FLAGS_body = "";
84 // A semicolon separated list of key:value pairs to add to request headers. 84 // A semicolon separated list of key:value pairs to add to request headers.
85 string FLAGS_headers = ""; 85 string FLAGS_headers = "";
86 // Set to true for a quieter output experience. 86 // Set to true for a quieter output experience.
87 bool FLAGS_quiet = false; 87 bool FLAGS_quiet = false;
88 // QUIC version to speak, e.g. 21. If not set, then all available versions are 88 // QUIC version to speak, e.g. 21. If not set, then all available versions are
89 // offered in the handshake. 89 // offered in the handshake.
90 int32 FLAGS_quic_version = -1; 90 int32 FLAGS_quic_version = -1;
91 // If true, a version mismatch in the handshake is not considered a failure. 91 // If true, a version mismatch in the handshake is not considered a failure.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Determine IP address to connect to from supplied hostname. 183 // Determine IP address to connect to from supplied hostname.
184 net::IPAddressNumber ip_addr; 184 net::IPAddressNumber ip_addr;
185 185
186 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus 186 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus
187 // protocol is required in the URL. 187 // protocol is required in the URL.
188 GURL url(urls[0]); 188 GURL url(urls[0]);
189 string host = FLAGS_host; 189 string host = FLAGS_host;
190 if (host.empty()) { 190 if (host.empty()) {
191 host = url.host(); 191 host = url.host();
192 } 192 }
193 int port = FLAGS_port;
194 if (port == 0) {
195 port = url.EffectiveIntPort();
196 }
193 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) { 197 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
194 net::AddressList addresses; 198 net::AddressList addresses;
195 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses); 199 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses);
196 if (rv != net::OK) { 200 if (rv != net::OK) {
197 LOG(ERROR) << "Unable to resolve '" << host << "' : " 201 LOG(ERROR) << "Unable to resolve '" << host << "' : "
198 << net::ErrorToShortString(rv); 202 << net::ErrorToShortString(rv);
199 return 1; 203 return 1;
200 } 204 }
201 ip_addr = addresses[0].address(); 205 ip_addr = addresses[0].address();
202 } 206 }
203 207
204 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port); 208 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
205 VLOG(1) << "Resolved " << host << " to " << host_port << endl; 209 VLOG(1) << "Resolved " << host << " to " << host_port << endl;
206 210
207 // Build the client, and try to connect. 211 // Build the client, and try to connect.
208 net::QuicServerId server_id(host, FLAGS_port, /*is_https=*/true, 212 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(),
209 net::PRIVACY_MODE_DISABLED); 213 /*is_https=*/true, net::PRIVACY_MODE_DISABLED);
210 net::QuicVersionVector versions = net::QuicSupportedVersions(); 214 net::QuicVersionVector versions = net::QuicSupportedVersions();
211 if (FLAGS_quic_version != -1) { 215 if (FLAGS_quic_version != -1) {
212 versions.clear(); 216 versions.clear();
213 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); 217 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
214 } 218 }
215 net::tools::QuicSimpleClient client(net::IPEndPoint(ip_addr, FLAGS_port), 219 net::tools::QuicSimpleClient client(net::IPEndPoint(ip_addr, port), server_id,
216 server_id, versions); 220 versions);
217 scoped_ptr<CertVerifier> cert_verifier; 221 scoped_ptr<CertVerifier> cert_verifier;
218 scoped_ptr<TransportSecurityState> transport_security_state; 222 scoped_ptr<TransportSecurityState> transport_security_state;
219 client.set_initial_max_packet_length( 223 client.set_initial_max_packet_length(
220 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); 224 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize);
221 // For secure QUIC we need to verify the cert chain. 225 // For secure QUIC we need to verify the cert chain.
222 cert_verifier = CertVerifier::CreateDefault(); 226 cert_verifier = CertVerifier::CreateDefault();
223 transport_security_state.reset(new TransportSecurityState); 227 transport_security_state.reset(new TransportSecurityState);
224 client.SetProofVerifier(new ProofVerifierChromium( 228 client.SetProofVerifier(new ProofVerifierChromium(
225 cert_verifier.get(), nullptr, transport_security_state.get())); 229 cert_verifier.get(), nullptr, transport_security_state.get()));
226 if (!client.Initialize()) { 230 if (!client.Initialize()) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 return 0; 303 return 0;
300 } else { 304 } else {
301 cout << "Request failed (redirect " << response_code << ")." << endl; 305 cout << "Request failed (redirect " << response_code << ")." << endl;
302 return 1; 306 return 1;
303 } 307 }
304 } else { 308 } else {
305 cerr << "Request failed (" << response_code << ")." << endl; 309 cerr << "Request failed (" << response_code << ")." << endl;
306 return 1; 310 return 1;
307 } 311 }
308 } 312 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | net/url_request/url_request_context_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698