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

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

Issue 192583004: QUIC - use QuicSessionKey tuple (host, port, is_https) instead of server_hostname (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use QuicSessionKey as arg and delete server_hostname as arg Created 6 years, 9 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 | Annotate | Revision Log
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. Connects to --hostname via --address 5 // A binary wrapper for QuicClient. Connects to --hostname via --address
6 // on --port and requests URLs specified on the command line. 6 // on --port and requests URLs specified on the command line.
7 // --secure to check the certificates using proof verifier .
7 // 8 //
8 // For example: 9 // For example:
9 // quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com 10 // quic_client --address=127.0.0.1 --port=6122 --hostname=www.google.com
10 // http://www.google.com/index.html http://www.google.com/favicon.ico 11 // http://www.google.com/index.html http://www.google.com/favicon.ico
11 12
12 #include <iostream> 13 #include <iostream>
13 14
14 #include "base/at_exit.h" 15 #include "base/at_exit.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
18 #include "net/base/ip_endpoint.h" 19 #include "net/base/ip_endpoint.h"
19 #include "net/quic/quic_protocol.h" 20 #include "net/quic/quic_protocol.h"
20 #include "net/tools/quic/quic_client.h" 21 #include "net/tools/quic/quic_client.h"
21 22
22 int32 FLAGS_port = 6121; 23 int32 FLAGS_port = 6121;
23 std::string FLAGS_address = "127.0.0.1"; 24 std::string FLAGS_address = "127.0.0.1";
24 std::string FLAGS_hostname = "localhost"; 25 std::string FLAGS_hostname = "localhost";
26 bool FLAGS_secure = false;
25 27
26 int main(int argc, char *argv[]) { 28 int main(int argc, char *argv[]) {
27 CommandLine::Init(argc, argv); 29 CommandLine::Init(argc, argv);
28 CommandLine* line = CommandLine::ForCurrentProcess(); 30 CommandLine* line = CommandLine::ForCurrentProcess();
29 31
30 logging::LoggingSettings settings; 32 logging::LoggingSettings settings;
31 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 33 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
32 CHECK(logging::InitLogging(settings)); 34 CHECK(logging::InitLogging(settings));
33 35
34 if (line->HasSwitch("h") || line->HasSwitch("help")) { 36 if (line->HasSwitch("h") || line->HasSwitch("help")) {
35 const char* help_str = 37 const char* help_str =
36 "Usage: quic_client [options]\n" 38 "Usage: quic_client [options]\n"
37 "\n" 39 "\n"
38 "Options:\n" 40 "Options:\n"
39 "-h, --help show this help message and exit\n" 41 "-h, --help show this help message and exit\n"
40 "--port=<port> specify the port to connect to\n" 42 "--port=<port> specify the port to connect to\n"
41 "--address=<address> specify the IP address to connect to\n" 43 "--address=<address> specify the IP address to connect to\n"
42 "--host=<host> specify the SNI hostname to use\n"; 44 "--host=<host> specify the SNI hostname to use\n"
45 "--secure check certificates\n";
ramant (doing other things) 2014/03/13 20:34:19 not sure if this is right name/description. Wanted
Ryan Hamilton 2014/03/13 22:14:39 SGTM.
43 std::cout << help_str; 46 std::cout << help_str;
44 exit(0); 47 exit(0);
45 } 48 }
46 if (line->HasSwitch("port")) { 49 if (line->HasSwitch("port")) {
47 int port; 50 int port;
48 if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) { 51 if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
49 FLAGS_port = port; 52 FLAGS_port = port;
50 } 53 }
51 } 54 }
52 if (line->HasSwitch("address")) { 55 if (line->HasSwitch("address")) {
53 FLAGS_address = line->GetSwitchValueASCII("address"); 56 FLAGS_address = line->GetSwitchValueASCII("address");
54 } 57 }
55 if (line->HasSwitch("hostname")) { 58 if (line->HasSwitch("hostname")) {
56 FLAGS_hostname = line->GetSwitchValueASCII("hostname"); 59 FLAGS_hostname = line->GetSwitchValueASCII("hostname");
57 } 60 }
61 if (line->HasSwitch("secure")) {
62 FLAGS_secure = true;
63 }
58 VLOG(1) << "server port: " << FLAGS_port 64 VLOG(1) << "server port: " << FLAGS_port
59 << " address: " << FLAGS_address 65 << " address: " << FLAGS_address
60 << " hostname: " << FLAGS_hostname; 66 << " hostname: " << FLAGS_hostname
67 << " secure: " << FLAGS_secure;
61 68
62 base::AtExitManager exit_manager; 69 base::AtExitManager exit_manager;
63 70
64 net::IPAddressNumber addr; 71 net::IPAddressNumber addr;
65 CHECK(net::ParseIPLiteralToNumber(FLAGS_address, &addr)); 72 CHECK(net::ParseIPLiteralToNumber(FLAGS_address, &addr));
66 // TODO(rjshade): Set version on command line. 73 // TODO(rjshade): Set version on command line.
67 net::tools::QuicClient client( 74 net::tools::QuicClient client(
68 net::IPEndPoint(addr, FLAGS_port), FLAGS_hostname, 75 net::IPEndPoint(addr, FLAGS_port),
76 net::QuicSessionKey(FLAGS_hostname, FLAGS_port, FLAGS_secure),
69 net::QuicSupportedVersions(), true); 77 net::QuicSupportedVersions(), true);
70 78
71 client.Initialize(); 79 client.Initialize();
72 80
73 if (!client.Connect()) return 1; 81 if (!client.Connect()) return 1;
74 82
75 client.SendRequestsAndWaitForResponse(line->GetArgs()); 83 client.SendRequestsAndWaitForResponse(line->GetArgs());
76 return 0; 84 return 0;
77 } 85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698