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

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: Cleanup 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
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 << " quic-version: " << FLAGS_quic_version 173 << " quic-version: " << FLAGS_quic_version
174 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok 174 << " version_mismatch_ok: " << FLAGS_version_mismatch_ok
175 << " redirect_is_success: " << FLAGS_redirect_is_success 175 << " redirect_is_success: " << FLAGS_redirect_is_success
176 << " initial_mtu: " << FLAGS_initial_mtu; 176 << " initial_mtu: " << FLAGS_initial_mtu;
177 177
178 base::AtExitManager exit_manager; 178 base::AtExitManager exit_manager;
179 179
180 // Determine IP address to connect to from supplied hostname. 180 // Determine IP address to connect to from supplied hostname.
181 net::IPAddressNumber ip_addr; 181 net::IPAddressNumber ip_addr;
182 182
183 // TODO(rtenneti): GURL's doesn't support default_protocol argument, thus
184 // protocol is required in the URL.
185 GURL url(urls[0]); 183 GURL url(urls[0]);
186 string host = FLAGS_host; 184 string host = FLAGS_host;
187 if (host.empty()) { 185 if (host.empty()) {
188 host = url.host(); 186 host = url.host();
189 } 187 }
188 int port = FLAGS_port;
189 if (port == 0) {
190 port = url.EffectiveIntPort();
191 }
190 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) { 192 if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
191 net::AddressList addresses; 193 net::AddressList addresses;
192 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses); 194 int rv = net::tools::SynchronousHostResolver::Resolve(host, &addresses);
193 if (rv != net::OK) { 195 if (rv != net::OK) {
194 LOG(ERROR) << "Unable to resolve '" << host << "' : " 196 LOG(ERROR) << "Unable to resolve '" << host << "' : "
195 << net::ErrorToShortString(rv); 197 << net::ErrorToShortString(rv);
196 return 1; 198 return 1;
197 } 199 }
198 ip_addr = addresses[0].address(); 200 ip_addr = addresses[0].address();
199 } 201 }
200 202
201 string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port); 203 string host_port = net::IPAddressToStringWithPort(ip_addr, port);
202 VLOG(1) << "Resolved " << host << " to " << host_port << endl; 204 VLOG(1) << "Resolved " << host << " to " << host_port << endl;
203 205
204 // Build the client, and try to connect. 206 // Build the client, and try to connect.
205 net::EpollServer epoll_server; 207 net::EpollServer epoll_server;
206 net::QuicServerId server_id(url.host(), FLAGS_port, /*is_https=*/true, 208 net::QuicServerId server_id(url.host(), url.port(), /*is_https=*/true,
207 net::PRIVACY_MODE_DISABLED); 209 net::PRIVACY_MODE_DISABLED);
208 net::QuicVersionVector versions = net::QuicSupportedVersions(); 210 net::QuicVersionVector versions = net::QuicSupportedVersions();
209 if (FLAGS_quic_version != -1) { 211 if (FLAGS_quic_version != -1) {
210 versions.clear(); 212 versions.clear();
211 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version)); 213 versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
212 } 214 }
213 net::tools::QuicClient client(net::IPEndPoint(ip_addr, FLAGS_port), server_id, 215 net::tools::QuicClient client(net::IPEndPoint(ip_addr, port), server_id,
214 versions, &epoll_server); 216 versions, &epoll_server);
215 scoped_ptr<CertVerifier> cert_verifier; 217 scoped_ptr<CertVerifier> cert_verifier;
216 scoped_ptr<TransportSecurityState> transport_security_state; 218 scoped_ptr<TransportSecurityState> transport_security_state;
217 client.set_initial_max_packet_length( 219 client.set_initial_max_packet_length(
218 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize); 220 FLAGS_initial_mtu != 0 ? FLAGS_initial_mtu : net::kDefaultMaxPacketSize);
219 // For secure QUIC we need to verify the cert chain. 221 // For secure QUIC we need to verify the cert chain.
220 cert_verifier = CertVerifier::CreateDefault(); 222 cert_verifier = CertVerifier::CreateDefault();
221 transport_security_state.reset(new TransportSecurityState); 223 transport_security_state.reset(new TransportSecurityState);
222 client.SetProofVerifier(new ProofVerifierChromium( 224 client.SetProofVerifier(new ProofVerifierChromium(
223 cert_verifier.get(), nullptr, transport_security_state.get())); 225 cert_verifier.get(), nullptr, transport_security_state.get()));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 return 0; 298 return 0;
297 } else { 299 } else {
298 cout << "Request failed (redirect " << response_code << ")." << endl; 300 cout << "Request failed (redirect " << response_code << ")." << endl;
299 return 1; 301 return 1;
300 } 302 }
301 } else { 303 } else {
302 cerr << "Request failed (" << response_code << ")." << endl; 304 cerr << "Request failed (" << response_code << ")." << endl;
303 return 1; 305 return 1;
304 } 306 }
305 } 307 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698