diff --git a/lib/handshake.js b/lib/handshake.js index 83304ae..830dec7 100644 --- a/lib/handshake.js +++ b/lib/handshake.js @@ -58,12 +58,15 @@ function hexlify (input) { module.exports = function auth (stream, opts, cb) { // filter used to make a copy so we don't accidently change opts data - let authMethods; - if (opts.authMethods) { - authMethods = opts.authMethods; - } else { + let authMethods = opts.authMethods; + if (opts.authMethods === undefined) { authMethods = constants.defaultAuthMethods; } + const skipAuthentication = authMethods.length === 0; + if (skipAuthentication) { + stream.once('readable', () => { cb(null, null); }); + return; + } stream.write('\0'); tryAuth(stream, authMethods.slice(), cb); };