Skip to content

Commit

Permalink
Fix additional inconsistencies (hostname vs host) in DNS. nodejs#20892
Browse files Browse the repository at this point in the history
  • Loading branch information
Shakeel Mohamed committed Oct 12, 2018
1 parent 0bd9cf4 commit 8c1e1d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
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

0 comments on commit 8c1e1d0

Please sign in to comment.