| Index: net/tools/quic/quic_client_bin.cc
|
| diff --git a/net/tools/quic/quic_client_bin.cc b/net/tools/quic/quic_client_bin.cc
|
| index b9ea9153a202a81a3b7e546b1f798d061e7a2ba2..e9ce928cbd0b93a633281090fa67d278a35bc17c 100644
|
| --- a/net/tools/quic/quic_client_bin.cc
|
| +++ b/net/tools/quic/quic_client_bin.cc
|
| @@ -2,16 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -// A binary wrapper for QuicClient. Connects to --hostname via --address
|
| -// on --port and requests URLs specified on the command line.
|
| -// Pass --secure to check the certificates using proof verifier.
|
| -// Pass --initial_stream_flow_control_window to specify the size of the initial
|
| -// stream flow control receive window to advertise to server.
|
| -// Pass --initial_session_flow_control_window to specify the size of the initial
|
| -// session flow control receive window to advertise to server.
|
| +// A binary wrapper for QuicClient.
|
| +// Connects to a host using QUIC, and sends requests to the provided URLS.
|
| //
|
| -// For example:
|
| -// quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com
|
| +// Example usage:
|
| +// quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com \
|
| // http://www.google.com/index.html http://www.google.com/favicon.ico
|
|
|
| #include <iostream>
|
| @@ -27,19 +22,16 @@
|
| #include "net/tools/epoll_server/epoll_server.h"
|
| #include "net/tools/quic/quic_client.h"
|
|
|
| -// The port the quic client will connect to.
|
| -int32 FLAGS_port = 6121;
|
| std::string FLAGS_address = "127.0.0.1";
|
| -// The hostname the quic client will connect to.
|
| +// The IP or hostname the quic client will connect to.
|
| std::string FLAGS_hostname = "localhost";
|
| -// Size of the initial stream flow control receive window to advertise to
|
| -// server.
|
| -int32 FLAGS_initial_stream_flow_control_window = 100 * net::kMaxPacketSize;
|
| -// Size of the initial session flow control receive window to advertise to
|
| -// server.
|
| -int32 FLAGS_initial_session_flow_control_window = 200 * net::kMaxPacketSize;
|
| +// The port the quic client will connect to.
|
| +int32 FLAGS_port = 6121;
|
| // Check the certificates using proof verifier.
|
| bool FLAGS_secure = false;
|
| +// QUIC version to speak, e.g. 21. Default value of 0 means 'use the latest
|
| +// version'.
|
| +int32 FLAGS_quic_version = 0;
|
|
|
| int main(int argc, char *argv[]) {
|
| base::CommandLine::Init(argc, argv);
|
| @@ -61,7 +53,8 @@ int main(int argc, char *argv[]) {
|
| "--port=<port> specify the port to connect to\n"
|
| "--address=<address> specify the IP address to connect to\n"
|
| "--host=<host> specify the SNI hostname to use\n"
|
| - "--secure check certificates\n";
|
| + "--secure check certificates\n"
|
| + "--quic-version=<quic version> specify QUIC version to speak\n";
|
| std::cout << help_str;
|
| exit(0);
|
| }
|
| @@ -80,37 +73,56 @@ int main(int argc, char *argv[]) {
|
| if (line->HasSwitch("secure")) {
|
| FLAGS_secure = true;
|
| }
|
| + if (line->HasSwitch("quic-version")) {
|
| + int quic_version;
|
| + if (base::StringToInt(line->GetSwitchValueASCII("quic-version"),
|
| + &quic_version)) {
|
| + FLAGS_quic_version = quic_version;
|
| + }
|
| + }
|
| VLOG(1) << "server port: " << FLAGS_port
|
| << " address: " << FLAGS_address
|
| << " hostname: " << FLAGS_hostname
|
| - << " secure: " << FLAGS_secure;
|
| + << " secure: " << FLAGS_secure
|
| + << " quic-version: " << FLAGS_quic_version;
|
|
|
| base::AtExitManager exit_manager;
|
|
|
| + // Determine IP address to connect to from supplied hostname.
|
| net::IPAddressNumber addr;
|
| CHECK(net::ParseIPLiteralToNumber(FLAGS_address, &addr));
|
|
|
| + // Populate version vector with all versions if none specified.
|
| + net::QuicVersionVector versions;
|
| + if (FLAGS_quic_version == 0) {
|
| + versions = net::QuicSupportedVersions();
|
| + } else {
|
| + versions.push_back(static_cast<net::QuicVersion>(FLAGS_quic_version));
|
| + }
|
| +
|
| + // Build the client, and try to connect.
|
| + VLOG(1) << "Conecting to " << FLAGS_hostname << ":" << FLAGS_port
|
| + << " with supported versions "
|
| + << QuicVersionVectorToString(versions);
|
| + net::EpollServer epoll_server;
|
| net::QuicConfig config;
|
| config.SetDefaults();
|
| - config.SetInitialFlowControlWindowToSend(
|
| - FLAGS_initial_session_flow_control_window);
|
| - config.SetInitialStreamFlowControlWindowToSend(
|
| - FLAGS_initial_stream_flow_control_window);
|
| - config.SetInitialSessionFlowControlWindowToSend(
|
| - FLAGS_initial_session_flow_control_window);
|
|
|
| - // TODO(rjshade): Set version on command line.
|
| - net::EpollServer epoll_server;
|
| net::tools::QuicClient client(
|
| net::IPEndPoint(addr, FLAGS_port),
|
| net::QuicServerId(FLAGS_hostname, FLAGS_port, FLAGS_secure,
|
| net::PRIVACY_MODE_DISABLED),
|
| - net::QuicSupportedVersions(), true, config, &epoll_server);
|
| + versions, true, config, &epoll_server);
|
|
|
| client.Initialize();
|
|
|
| - if (!client.Connect()) return 1;
|
| + if (!client.Connect()) {
|
| + LOG(ERROR) << "Client failed to connect to host: "
|
| + << FLAGS_hostname << ":" << FLAGS_port;
|
| + return 1;
|
| + }
|
|
|
| + // Send a GET request for each supplied url.
|
| client.SendRequestsAndWaitForResponse(urls);
|
| return 0;
|
| }
|
|
|