Skip to content

Commit

Permalink
fix(NODE-2939): use host on cname error
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Feb 4, 2022
1 parent 392bb8e commit 77a4f37
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/cmap/auth/gssapi.ts
Expand Up @@ -184,11 +184,15 @@ function performGssapiCanonicalizeHostName(
if (mode === true || mode === 'forwardAndReverse') {
// Perform the lookup of the ip address.
dns.lookup(host, (error, address) => {
/* eslint no-console: 0 */
console.log('lookup', host, error, address);
// No ip found, return the error.
if (error) return callback(error);

// Perform a reverse ptr lookup on the ip address.
dns.resolvePtr(address, (err, results) => {
/* eslint no-console: 0 */
console.log('resolvePtr', err, results);
// This can error as ptr records may not exist for all ips. In this case
// fallback to a cname lookup as dns.lookup() does not return the
// cname.
Expand All @@ -199,16 +203,19 @@ function performGssapiCanonicalizeHostName(
callback(undefined, results.length > 0 ? results[0] : host);
});
});
} else {
// The case for forward is just to resolve the cname as dns.lookup()
// will not return it.
resolveCname(host, callback);
}
// The case for forward is just to resolve the cname as dns.lookup()
// will not return it.
resolveCname(host, callback);
}

function resolveCname(host: string, callback: Callback<string>): void {
// Attempt to resolve the host name
dns.resolveCname(host, (err, r) => {
if (err) return callback(err);
/* eslint no-console: 0 */
console.log('resolveCname', err, r);
if (err) return callback(undefined, host);

// Get the first resolve host id
if (r.length > 0) {
Expand Down

0 comments on commit 77a4f37

Please sign in to comment.