| | 1 | | using System.Net; |
| | 2 | | using System.Security.Cryptography.X509Certificates; |
| | 3 | | using Microsoft.AspNetCore.Server.Kestrel.Core; |
| | 4 | |
|
| | 5 | | namespace Kestrun.Hosting.Options; |
| | 6 | |
|
| | 7 | | /// <summary> |
| | 8 | | /// Configuration for an individual Kestrel listener. |
| | 9 | | /// </summary> |
| | 10 | | public class ListenerOptions |
| | 11 | | { |
| | 12 | | /// <summary>The IP address to bind to.</summary> |
| 42 | 13 | | public IPAddress IPAddress { get; set; } |
| | 14 | |
|
| | 15 | | /// <summary>The port to listen on.</summary> |
| 27 | 16 | | public int Port { get; set; } |
| | 17 | |
|
| | 18 | | /// <summary>Whether HTTPS should be used.</summary> |
| 39 | 19 | | public bool UseHttps { get; set; } |
| | 20 | |
|
| | 21 | | /// <summary>HTTP protocols supported by the listener.</summary> |
| 42 | 22 | | public HttpProtocols Protocols { get; set; } |
| | 23 | |
|
| | 24 | | /// <summary>Enable verbose connection logging.</summary> |
| 39 | 25 | | public bool UseConnectionLogging { get; set; } |
| | 26 | |
|
| | 27 | | /// <summary>Optional TLS certificate.</summary> |
| 16 | 28 | | public X509Certificate2? X509Certificate { get; internal set; } |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// Gets or sets a value that controls whether the "Alt-Svc" header is included with response headers. |
| | 32 | | /// The "Alt-Svc" header is used by clients to upgrade HTTP/1.1 and HTTP/2 connections to HTTP/3. |
| | 33 | | /// <para> |
| | 34 | | /// The "Alt-Svc" header is automatically included with a response if <see cref="Protocols"/> has either |
| | 35 | | /// HTTP/1.1 or HTTP/2 enabled, and HTTP/3 is enabled. If an "Alt-Svc" header value has already been set |
| | 36 | | /// by the app then it isn't changed. |
| | 37 | | /// </para> |
| | 38 | | /// </summary> |
| | 39 | | /// <remarks> |
| | 40 | | /// Defaults to false. |
| | 41 | | /// </remarks> |
| 8 | 42 | | public bool DisableAltSvcHeader { get; set; } |
| | 43 | |
|
| | 44 | | /// <summary> |
| | 45 | | /// Initializes a new instance of the <see cref="ListenerOptions"/> class with default values. |
| | 46 | | /// </summary> |
| 15 | 47 | | public ListenerOptions() |
| | 48 | | { |
| 15 | 49 | | IPAddress = IPAddress.Any; |
| 15 | 50 | | UseHttps = false; |
| 15 | 51 | | Protocols = HttpProtocols.Http1; |
| 15 | 52 | | UseConnectionLogging = false; |
| 15 | 53 | | } |
| | 54 | | } |