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

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

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage Created 4 years 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_server.cc ('k') | net/tools/quic/quic_server_test.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 QuicServer. It listens forever on --port 5 // A binary wrapper for QuicServer. It listens forever on --port
6 // (default 6121) until it's killed or ctrl-cd to death. 6 // (default 6121) until it's killed or ctrl-cd to death.
7 7
8 #include <iostream> 8 #include <iostream>
9 9
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "net/quic/chromium/crypto/proof_source_chromium.h" 15 #include "net/quic/chromium/crypto/proof_source_chromium.h"
16 #include "net/quic/core/quic_protocol.h" 16 #include "net/quic/core/quic_packets.h"
17 #include "net/quic/platform/api/quic_socket_address.h" 17 #include "net/quic/platform/api/quic_socket_address.h"
18 #include "net/tools/quic/quic_in_memory_cache.h" 18 #include "net/tools/quic/quic_http_response_cache.h"
19 #include "net/tools/quic/quic_server.h" 19 #include "net/tools/quic/quic_server.h"
20 20
21 // The port the quic server will listen on. 21 // The port the quic server will listen on.
22 int32_t FLAGS_port = 6121; 22 int32_t FLAGS_port = 6121;
23 23
24 std::unique_ptr<net::ProofSource> CreateProofSource( 24 std::unique_ptr<net::ProofSource> CreateProofSource(
25 const base::FilePath& cert_path, 25 const base::FilePath& cert_path,
26 const base::FilePath& key_path) { 26 const base::FilePath& key_path) {
27 std::unique_ptr<net::ProofSourceChromium> proof_source( 27 std::unique_ptr<net::ProofSourceChromium> proof_source(
28 new net::ProofSourceChromium()); 28 new net::ProofSourceChromium());
(...skipping 12 matching lines...) Expand all
41 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; 41 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
42 CHECK(logging::InitLogging(settings)); 42 CHECK(logging::InitLogging(settings));
43 43
44 if (line->HasSwitch("h") || line->HasSwitch("help")) { 44 if (line->HasSwitch("h") || line->HasSwitch("help")) {
45 const char* help_str = 45 const char* help_str =
46 "Usage: quic_server [options]\n" 46 "Usage: quic_server [options]\n"
47 "\n" 47 "\n"
48 "Options:\n" 48 "Options:\n"
49 "-h, --help show this help message and exit\n" 49 "-h, --help show this help message and exit\n"
50 "--port=<port> specify the port to listen on\n" 50 "--port=<port> specify the port to listen on\n"
51 "--quic_in_memory_cache_dir directory containing response data\n" 51 "--quic_response_cache_dir directory containing response data\n"
52 " to load\n" 52 " to load\n"
53 "--certificate_file=<file> path to the certificate chain\n" 53 "--certificate_file=<file> path to the certificate chain\n"
54 "--key_file=<file> path to the pkcs8 private key\n"; 54 "--key_file=<file> path to the pkcs8 private key\n";
55 std::cout << help_str; 55 std::cout << help_str;
56 exit(0); 56 exit(0);
57 } 57 }
58 58
59 net::QuicInMemoryCache in_memory_cache; 59 net::QuicHttpResponseCache response_cache;
60 if (line->HasSwitch("quic_in_memory_cache_dir")) { 60 if (line->HasSwitch("quic_response_cache_dir")) {
61 in_memory_cache.InitializeFromDirectory( 61 response_cache.InitializeFromDirectory(
62 line->GetSwitchValueASCII("quic_in_memory_cache_dir")); 62 line->GetSwitchValueASCII("quic_response_cache_dir"));
63 } 63 }
64 64
65 if (line->HasSwitch("port")) { 65 if (line->HasSwitch("port")) {
66 if (!base::StringToInt(line->GetSwitchValueASCII("port"), &FLAGS_port)) { 66 if (!base::StringToInt(line->GetSwitchValueASCII("port"), &FLAGS_port)) {
67 LOG(ERROR) << "--port must be an integer\n"; 67 LOG(ERROR) << "--port must be an integer\n";
68 return 1; 68 return 1;
69 } 69 }
70 } 70 }
71 71
72 if (!line->HasSwitch("certificate_file")) { 72 if (!line->HasSwitch("certificate_file")) {
73 LOG(ERROR) << "missing --certificate_file"; 73 LOG(ERROR) << "missing --certificate_file";
74 return 1; 74 return 1;
75 } 75 }
76 76
77 if (!line->HasSwitch("key_file")) { 77 if (!line->HasSwitch("key_file")) {
78 LOG(ERROR) << "missing --key_file"; 78 LOG(ERROR) << "missing --key_file";
79 return 1; 79 return 1;
80 } 80 }
81 81
82 net::QuicConfig config; 82 net::QuicConfig config;
83 net::QuicServer server( 83 net::QuicServer server(
84 CreateProofSource(line->GetSwitchValuePath("certificate_file"), 84 CreateProofSource(line->GetSwitchValuePath("certificate_file"),
85 line->GetSwitchValuePath("key_file")), 85 line->GetSwitchValuePath("key_file")),
86 config, net::QuicCryptoServerConfig::ConfigOptions(), 86 config, net::QuicCryptoServerConfig::ConfigOptions(),
87 net::AllSupportedVersions(), &in_memory_cache); 87 net::AllSupportedVersions(), &response_cache);
88 88
89 int rc = server.CreateUDPSocketAndListen( 89 int rc = server.CreateUDPSocketAndListen(
90 net::QuicSocketAddress(net::QuicIpAddress::Any6(), FLAGS_port)); 90 net::QuicSocketAddress(net::QuicIpAddress::Any6(), FLAGS_port));
91 if (rc < 0) { 91 if (rc < 0) {
92 return 1; 92 return 1;
93 } 93 }
94 94
95 while (1) { 95 while (1) {
96 server.WaitForEvents(); 96 server.WaitForEvents();
97 } 97 }
98 } 98 }
OLDNEW
« no previous file with comments | « net/tools/quic/quic_server.cc ('k') | net/tools/quic/quic_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698