Skip to content

Conversation

@DeagleGross
Copy link
Member

@DeagleGross DeagleGross commented Nov 11, 2024

On a machine that supports IPv6, listening to Any, rather than IPv6Any will either not work or be slower than necessary. For HTTP/1.x and 2/0, a name like localhost will resolve to [::1], which won't be accepted by the server, forcing a retry with 127.0.0.1 (i.e. failed attempt before each connection).

Implemented in a way, as specified by @amcasey:

Probably best to just always report the diagnostic and let users disable it if they know it doesn't apply

PR adds the analyzer, which catches options.Listen(IPAddress.Any, ...) usage, and a code fix, which explicitly changes the argument to IPAddress.IPv6Any.

Docs PR

Fixes #58172

@DeagleGross DeagleGross added the analyzer Indicates an issue which is related to analyzer experience label Nov 11, 2024
@DeagleGross DeagleGross self-assigned this Nov 11, 2024
@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Nov 11, 2024
@DeagleGross
Copy link
Member Author

@dotnet-policy-service agree company="Microsoft"

@DeagleGross DeagleGross marked this pull request as ready for review November 12, 2024 11:59
@DeagleGross DeagleGross enabled auto-merge (squash) November 13, 2024 10:30
@DeagleGross DeagleGross merged commit 5c6839e into dotnet:main Nov 13, 2024
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Nov 13, 2024
@DeagleGross DeagleGross deleted the dmkorolev/analyzers/listenoptions branch November 13, 2024 15:42
captainsafia pushed a commit that referenced this pull request Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analyzer Indicates an issue which is related to analyzer experience area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider flagging ListenOptions.Listen(IPAddress.Any)

4 participants