示例#1
0
        public Http3LoopbackServer(Http3Options options = null)
        {
            options ??= new Http3Options();

            _cert = Configuration.Certificates.GetServerCertificate();

            var listenerOptions = new QuicListenerOptions()
            {
                ListenEndPoint = new IPEndPoint(options.Address, 0),
                ServerAuthenticationOptions = new SslServerAuthenticationOptions
                {
                    EnabledSslProtocols  = options.SslProtocols,
                    ApplicationProtocols = new List <SslApplicationProtocol>
                    {
                        new SslApplicationProtocol(options.Alpn)
                    },
                    ServerCertificate         = _cert,
                    ClientCertificateRequired = false
                },
                MaxUnidirectionalStreams = options.MaxUnidirectionalStreams,
                MaxBidirectionalStreams  = options.MaxBidirectionalStreams,
            };

            ValueTask <QuicListener> valueTask = QuicListener.ListenAsync(listenerOptions);

            Debug.Assert(valueTask.IsCompleted);
            _listener = valueTask.Result;
        }
示例#2
0
        private static Http3Options CreateOptions(GenericLoopbackOptions options)
        {
            Http3Options http3Options = new Http3Options();

            if (options != null)
            {
                http3Options.Address       = options.Address;
                http3Options.UseSsl        = options.UseSsl;
                http3Options.SslProtocols  = options.SslProtocols;
                http3Options.ListenBacklog = options.ListenBacklog;
            }
            return(http3Options);
        }
示例#3
0
        public Http3LoopbackServer(Http3Options options = null)
        {
            options ??= new Http3Options();

            _cert = options.Certificate ?? Configuration.Certificates.GetServerCertificate();

            var listenerOptions = new QuicListenerOptions()
            {
                ListenEndPoint       = new IPEndPoint(options.Address, 0),
                ApplicationProtocols = new List <SslApplicationProtocol>
                {
                    new SslApplicationProtocol(options.Alpn)
                },
                ConnectionOptionsCallback = (_, _, _) =>
                {
                    var serverOptions = new QuicServerConnectionOptions()
                    {
                        DefaultStreamErrorCode          = Http3LoopbackConnection.H3_REQUEST_CANCELLED,
                        DefaultCloseErrorCode           = Http3LoopbackConnection.H3_NO_ERROR,
                        MaxInboundBidirectionalStreams  = options.MaxInboundBidirectionalStreams,
                        MaxInboundUnidirectionalStreams = options.MaxInboundUnidirectionalStreams,
                        ServerAuthenticationOptions     = new SslServerAuthenticationOptions
                        {
                            EnabledSslProtocols  = options.SslProtocols,
                            ApplicationProtocols = new List <SslApplicationProtocol>
                            {
                                new SslApplicationProtocol(options.Alpn)
                            },
                            ServerCertificate         = _cert,
                            ClientCertificateRequired = false
                        }
                    };
                    return(ValueTask.FromResult(serverOptions));
                }
            };

            ValueTask <QuicListener> valueTask = QuicListener.ListenAsync(listenerOptions);

            Debug.Assert(valueTask.IsCompleted);
            _listener = valueTask.Result;
        }
示例#4
0
        public Http3LoopbackServer(QuicImplementationProvider quicImplementationProvider = null, Http3Options options = null)
        {
            options ??= new Http3Options();

            _cert = Configuration.Certificates.GetServerCertificate();

            var listenerOptions = new QuicListenerOptions()
            {
                ListenEndPoint = new IPEndPoint(options.Address, 0),
                ServerAuthenticationOptions = new SslServerAuthenticationOptions
                {
                    EnabledSslProtocols  = options.SslProtocols,
                    ApplicationProtocols = new List <SslApplicationProtocol>
                    {
                        new SslApplicationProtocol(options.Alpn)
                    },
                    ServerCertificate         = _cert,
                    ClientCertificateRequired = false
                },
                MaxUnidirectionalStreams = options.MaxUnidirectionalStreams,
                MaxBidirectionalStreams  = options.MaxBidirectionalStreams,
            };

            _listener = new QuicListener(quicImplementationProvider ?? QuicImplementationProviders.Default, listenerOptions);
        }