diff --git a/lib/https/index.js b/lib/https/index.js index 14ee12c3c..adde1cd1c 100644 --- a/lib/https/index.js +++ b/lib/https/index.js @@ -30,8 +30,6 @@ var getSNIServer = ca.getSNIServer; var LOCALHOST = '127.0.0.1'; var tunnelTmplData = new LRU({max: 3000, maxAge: 30000}); var TIMEOUT = 5000; -var LOCAL_TIMEOUT = 3000; -var AUTH_TIMEOUT = 3000; var CONN_TIMEOUT = 60000; var X_RE = /^x/; var proxy, server; @@ -810,8 +808,9 @@ module.exports = function(socket, hostname, next, isWebPort) { socket.on('end', request); var clientIp = socket.clientIp; var clientPort = socket.clientPort; - var timeout = isWebPort ? null : (util.isLocalAddress(clientIp) ? LOCAL_TIMEOUT : TIMEOUT); - timer = timeout && setTimeout(request, timeout); + if (!isWebPort) { + timer = setTimeout(request, TIMEOUT); + } function request(chunk) { clearTimeout(timer); headersStr = chunk && chunk.toString(); @@ -848,10 +847,16 @@ module.exports = function(socket, hostname, next, isWebPort) { } else if (chunk[0] != 22) { next(chunk); } else { - var domain = hostname && getDomain(hostname); var recieveData, authTimer; - - var useSNI = (!domain || !serverAgent.existsServer(domain)) && checkSNI(chunk); + var useSNI = checkSNI(chunk); + var domain = useSNI || domain; + if (!domain) { + return next(chunk); + } + domain = getDomain(domain); + if (serverAgent.existsServer(domain)) { + useSNI = false; + } socket.pause(); var checkTimeout = function() { authTimer = setTimeout(function() { @@ -865,7 +870,7 @@ module.exports = function(socket, hostname, next, isWebPort) { } else { next(chunk); } - }, AUTH_TIMEOUT); + }, TIMEOUT); }; var handleConnect = function(port) { util.connect({