Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

Commit ce83321

Browse files
author
Julien Gilli
committed
net: do not set V4MAPPED on FreeBSD
V4MAPPED is not supported on recent FreeBSD versions, at least on 10.1. Thus, do not set this flag in net.connect on FreeBSD. Fixes #8540 and #9204.
1 parent f99eaef commit ce83321

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

lib/net.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -917,8 +917,18 @@ Socket.prototype.connect = function(options, cb) {
917917
throw new RangeError('port should be >= 0 and < 65536: ' +
918918
options.port);
919919

920-
if (dnsopts.family !== 4 && dnsopts.family !== 6)
921-
dnsopts.hints = dns.ADDRCONFIG | dns.V4MAPPED;
920+
if (dnsopts.family !== 4 && dnsopts.family !== 6) {
921+
dnsopts.hints = dns.ADDRCONFIG;
922+
// The AI_V4MAPPED hint is not supported on FreeBSD, and getaddrinfo
923+
// returns EAI_BADFLAGS. However, it seems to be supported on most other
924+
// systems. See
925+
// http://lists.freebsd.org/pipermail/freebsd-bugs/2008-February/028260.html
926+
// and
927+
// https://svnweb.freebsd.org/base/head/lib/libc/net/getaddrinfo.c?r1=172052&r2=175955
928+
// for more information on the lack of support for FreeBSD.
929+
if (process.platform !== 'freebsd')
930+
dnsopts.hints |= dns.V4MAPPED;
931+
}
922932

923933
debug('connect: find host ' + host);
924934
debug('connect: dns options ' + dnsopts);

0 commit comments

Comments
 (0)