-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Implement IConnectionEndPointFeature in Kestrel, HttpSys, and IIS #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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
04cf3eb
Initial plan for issue
Copilot 55b9034
Implement IConnectionEndPointFeature in TransportConnection
Copilot dbd9f49
Add TransportConnection IConnectionEndPointFeature tests
Copilot 6c1244f
Refactor connection endpoint tagging to use shared utility
Copilot 9cfe40b
Update KestrelMetrics.cs
BrennanConroy c4f48b6
Update KestrelMetrics.cs
BrennanConroy 45fbce8
Add IConnectionEndPointFeature support to TransportMultiplexedConnect…
Copilot 630a05c
Add IConnectionEndPointFeature support to HttpConnectionContext and S…
Copilot 6708082
Merge main into copilot/fix-43786 to update PR
Copilot af13f19
Fix code quality issues: refactor ConnectionEndpointTags.cs and fix t…
Copilot dfbd1b6
Undo submodule change; add IConnectionEndPointFeature to HttpSys and IIS
Copilot 93ed79f
Restore googletest submodule to main branch version (d72f9c8a)
Copilot 49c4fd8
Add smoke tests for IConnectionEndPointFeature in HttpSys and IIS
Copilot 5bfaea5
Merge branch 'main' into copilot/fix-43786
BrennanConroy 1358d26
Address code review: namespace, comment, naming, SignalR endpoint fix…
Copilot 4023470
Remove IConnectionEndPointFeature from HttpConnectionContext; dispatc…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Servers/HttpSys/test/FunctionalTests/ConnectionEndPointFeatureTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Net; | ||
| using System.Text; | ||
| using Microsoft.AspNetCore.Connections.Features; | ||
| using Microsoft.AspNetCore.InternalTesting; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.AspNetCore.Server.HttpSys; | ||
|
|
||
| public class ConnectionEndPointFeatureTests : LoggedTest | ||
| { | ||
| [ConditionalFact] | ||
| public async Task Request_ProvidesConnectionEndPointFeature() | ||
| { | ||
| string root; | ||
| EndPoint localEndPoint = null; | ||
| EndPoint remoteEndPoint = null; | ||
| using (Utilities.CreateHttpServerReturnRoot("/", out root, httpContext => | ||
| { | ||
| try | ||
| { | ||
| var endPointFeature = httpContext.Features.Get<IConnectionEndPointFeature>(); | ||
| localEndPoint = endPointFeature.LocalEndPoint; | ||
| remoteEndPoint = endPointFeature.RemoteEndPoint; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| byte[] body = Encoding.ASCII.GetBytes(ex.ToString()); | ||
| httpContext.Response.Body.Write(body, 0, body.Length); | ||
| } | ||
| return Task.FromResult(0); | ||
| }, options => { }, LoggerFactory)) | ||
| { | ||
| string response = await SendRequestAsync(root + "/"); | ||
| Assert.Equal(string.Empty, response); | ||
| } | ||
|
|
||
| Assert.NotNull(localEndPoint); | ||
| Assert.NotNull(remoteEndPoint); | ||
| var localIPEndPoint = Assert.IsType<IPEndPoint>(localEndPoint); | ||
| var remoteIPEndPoint = Assert.IsType<IPEndPoint>(remoteEndPoint); | ||
| Assert.NotEqual(0, localIPEndPoint.Port); | ||
| Assert.NotEqual(0, remoteIPEndPoint.Port); | ||
| } | ||
|
|
||
| private async Task<string> SendRequestAsync(string uri) | ||
| { | ||
| using (var client = new System.Net.Http.HttpClient()) | ||
| { | ||
| return await client.GetStringAsync(uri); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/Servers/IIS/IIS/test/IIS.Tests/ConnectionEndPointFeatureTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Net; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.AspNetCore.Connections.Features; | ||
| using Microsoft.AspNetCore.InternalTesting; | ||
| using Xunit; | ||
|
|
||
| namespace Microsoft.AspNetCore.Server.IIS.FunctionalTests; | ||
|
|
||
| [SkipIfHostableWebCoreNotAvailable] | ||
| [MinimumOSVersion(OperatingSystems.Windows, WindowsVersions.Win8, SkipReason = "https://github.com/aspnet/IISIntegration/issues/866")] | ||
| public class ConnectionEndPointFeatureTests : StrictTestServerTests | ||
| { | ||
| [ConditionalFact] | ||
| public async Task ProvidesLocalAndRemoteEndPoints() | ||
| { | ||
| EndPoint localEndPoint = null; | ||
| EndPoint remoteEndPoint = null; | ||
| using (var testServer = await TestServer.Create(ctx => | ||
| { | ||
| var endPointFeature = ctx.Features.Get<IConnectionEndPointFeature>(); | ||
| localEndPoint = endPointFeature.LocalEndPoint; | ||
| remoteEndPoint = endPointFeature.RemoteEndPoint; | ||
| return Task.CompletedTask; | ||
| }, LoggerFactory)) | ||
| { | ||
| await testServer.HttpClient.GetStringAsync("/"); | ||
| } | ||
|
|
||
| Assert.NotNull(localEndPoint); | ||
| Assert.NotNull(remoteEndPoint); | ||
| var localIPEndPoint = Assert.IsType<IPEndPoint>(localEndPoint); | ||
| var remoteIPEndPoint = Assert.IsType<IPEndPoint>(remoteEndPoint); | ||
| Assert.NotEqual(0, localIPEndPoint.Port); | ||
| Assert.NotEqual(0, remoteIPEndPoint.Port); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.