Allow quic_toy_server to only use IETF QUIC

gfe-relnote: n/a, test-only
PiperOrigin-RevId: 268771484
Change-Id: I0546c2758165c4f16e7b2a3cda008e34643fdb04
diff --git a/quic/core/quic_dispatcher.cc b/quic/core/quic_dispatcher.cc
index 6a4ce01..b8e7f0c 100644
--- a/quic/core/quic_dispatcher.cc
+++ b/quic/core/quic_dispatcher.cc
@@ -204,7 +204,10 @@
       allow_short_initial_server_connection_ids_(false),
       expected_server_connection_id_length_(
           expected_server_connection_id_length),
-      should_update_expected_server_connection_id_length_(false) {}
+      should_update_expected_server_connection_id_length_(false) {
+  QUIC_DLOG(INFO) << "Created QuicDispatcher with versions: "
+                  << ParsedQuicVersionVectorToString(GetSupportedVersions());
+}
 
 QuicDispatcher::~QuicDispatcher() {
   session_map_.clear();
diff --git a/quic/tools/quic_epoll_server_factory.cc b/quic/tools/quic_epoll_server_factory.cc
index 9662658..baa1392 100644
--- a/quic/tools/quic_epoll_server_factory.cc
+++ b/quic/tools/quic_epoll_server_factory.cc
@@ -10,8 +10,10 @@
 
 std::unique_ptr<quic::QuicSpdyServerBase> QuicEpollServerFactory::CreateServer(
     quic::QuicSimpleServerBackend* backend,
-    std::unique_ptr<quic::ProofSource> proof_source) {
-  return std::make_unique<quic::QuicServer>(std::move(proof_source), backend);
+    std::unique_ptr<quic::ProofSource> proof_source,
+    const quic::ParsedQuicVersionVector& supported_versions) {
+  return std::make_unique<quic::QuicServer>(std::move(proof_source), backend,
+                                            supported_versions);
 }
 
 }  // namespace quic
diff --git a/quic/tools/quic_epoll_server_factory.h b/quic/tools/quic_epoll_server_factory.h
index 391f3cd..9070291 100644
--- a/quic/tools/quic_epoll_server_factory.h
+++ b/quic/tools/quic_epoll_server_factory.h
@@ -15,7 +15,8 @@
  public:
   std::unique_ptr<QuicSpdyServerBase> CreateServer(
       QuicSimpleServerBackend* backend,
-      std::unique_ptr<ProofSource> proof_source) override;
+      std::unique_ptr<ProofSource> proof_source,
+      const quic::ParsedQuicVersionVector& supported_versions) override;
 
  private:
   QuicEpollServer epoll_server_;
diff --git a/quic/tools/quic_server.cc b/quic/tools/quic_server.cc
index 46b04a5..294dbc5 100644
--- a/quic/tools/quic_server.cc
+++ b/quic/tools/quic_server.cc
@@ -51,9 +51,16 @@
 QuicServer::QuicServer(std::unique_ptr<ProofSource> proof_source,
                        QuicSimpleServerBackend* quic_simple_server_backend)
     : QuicServer(std::move(proof_source),
+                 quic_simple_server_backend,
+                 AllSupportedVersions()) {}
+
+QuicServer::QuicServer(std::unique_ptr<ProofSource> proof_source,
+                       QuicSimpleServerBackend* quic_simple_server_backend,
+                       const ParsedQuicVersionVector& supported_versions)
+    : QuicServer(std::move(proof_source),
                  QuicConfig(),
                  QuicCryptoServerConfig::ConfigOptions(),
-                 AllSupportedVersions(),
+                 supported_versions,
                  quic_simple_server_backend,
                  kQuicDefaultConnectionIdLength) {}
 
diff --git a/quic/tools/quic_server.h b/quic/tools/quic_server.h
index 755e5e3..0b11be3 100644
--- a/quic/tools/quic_server.h
+++ b/quic/tools/quic_server.h
@@ -39,8 +39,11 @@
   QuicServer(std::unique_ptr<ProofSource> proof_source,
              QuicSimpleServerBackend* quic_simple_server_backend);
   QuicServer(std::unique_ptr<ProofSource> proof_source,
+             QuicSimpleServerBackend* quic_simple_server_backend,
+             const ParsedQuicVersionVector& supported_versions);
+  QuicServer(std::unique_ptr<ProofSource> proof_source,
              const QuicConfig& config,
-             const QuicCryptoServerConfig::ConfigOptions& server_config_options,
+             const QuicCryptoServerConfig::ConfigOptions& crypto_config_options,
              const ParsedQuicVersionVector& supported_versions,
              QuicSimpleServerBackend* quic_simple_server_backend,
              uint8_t expected_server_connection_id_length);
diff --git a/quic/tools/quic_toy_server.cc b/quic/tools/quic_toy_server.cc
index 39f206f..c572c7a 100644
--- a/quic/tools/quic_toy_server.cc
+++ b/quic/tools/quic_toy_server.cc
@@ -49,15 +49,19 @@
     : backend_factory_(backend_factory), server_factory_(server_factory) {}
 
 int QuicToyServer::Start() {
+  ParsedQuicVersionVector supported_versions;
   if (GetQuicFlag(FLAGS_quic_ietf_draft)) {
     QuicVersionInitializeSupportForIetfDraft();
-    quic::QuicEnableVersion(
-        quic::ParsedQuicVersion(quic::PROTOCOL_TLS1_3, quic::QUIC_VERSION_99));
+    ParsedQuicVersion version(PROTOCOL_TLS1_3, QUIC_VERSION_99);
+    QuicEnableVersion(version);
+    supported_versions = {version};
+  } else {
+    supported_versions = AllSupportedVersions();
   }
   auto proof_source = quic::CreateDefaultProofSource();
   auto backend = backend_factory_->CreateBackend();
-  auto server =
-      server_factory_->CreateServer(backend.get(), std::move(proof_source));
+  auto server = server_factory_->CreateServer(
+      backend.get(), std::move(proof_source), supported_versions);
 
   if (!server->CreateUDPSocketAndListen(quic::QuicSocketAddress(
           quic::QuicIpAddress::Any6(), GetQuicFlag(FLAGS_port)))) {
diff --git a/quic/tools/quic_toy_server.h b/quic/tools/quic_toy_server.h
index 6c5c486..6168b3f 100644
--- a/quic/tools/quic_toy_server.h
+++ b/quic/tools/quic_toy_server.h
@@ -24,7 +24,8 @@
     // responses, and |proof_source| for certificates.
     virtual std::unique_ptr<QuicSpdyServerBase> CreateServer(
         QuicSimpleServerBackend* backend,
-        std::unique_ptr<ProofSource> proof_source) = 0;
+        std::unique_ptr<ProofSource> proof_source,
+        const ParsedQuicVersionVector& supported_versions) = 0;
   };
 
   // A facotry for creating QuicSimpleServerBackend instances.