Skip to content
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

Listen on all ips #1154

Closed
cocoon opened this issue Aug 9, 2024 · 5 comments
Closed

Listen on all ips #1154

cocoon opened this issue Aug 9, 2024 · 5 comments
Assignees
Labels

Comments

@cocoon
Copy link
Contributor

cocoon commented Aug 9, 2024

I ask this as question, maybe I missed something obvious.

When I want to listen to all public IPs I thought I could use http://0.0.0.0 as URL, but it was not working.
So I had to get all my current IPs and add them as List.

And when I check this line of code:

https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Owin/AspNetCoreSelfHost.NETStandard.cs#L79

it looks like it should use "ListenAnyIP" but instead it is listed in "ListenLocalhost"?

@cocoon cocoon added the question label Aug 9, 2024
@StefH
Copy link
Collaborator

StefH commented Aug 9, 2024

I need to double check that.

BTW what .NET version are you using?

@cocoon
Copy link
Contributor Author

cocoon commented Aug 9, 2024

I usually use .net 8 now.

@cocoon
Copy link
Contributor Author

cocoon commented Aug 12, 2024

I tried it and moved the host check for 0.0.0.0 at top and return it as ListenAnyIP and it works:

if (urlDetail is { Port: > 0, Host: "0.0.0.0" })
 {
     kestrelOptions.ListenAnyIP(urlDetail.Port, configure);
     return;
 }
var Settings = new WireMock.Settings.WireMockServerSettings
{
    Urls = new string[] { "http://0.0.0.0:80" },
    AllowPartialMapping = true,
    StartAdminInterface = true,
};

var server = WireMockServer.Start(Settings);

WireMock NET-0 0 0 0

@StefH
Copy link
Collaborator

StefH commented Aug 13, 2024

Looks good.

Can you make a PR and if possible add/update a unit test?

@StefH StefH self-assigned this Aug 15, 2024
@StefH StefH added bug and removed question labels Aug 15, 2024
@cocoon
Copy link
Contributor Author

cocoon commented Sep 4, 2024

PR created and tried to add a test.

@cocoon cocoon closed this as completed Sep 4, 2024
@StefH StefH reopened this Sep 4, 2024
@StefH StefH closed this as completed Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants