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

Microsoft.AspNet.Server.Kestrel.Http.Listener ignores host argument #98

Closed
srdjantot opened this issue May 8, 2015 · 5 comments
Closed
Assignees
Labels
Milestone

Comments

@srdjantot
Copy link

Listener always binds to IPAddress.Any host. This can lead to problems when security policy allow only specific IP to bind to.

Are there any reasons for listener to ignore supplied host argument?

public Task StartAsync(
            string scheme,
            string host,
            int port,
            KestrelThread thread,
            Func<Frame, Task> application)
        {
            Thread = thread;
            Application = application;

            var tcs = new TaskCompletionSource<int>();
            Thread.Post(_ =>
            {
                try
                {
                    ListenSocket = new UvTcpHandle();
                    ListenSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
                    ListenSocket.Bind(new IPEndPoint(IPAddress.Any, port));
                    ListenSocket.Listen(10, _connectionCallback, this);
                    tcs.SetResult(0);
                }
                catch (Exception ex)
                {
                    tcs.SetException(ex);
                }
            }, null);
            return tcs.Task;
        }
@davidfowl
Copy link
Member

Looks like a bug to me

@davidfowl
Copy link
Member

/cc @lodejard

@Tratcher
Copy link
Member

Allow binding to IPs or *.
If localhost is requested, bind to 127.0.0.1 and ::1.
If any other host is requested bind to *.
For *, bind to both IPv4 and IPv6.

@halter73
Copy link
Member

I think this is a dupe of #57. Should we close one of these issues?

@Tratcher
Copy link
Member

Taken care of.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants