Skip to content

Listen to both ipv6 and ipv4 #930

@255kb

Description

@255kb

Issue

Mockoon's server is only listening to ipv4 by default due to the use of ipv4 loopback hosts (0.0.0.0 or 127.0.0.1).
Until now this was kind of ok, but starting with Node 17, http tries to follows the OS preferences and may resolve ipv6 first. Our automated tests will break because of this and it may prevent people to use mocks with a Node.js application.
Also, it is a good idea to listen on all adapters, not only ipv4.

Solution

Currently, the data file has a hostname field set by default to 0.0.0.0. If the env setting "Localhost only" is activated, it switches the hostname to 127.0.0.1. In both cases, this will only listen on ipv4 adapters.

A good solution would be to replace this checkbox by a field and to migrate the env setting hostname from 0.0.0.0 to `` (empty).

  • Empty: would revert to listen to the default Node settings.
  • User provided host: listen to this specific host (would it be 127.0.0.1, localhost, ::1, etc.)

Note : The CLI allows for the same kind of configuration through a flag. It shouldn't require huge modification, except maybe for the logging.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done (ready for next release)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions