Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Add ListenLocalhost and ListenAnyIP #2159

Merged
merged 1 commit into from
Nov 17, 2017
Merged

Add ListenLocalhost and ListenAnyIP #2159

merged 1 commit into from
Nov 17, 2017

Conversation

Tratcher
Copy link
Member

#2139 Still needs tests

This abstracts the address parser to work independently of the binder so it can be used for future config code. It also adds first class support for two scenarios formerly only available via UseUrls, ListenLocalhost and ListenAnyIP. Both of these provide dynamic fallback behavior that's not was not possible with a single ListenOptions before.

@Tratcher Tratcher added this to the 2.1.0-preview1 milestone Nov 14, 2017
@Tratcher Tratcher self-assigned this Nov 14, 2017
@Tratcher Tratcher requested a review from halter73 November 14, 2017 23:59
@@ -9,6 +9,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
public enum ListenType
{
IPEndPoint,
Localhost,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes me super sad

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the feeling. Still better than "Prefix" though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it, I think this is too big of a hack to exist. It doesn't fit the current model. This enum needs to be something else and not part of ListenType.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such as? I could drive from Listen options and type check. Or add a second enum IPMode with values LocalhostSplit, AnyIPFallback, and Single. Or derive from ListenOptions and put the bind method on that type. Hmm, that might work...

@Tratcher Tratcher force-pushed the tratcher/localhost3 branch 2 times, most recently from 19a56db to fdf9229 Compare November 16, 2017 03:47
@Tratcher Tratcher changed the title [WIP] Add ListenLocalhost and ListenAnyIP Add ListenLocalhost and ListenAnyIP Nov 16, 2017
@Tratcher
Copy link
Member Author

Rebased and updated with tests, ready for review.

@@ -182,5 +183,11 @@ public ConnectionDelegate Build()

return app;
}

internal virtual async Task BindAsync(AddressBinder.AddressBindContext context)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: unnest AddressBindContext

}

private static async Task BindAddressAsync(string address, AddressBindContext context)
internal static ListenOptions ParseAddress(string address, KestrelServerOptions serverOptions, IDefaultHttpsProvider defaultHttpsProvider)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending nit.

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Tratcher Tratcher force-pushed the tratcher/localhost3 branch from 709c1a2 to 89d1862 Compare November 17, 2017 00:14
@Tratcher Tratcher merged commit 89d1862 into dev Nov 17, 2017
@Tratcher Tratcher deleted the tratcher/localhost3 branch November 17, 2017 00:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants