Skip to content

Implement IConnectionEndPointFeature in Kestrel's TransportConnection #62162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Prev Previous commit
Next Next commit
Implement IConnectionEndPointFeature in TransportConnection
Co-authored-by: BrennanConroy <7574801+BrennanConroy@users.noreply.github.com>
  • Loading branch information
Copilot and BrennanConroy committed May 29, 2025
commit 55b9034369f8d409262ea84b5b9bdad67b319fc3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Buffers;
using System.IO.Pipelines;
using System.Net;
using Microsoft.AspNetCore.Connections.Features;

#nullable enable
Expand Down Expand Up @@ -37,4 +38,16 @@ CancellationToken IConnectionLifetimeFeature.ConnectionClosed
}

void IConnectionLifetimeFeature.Abort() => Abort(new ConnectionAbortedException("The connection was aborted by the application via IConnectionLifetimeFeature.Abort()."));

EndPoint? IConnectionEndPointFeature.LocalEndPoint
{
get => LocalEndPoint;
set => LocalEndPoint = value;
}

EndPoint? IConnectionEndPointFeature.RemoteEndPoint
{
get => RemoteEndPoint;
set => RemoteEndPoint = value;
}
}
25 changes: 24 additions & 1 deletion src/Servers/Kestrel/shared/TransportConnection.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ internal partial class TransportConnection : IFeatureCollection,
IConnectionTransportFeature,
IConnectionItemsFeature,
IMemoryPoolFeature,
IConnectionLifetimeFeature
IConnectionLifetimeFeature,
IConnectionEndPointFeature
{
// Implemented features
internal protected IConnectionIdFeature? _currentIConnectionIdFeature;
internal protected IConnectionTransportFeature? _currentIConnectionTransportFeature;
internal protected IConnectionItemsFeature? _currentIConnectionItemsFeature;
internal protected IMemoryPoolFeature? _currentIMemoryPoolFeature;
internal protected IConnectionLifetimeFeature? _currentIConnectionLifetimeFeature;
internal protected IConnectionEndPointFeature? _currentIConnectionEndPointFeature;

// Other reserved feature slots
internal protected IPersistentStateFeature? _currentIPersistentStateFeature;
Expand All @@ -48,6 +50,7 @@ private void FastReset()
_currentIConnectionItemsFeature = this;
_currentIMemoryPoolFeature = this;
_currentIConnectionLifetimeFeature = this;
_currentIConnectionEndPointFeature = this;

_currentIPersistentStateFeature = null;
_currentIConnectionSocketFeature = null;
Expand Down Expand Up @@ -180,6 +183,10 @@ private void ExtraFeatureSet(Type key, object? value)
{
feature = _currentIConnectionMetricsTagsFeature;
}
else if (key == typeof(IConnectionEndPointFeature))
{
feature = _currentIConnectionEndPointFeature;
}
else if (MaybeExtra != null)
{
feature = ExtraFeatureGet(key);
Expand Down Expand Up @@ -244,6 +251,10 @@ private void ExtraFeatureSet(Type key, object? value)
{
_currentIConnectionMetricsTagsFeature = (IConnectionMetricsTagsFeature?)value;
}
else if (key == typeof(IConnectionEndPointFeature))
{
_currentIConnectionEndPointFeature = (IConnectionEndPointFeature?)value;
}
else
{
ExtraFeatureSet(key, value);
Expand Down Expand Up @@ -310,6 +321,10 @@ private void ExtraFeatureSet(Type key, object? value)
{
feature = Unsafe.As<IConnectionMetricsTagsFeature?, TFeature?>(ref _currentIConnectionMetricsTagsFeature);
}
else if (typeof(TFeature) == typeof(IConnectionEndPointFeature))
{
feature = Unsafe.As<IConnectionEndPointFeature?, TFeature?>(ref _currentIConnectionEndPointFeature);
}
else if (MaybeExtra != null)
{
feature = (TFeature?)(ExtraFeatureGet(typeof(TFeature)));
Expand Down Expand Up @@ -382,6 +397,10 @@ private void ExtraFeatureSet(Type key, object? value)
{
_currentIConnectionMetricsTagsFeature = Unsafe.As<TFeature?, IConnectionMetricsTagsFeature?>(ref feature);
}
else if (typeof(TFeature) == typeof(IConnectionEndPointFeature))
{
_currentIConnectionEndPointFeature = Unsafe.As<TFeature?, IConnectionEndPointFeature?>(ref feature);
}
else
{
ExtraFeatureSet(typeof(TFeature), feature);
Expand Down Expand Up @@ -442,6 +461,10 @@ private IEnumerable<KeyValuePair<Type, object>> FastEnumerable()
{
yield return new KeyValuePair<Type, object>(typeof(IConnectionMetricsTagsFeature), _currentIConnectionMetricsTagsFeature);
}
if (_currentIConnectionEndPointFeature != null)
{
yield return new KeyValuePair<Type, object>(typeof(IConnectionEndPointFeature), _currentIConnectionEndPointFeature);
}

if (MaybeExtra != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static string GenerateFile()
"IStreamIdFeature",
"IStreamAbortFeature",
"IStreamClosedFeature",
"IConnectionMetricsTagsFeature"
"IConnectionMetricsTagsFeature",
"IConnectionEndPointFeature"
};

var implementedFeatures = new[]
Expand All @@ -33,7 +34,8 @@ public static string GenerateFile()
"IConnectionTransportFeature",
"IConnectionItemsFeature",
"IMemoryPoolFeature",
"IConnectionLifetimeFeature"
"IConnectionLifetimeFeature",
"IConnectionEndPointFeature"
};

var usings = $@"
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy