| OLD | NEW |
| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 std::cout << help_str; | 41 std::cout << help_str; |
| 42 exit(0); | 42 exit(0); |
| 43 } | 43 } |
| 44 | 44 |
| 45 if (line->HasSwitch("quic_in_memory_cache_dir")) { | 45 if (line->HasSwitch("quic_in_memory_cache_dir")) { |
| 46 net::g_quic_in_memory_cache_dir = | 46 net::g_quic_in_memory_cache_dir = |
| 47 line->GetSwitchValueNative("quic_in_memory_cache_dir"); | 47 line->GetSwitchValueNative("quic_in_memory_cache_dir"); |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (line->HasSwitch("port")) { | 50 if (line->HasSwitch("port")) { |
| 51 int port; | 51 if (!base::StringToInt(line->GetSwitchValueASCII("port"), &FLAGS_port)) { |
| 52 if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) { | |
| 53 FLAGS_port = port; | |
| 54 } else { | |
| 55 LOG(ERROR) << "--port must be an integer\n"; | 52 LOG(ERROR) << "--port must be an integer\n"; |
| 56 return 1; | 53 return 1; |
| 57 } | 54 } |
| 58 } | 55 } |
| 59 | 56 |
| 60 base::AtExitManager exit_manager; | 57 base::AtExitManager exit_manager; |
| 61 base::MessageLoopForIO message_loop; | 58 base::MessageLoopForIO message_loop; |
| 62 | 59 |
| 63 net::IPAddressNumber ip; | 60 net::IPAddressNumber ip; |
| 64 CHECK(net::ParseIPLiteralToNumber("::", &ip)); | 61 CHECK(net::ParseIPLiteralToNumber("::", &ip)); |
| 65 | 62 |
| 66 net::QuicConfig config; | 63 net::QuicConfig config; |
| 67 net::QuicServer server(config, net::QuicSupportedVersions()); | 64 net::QuicServer server(config, net::QuicSupportedVersions()); |
| 68 | 65 |
| 69 int rc = server.Listen(net::IPEndPoint(ip, FLAGS_port)); | 66 int rc = server.Listen(net::IPEndPoint(ip, FLAGS_port)); |
| 70 if (rc < 0) { | 67 if (rc < 0) { |
| 71 return 1; | 68 return 1; |
| 72 } | 69 } |
| 73 | 70 |
| 74 base::RunLoop().Run(); | 71 base::RunLoop().Run(); |
| 75 | 72 |
| 76 return 0; | 73 return 0; |
| 77 } | 74 } |
| OLD | NEW |