Add ALPN to QUIC when using TLS
This CL makes our client send ALPN when using QUIC with TLS, makes the server echo the first ALPN value, and allows quic_client to override the ALPN for IETF interop events.
gfe-relnote: protected by disabled flag quic_supports_tls_handshake
PiperOrigin-RevId: 242682444
Change-Id: I7e60fb61c0afe02283e38598de29df9018b71ee8
diff --git a/quic/core/quic_versions.cc b/quic/core/quic_versions.cc
index 62f9ce9..ca6bdae 100644
--- a/quic/core/quic_versions.cc
+++ b/quic/core/quic_versions.cc
@@ -25,9 +25,9 @@
return MakeQuicTag(d, c, b, a);
}
-// Version label for ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_99).
-// Defaults to "T099". Can be overridden for IETF interop events.
-QuicVersionLabel kQuicT099VersionLabel = 0;
+// IETF draft version for ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_99).
+// Overrides the version label and ALPN string for IETF interop events.
+int32_t kQuicT099IetfDraftVersion = 0;
} // namespace
@@ -73,8 +73,8 @@
return MakeVersionLabel(proto, '0', '4', '7');
case QUIC_VERSION_99:
if (parsed_version.handshake_protocol == PROTOCOL_TLS1_3 &&
- kQuicT099VersionLabel != 0) {
- return kQuicT099VersionLabel;
+ kQuicT099IetfDraftVersion != 0) {
+ return 0xff000000 + kQuicT099IetfDraftVersion;
}
return MakeVersionLabel(proto, '0', '9', '9');
default:
@@ -116,7 +116,7 @@
}
ParsedQuicVersion ParseQuicVersionString(std::string version_string) {
- if (version_string.length() == 0) {
+ if (version_string.empty()) {
return UnsupportedQuicVersion();
}
int quic_version_number = 0;
@@ -140,7 +140,7 @@
}
}
}
- // Still recognize T099 even if kQuicT099VersionLabel has been changed.
+ // Still recognize T099 even if kQuicT099IetfDraftVersion has been changed.
if (FLAGS_quic_supports_tls_handshake && version_string == "T099") {
return ParsedQuicVersion(PROTOCOL_TLS1_3, QUIC_VERSION_99);
}
@@ -378,6 +378,15 @@
return ParsedQuicVersion(PROTOCOL_UNSUPPORTED, QUIC_VERSION_UNSUPPORTED);
}
+std::string AlpnForVersion(ParsedQuicVersion parsed_version) {
+ if (parsed_version.handshake_protocol == PROTOCOL_TLS1_3 &&
+ parsed_version.transport_version == QUIC_VERSION_99 &&
+ kQuicT099IetfDraftVersion != 0) {
+ return "h3-" + QuicTextUtils::Uint64ToString(kQuicT099IetfDraftVersion);
+ }
+ return "h3-google-" + ParsedQuicVersionToString(parsed_version);
+}
+
void QuicVersionInitializeSupportForIetfDraft(int32_t draft_version) {
if (draft_version == 0) {
return;
@@ -387,7 +396,7 @@
return;
}
- kQuicT099VersionLabel = 0xff000000 + draft_version;
+ kQuicT099IetfDraftVersion = draft_version;
// Enable necessary flags.
SetQuicFlag(&FLAGS_quic_supports_tls_handshake, true);