Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7a3e354

Browse files
Julien Gillichrisdickinson
authored andcommittedJun 17, 2015
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: nodejs/node-v0.x-archive#8540 Fixes: nodejs/node-v0.x-archive#9204 PR-URL: nodejs/node-v0.x-archive#18204 PR-URL: #1555 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 0925aba commit 7a3e354

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
 

‎doc/api/dns.markdown

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ The following flags can be passed as hints to `dns.lookup`.
267267
of addresses supported by the current system. For example, IPv4 addresses
268268
are only returned if the current system has at least one IPv4 address
269269
configured. Loopback addresses are not considered.
270-
- `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses
271-
were found, then return IPv4 mapped IPv6 addresses.
270+
- `dns.V4MAPPED`: If the IPv6 family was specified, but no IPv6 addresses were
271+
found, then return IPv4 mapped IPv6 addresses. Note that it is not supported
272+
on some operating systems (e.g FreeBSD 10.1).
272273

273274
## Implementation considerations
274275

‎lib/net.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,16 @@ function lookupAndConnect(self, options) {
937937
hints: 0
938938
};
939939

940-
if (dnsopts.family !== 4 && dnsopts.family !== 6)
941-
dnsopts.hints = dns.ADDRCONFIG | dns.V4MAPPED;
940+
if (dnsopts.family !== 4 && dnsopts.family !== 6) {
941+
dnsopts.hints = dns.ADDRCONFIG;
942+
// The AI_V4MAPPED hint is not supported on FreeBSD, and getaddrinfo
943+
// returns EAI_BADFLAGS. However, it seems to be supported on most other
944+
// systems. See
945+
// http://lists.freebsd.org/pipermail/freebsd-bugs/2008-February/028260.html
946+
// for more information on the lack of support for FreeBSD.
947+
if (process.platform !== 'freebsd')
948+
dnsopts.hints |= dns.V4MAPPED;
949+
}
942950

943951
debug('connect: find host ' + host);
944952
debug('connect: dns options ' + dnsopts);

0 commit comments

Comments
 (0)