natemcmaster / dotnet-serve

Simple command-line HTTPS server for the .NET Core CLI

Home Page:https://nuget.org/packages/dotnet-serve/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reporting wrong host

lejsekt opened this issue · comments

Describe the bug
dotnet serve reports a wrong host (or perhaps does not report all the host that it is serving on).

To Reproduce
dotnet serve --address 0.0.0.0

Output in the terminal:

Starting server, serving .
Listening on:
http://localhost:37161

But it is possible to reach it on all the network interfaces.

Expected behavior
Listening on should be http://0.0.0.0:3761 or all the hosts should be reported.

Thank you.

0.0.0.0 is a special case because of #6.

static string NormalizeToLoopbackAddress(string url)
{
// normalize to loopback if binding to IPAny
url = url.Replace("0.0.0.0", "localhost");
url = url.Replace("[::]", "localhost");
return url;
}

The server running is actually running on IPAny, but it's just not what we print to the console because that makes the link un-clickable for Windows developers.

I see. But how about adjusting the message? Such as "Listening on any IP:". Or adding something after http://localhost:{port} such as "(and on any IP as well)"?

That seems like a good update. Would you be willing to make a pull request for that?

Yes: #133