Line data Source code
1 : #include "source/common/quic/quic_server_transport_socket_factory.h" 2 : 3 : #include <memory> 4 : 5 : #include "envoy/extensions/transport_sockets/quic/v3/quic_transport.pb.validate.h" 6 : 7 : #include "source/common/runtime/runtime_features.h" 8 : #include "source/extensions/transport_sockets/tls/context_config_impl.h" 9 : 10 : namespace Envoy { 11 : namespace Quic { 12 : 13 : Network::DownstreamTransportSocketFactoryPtr 14 : QuicServerTransportSocketConfigFactory::createTransportSocketFactory( 15 : const Protobuf::Message& config, Server::Configuration::TransportSocketFactoryContext& context, 16 0 : const std::vector<std::string>& /*server_names*/) { 17 0 : auto quic_transport = MessageUtil::downcastAndValidate< 18 0 : const envoy::extensions::transport_sockets::quic::v3::QuicDownstreamTransport&>( 19 0 : config, context.messageValidationVisitor()); 20 0 : auto server_config = std::make_unique<Extensions::TransportSockets::Tls::ServerContextConfigImpl>( 21 0 : quic_transport.downstream_tls_context(), context); 22 : // TODO(RyanTheOptimist): support TLS client authentication. 23 0 : if (server_config->requireClientCertificate()) { 24 0 : throwEnvoyExceptionOrPanic("TLS Client Authentication is not supported over QUIC"); 25 0 : } 26 : 27 0 : auto factory = std::make_unique<QuicServerTransportSocketFactory>( 28 0 : PROTOBUF_GET_WRAPPED_OR_DEFAULT(quic_transport, enable_early_data, true), 29 0 : context.statsScope(), std::move(server_config)); 30 0 : factory->initialize(); 31 0 : return factory; 32 0 : } 33 : 34 12 : ProtobufTypes::MessagePtr QuicServerTransportSocketConfigFactory::createEmptyConfigProto() { 35 12 : return std::make_unique< 36 12 : envoy::extensions::transport_sockets::quic::v3::QuicDownstreamTransport>(); 37 12 : } 38 : 39 0 : void QuicServerTransportSocketFactory::initialize() { 40 0 : config_->setSecretUpdateCallback([this]() { 41 : // The callback also updates config_ with the new secret. 42 0 : onSecretUpdated(); 43 0 : }); 44 0 : if (!config_->alpnProtocols().empty()) { 45 0 : supported_alpns_ = absl::StrSplit(config_->alpnProtocols(), ','); 46 0 : } 47 0 : } 48 : 49 : REGISTER_FACTORY(QuicServerTransportSocketConfigFactory, 50 : Server::Configuration::DownstreamTransportSocketConfigFactory); 51 : 52 : } // namespace Quic 53 : } // namespace Envoy