Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix additional inconsistencies (hostname vs host) in DNS. #20892
  • Loading branch information
Shakeel Mohamed committed Oct 12, 2018
commit 8c1e1d014b0401651b463ad38cf94a128b5d6240
18 changes: 9 additions & 9 deletions lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,34 +127,34 @@ function onlookupservice(err, hostname, service) {
this.resolve({ hostname, service });
}

function createLookupServicePromise(host, port) {
function createLookupServicePromise(hostname, port) {
return new Promise((resolve, reject) => {
const req = new GetNameInfoReqWrap();

req.host = host;
req.hostname = hostname;
req.port = port;
req.oncomplete = onlookupservice;
req.resolve = resolve;
req.reject = reject;

const err = getnameinfo(req, host, port);
const err = getnameinfo(req, hostname, port);

if (err)
reject(dnsException(err, 'getnameinfo', host));
reject(dnsException(err, 'getnameinfo', hostname));
});
}

function lookupService(host, port) {
function lookupService(hostname, port) {
if (arguments.length !== 2)
throw new ERR_MISSING_ARGS('host', 'port');
throw new ERR_MISSING_ARGS('hostname', 'port');

if (isIP(host) === 0)
throw new ERR_INVALID_OPT_VALUE('host', host);
if (isIP(hostname) === 0)
throw new ERR_INVALID_OPT_VALUE('hostname', hostname);

if (!isLegalPort(port))
throw new ERR_SOCKET_BAD_PORT(port);

return createLookupServicePromise(host, +port);
return createLookupServicePromise(hostname, +port);
}


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ dns.lookup('', {
const err = {
code: 'ERR_INVALID_OPT_VALUE',
type: TypeError,
message: `The value "${invalidHost}" is invalid for option "host"`
message: `The value "${invalidHost}" is invalid for option "hostname"`
};

common.expectsError(() => {
Expand Down