// Constructor for outbound connections internal MockConnection(EndPoint?remoteEndPoint, SslClientAuthenticationOptions?sslClientAuthenticationOptions, IPEndPoint?localEndPoint = null, int maxUnidirectionalStreams = 100, int maxBidirectionalStreams = 100) { if (remoteEndPoint is null) { throw new ArgumentNullException(nameof(remoteEndPoint)); } IPEndPoint ipEndPoint = GetIPEndPoint(remoteEndPoint); if (ipEndPoint.Address != IPAddress.Loopback) { throw new ArgumentException("Expected loopback address", nameof(remoteEndPoint)); } _isClient = true; _remoteEndPoint = ipEndPoint; _localEndPoint = new IPEndPoint(IPAddress.Loopback, 0); _sslClientAuthenticationOptions = sslClientAuthenticationOptions; _nextOutboundBidirectionalStream = 0; _nextOutboundUnidirectionalStream = 2; _maxUnidirectionalStreams = maxUnidirectionalStreams; _maxBidirectionalStreams = maxBidirectionalStreams; // _state is not initialized until ConnectAsync }
internal MockConnection(EndPoint?remoteEndPoint, SslClientAuthenticationOptions?sslClientAuthenticationOptions, IPEndPoint?localEndPoint = null) { _remoteEndPoint = remoteEndPoint; _localEndPoint = localEndPoint; _isClient = true; _nextOutboundBidirectionalStream = 0; _nextOutboundUnidirectionalStream = 2; }
internal override Task <HttpConnection> CreateTestClientAsync(ConnectionFactory connectionFactory, EndPoint endPoint) { IConnectionProperties?properties = CreateConnectProperties(); SslClientAuthenticationOptions?sslOptions = null; properties?.TryGetProperty(SslConnectionFactory.SslClientAuthenticationOptionsPropertyKey, out sslOptions); return(Task.FromResult <HttpConnection>(new PooledHttpConnection(connectionFactory, endPoint, sslOptions))); }
public DnsEndPointWithProperties(string host, int port, SslClientAuthenticationOptions?sslOptions) : base(host, port) { SslOptions = sslOptions; }
public static async ValueTask <QuicConnection> ConnectQuicAsync(string host, int port, SslClientAuthenticationOptions?clientAuthenticationOptions, CancellationToken cancellationToken) { IPAddress[] addresses = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false); Exception?lastException = null; foreach (IPAddress address in addresses) { QuicConnection con = new QuicConnection(new IPEndPoint(address, port), clientAuthenticationOptions); try { await con.ConnectAsync(cancellationToken).ConfigureAwait(false); return(con); } // TODO: it would be great to catch a specific exception here... QUIC implementation dependent. catch (Exception ex) when(!(ex is OperationCanceledException)) { con.Dispose(); lastException = ex; } } if (lastException != null) { throw CreateWrappedException(lastException, cancellationToken); } // TODO: find correct exception to throw here. throw new HttpRequestException("No host found."); }
// !!! TEMPORARY: Remove or make internal before shipping public QuicConnection(QuicImplementationProvider implementationProvider, EndPoint remoteEndPoint, SslClientAuthenticationOptions?sslClientAuthenticationOptions, IPEndPoint?localEndPoint = null) : this(implementationProvider, new QuicClientConnectionOptions() { RemoteEndPoint = remoteEndPoint, ClientAuthenticationOptions = sslClientAuthenticationOptions, LocalEndPoint = localEndPoint }) { }
/// <summary> /// Create an outbound QUIC connection. /// </summary> /// <param name="remoteEndPoint">The remote endpoint to connect to.</param> /// <param name="sslClientAuthenticationOptions">TLS options</param> /// <param name="localEndPoint">The local endpoint to connect from.</param> public QuicConnection(EndPoint remoteEndPoint, SslClientAuthenticationOptions?sslClientAuthenticationOptions, IPEndPoint?localEndPoint = null) : this(QuicImplementationProviders.Default, remoteEndPoint, sslClientAuthenticationOptions, localEndPoint) { }