1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // A binary wrapper for QuicServer. It listens forever on --port
6 // (default 6121) until it's killed or ctrl-cd to death.
7
8 #include <vector>
9
10 #include "net/third_party/quiche/src/quiche/common/platform/api/quiche_command_line_flags.h"
11 #include "net/third_party/quiche/src/quiche/common/platform/api/quiche_system_event_loop.h"
12 #include "net/third_party/quiche/src/quiche/quic/core/quic_versions.h"
13 #include "net/third_party/quiche/src/quiche/quic/platform/api/quic_flags.h"
14 #include "net/third_party/quiche/src/quiche/quic/tools/quic_simple_server_backend.h"
15 #include "net/third_party/quiche/src/quiche/quic/tools/quic_toy_server.h"
16 #include "net/tools/quic/quic_simple_server.h"
17 #include "net/tools/quic/quic_simple_server_backend_factory.h"
18
19 class QuicSimpleServerFactory : public quic::QuicToyServer::ServerFactory {
CreateServer(quic::QuicSimpleServerBackend * backend,std::unique_ptr<quic::ProofSource> proof_source,const quic::ParsedQuicVersionVector & supported_versions)20 std::unique_ptr<quic::QuicSpdyServerBase> CreateServer(
21 quic::QuicSimpleServerBackend* backend,
22 std::unique_ptr<quic::ProofSource> proof_source,
23 const quic::ParsedQuicVersionVector& supported_versions) override {
24 return std::make_unique<net::QuicSimpleServer>(
25 std::move(proof_source), config_,
26 quic::QuicCryptoServerConfig::ConfigOptions(), supported_versions,
27 backend);
28 }
29
30 private:
31 quic::QuicConfig config_;
32 };
33
main(int argc,char * argv[])34 int main(int argc, char* argv[]) {
35 quiche::QuicheSystemEventLoop event_loop("quic_server");
36 const char* usage = "Usage: quic_server [options]";
37 std::vector<std::string> non_option_args =
38 quiche::QuicheParseCommandLineFlags(usage, argc, argv);
39 if (!non_option_args.empty()) {
40 quiche::QuichePrintCommandLineFlagHelp(usage);
41 exit(0);
42 }
43
44 net::QuicSimpleServerBackendFactory backend_factory;
45 QuicSimpleServerFactory server_factory;
46 quic::QuicToyServer server(&backend_factory, &server_factory);
47 return server.Start();
48 }
49