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

Side by Side Diff: net/tools/quic/quic_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/quic/quic_stream_factory_test.cc ('k') | net/tools/quic/quic_simple_client_bin.cc » ('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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 using net::TransportSecurityState; 70 using net::TransportSecurityState;
71 using std::cout; 71 using std::cout;
72 using std::cerr; 72 using std::cerr;
73 using std::string; 73 using std::string;
74 using std::vector; 74 using std::vector;
75 using std::endl; 75 using std::endl;
76 76
77 // The IP or hostname the quic client will connect to. 77 // The IP or hostname the quic client will connect to.
78 string FLAGS_host = ""; 78 string FLAGS_host = "";
79 // The port to connect to. 79 // The port to connect to.
80 int32 FLAGS_port = 80; 80 int32 FLAGS_port = 0;
81 // If set, send a POST with this body. 81 // If set, send a POST with this body.
82 string FLAGS_body = ""; 82 string FLAGS_body = "";
83 // A semicolon separated list of key:value pairs to add to request headers. 83 // A semicolon separated list of key:value pairs to add to request headers.
84 string FLAGS_headers = ""; 84 string FLAGS_headers = "";
85 // Set to true for a quieter output experience. 85 // Set to true for a quieter output experience.
86 bool FLAGS_quiet = false; 86 bool FLAGS_quiet = false;
87 // QUIC version to speak, e.g. 21. If not set, then all available versions are 87 // QUIC version to speak, e.g. 21. If not set, then all available versions are
88 // offered in the handshake. 88 // offered in the handshake.
89 int32 FLAGS_quic_version = -1; 89 int32 FLAGS_quic_version = -1;
90 // If true, a version mismatch in the handshake is not considered a failure. 90 // If true, a version mismatch in the handshake is not considered a failure.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok 175 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok
176 << " redirect_is_success: " << FLAGS_redirect_is_success 176 << " redirect_is_success: " << FLAGS_redirect_is_success
177 << " initial_mtu: " << FLAGS_initial_mtu; 177 << " initial_mtu: " << FLAGS_initial_mtu;
178 178
179 base::AtExitManager exit_manager; 179 base::AtExitManager exit_manager;
180 base::MessageLoopForIO message_loop; 180 base::MessageLoopForIO message_loop;
181 181
182 // Determine IP address to connect to from supplied hostname. 182 // Determine IP address to connect to from supplied hostname.
183 net::IPAddressNumber ip_addr; 183 net::IPAddressNumber ip_addr;
184 184
185 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus
186 // protocol is required in the URL.
187 GURL url(urls[0]); 185 GURL url(urls[0]);
188 string host = FLAGS_host; 186 string host = FLAGS_host;
189 if (host.empty()) { 187 if (host.empty()) {
190 host = url.host(); 188 host = url.host();
191 } 189 }
190 int port = FLAGS_port;
191 if (port == 0) {
192 port = url.EffectiveIntPort();
193 }
192 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) { 194 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
193 net::AddressList addresses; 195 net::AddressList addresses;
194 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses); 196 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses);
195 if (rv != net::OK) { 197 if (rv != net::OK) {
196 LOG(ERROR) << "Unable to resolve '" << host << "' : " 198 LOG(ERROR) << "Unable to resolve '" << host << "' : "
197 << net::ErrorToShortString(rv); 199 << net::ErrorToShortString(rv);
198 return 1; 200 return 1;
199 } 201 }
200 ip_addr = addresses[0].address(); 202 ip_addr = addresses[0].address();
201 } 203 }
202 204
203 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port); 205 string host_port = net::IPAddressToStringWithPort(ip_addr, port);
204 VLOG(1) << "Resolved " << host << " to " << host_port << endl; 206 VLOG(1) << "Resolved " << host << " to " << host_port << endl;
205 207
206 // Build the client, and try to connect. 208 // Build the client, and try to connect.
207 net::EpollServer epoll_server; 209 net::EpollServer epoll_server;
208 net::QuicServerId server_id(url.host(), FLAGS_port, /*is_https=*/true, 210 net::QuicServerId server_id(url.host(), url.EffectiveIntPort(),
209 net::PRIVACY_MODE_DISABLED); 211 /*is_https=*/true, net::PRIVACY_MODE_DISABLED);
210 net::QuicVersionVector versions = net::QuicSupportedVersions(); 212 net::QuicVersionVector versions = net::QuicSupportedVersions();
211 if (FLAGS_quic_version != -1) { 213 if (FLAGS_quic_version != -1) {
212 versions.clear(); 214 versions.clear();
213 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); 215 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
214 } 216 }
215 net::tools::QuicClient client(net::IPEndPoint(ip_addr, FLAGS_port), server_id, 217 net::tools::QuicClient client(net::IPEndPoint(ip_addr, port), server_id,
216 versions, &epoll_server); 218 versions, &epoll_server);
217 scoped_ptr<CertVerifier> cert_verifier; 219 scoped_ptr<CertVerifier> cert_verifier;
218 scoped_ptr<TransportSecurityState> transport_security_state; 220 scoped_ptr<TransportSecurityState> transport_security_state;
219 client.set_initial_max_packet_length( 221 client.set_initial_max_packet_length(
220 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); 222 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize);
221 // For secure QUIC we need to verify the cert chain. 223 // For secure QUIC we need to verify the cert chain.
222 cert_verifier = CertVerifier::CreateDefault(); 224 cert_verifier = CertVerifier::CreateDefault();
223 transport_security_state.reset(new TransportSecurityState); 225 transport_security_state.reset(new TransportSecurityState);
224 client.SetProofVerifier(new ProofVerifierChromium( 226 client.SetProofVerifier(new ProofVerifierChromium(
225 cert_verifier.get(), nullptr, transport_security_state.get())); 227 cert_verifier.get(), nullptr, transport_security_state.get()));
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 return 0; 299 return 0;
298 } else { 300 } else {
299 cout << "Request failed (redirect " << response_code << ")." << endl; 301 cout << "Request failed (redirect " << response_code << ")." << endl;
300 return 1; 302 return 1;
301 } 303 }
302 } else { 304 } else {
303 cerr << "Request failed (" << response_code << ")." << endl; 305 cerr << "Request failed (" << response_code << ")." << endl;
304 return 1; 306 return 1;
305 } 307 }
306 } 308 }
OLDNEW
« no previous file with comments | « net/quic/quic_stream_factory_test.cc ('k') | net/tools/quic/quic_simple_client_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698