denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.18k stars 5.41k forks source link

Network services should preferentially bind to IPv4 #23226

Open mmastrac opened 8 months ago

mmastrac commented 8 months ago

When we bind to an address that has both an IPv4 and IPv6 address, we should preferentially choose the IPv4 address. While technically both are correct, it is most likely that a user expects binding to the IPv4 version of the address, especially with localhost.

In addition, we should file a follow-up issue to determine how users can choose v4 vs v6 binding strategy -- it may make sense for the command line and each network listen to provide an ipv6 flag with the ability to prefer or disable ipv6, and to enable "dual-stack" mode where ipv6 ports can listen for legacy ipv4 addresses (ie: https://docs.rs/socket2/latest/socket2/struct.Socket.html#method.set_only_v6).

This popped up in a recent Github runner change where --ipv4 was placed in .curlrc, and curl no longer worked against localhost, as we had quietly bound to localhost.

yazan-abdalrahman commented 5 months ago

@mmastrac can provide an example so I understand the requirement?