-
Notifications
You must be signed in to change notification settings - Fork 707
Add non-localhost URLs #10232
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
Add non-localhost URLs #10232
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,8 +212,21 @@ private async Task ProcessResourceUrlCallbacks(IResource resource, CancellationT | |
| Debug.Assert(endpoint.AllocatedEndpoint is not null, "Endpoint should be allocated at this point as we're calling this from ResourceEndpointsAllocatedEvent handler."); | ||
| if (endpoint.AllocatedEndpoint is { } allocatedEndpoint) | ||
| { | ||
| var url = new ResourceUrlAnnotation { Url = allocatedEndpoint.UriString, Endpoint = new EndpointReference(resourceWithEndpoints, endpoint) }; | ||
| var endpointReference = new EndpointReference(resourceWithEndpoints, endpoint); | ||
| var url = new ResourceUrlAnnotation { Url = allocatedEndpoint.UriString, Endpoint = endpointReference }; | ||
| urls.Add(url); | ||
| if (allocatedEndpoint.BindingMode != EndpointBindingMode.SingleAddress && (endpoint.TargetHost is not "localhost" or "127.0.0.1")) | ||
|
||
| { | ||
| // Endpoint is listening on multiple addresses so add more URLs using | ||
DamianEdwards marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var address = endpoint.TargetHost == "0.0.0.0" ? Environment.MachineName : endpoint.TargetHost; | ||
DamianEdwards marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| url = new ResourceUrlAnnotation { Url = $"{allocatedEndpoint.UriScheme}://{address}:{allocatedEndpoint.Port}", Endpoint = endpointReference }; | ||
| urls.Add(url); | ||
| } | ||
| else if (endpoint.TargetHost.Length > 10 && endpoint.TargetHost.EndsWith(".localhost", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| url = new ResourceUrlAnnotation { Url = $"{allocatedEndpoint.UriScheme}://{endpoint.TargetHost}:{allocatedEndpoint.Port}", Endpoint = endpointReference }; | ||
DamianEdwards marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| urls.Add(url); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length check (
s.Length > 10) is redundant becauseEndsWith(".localhost")already implies a minimum length. Consider removing the length condition or defining a clear constant for the subdomain suffix to improve readability.