mirror of
https://github.com/avwo/whistle.git
synced 2026-10-28 22:59:50 +08:00
feat: auto reduce to http request
This commit is contained in:
+11
-2
@@ -304,7 +304,7 @@ function _handleWebsocket(socket, clientIp, clientPort, callback, wss) {
|
||||
}
|
||||
}
|
||||
|
||||
function connectServer(hostIp, hostPort) {
|
||||
function connectServer(hostIp, hostPort, err) {
|
||||
getServerIp(fullUrl, function(ip, port) {
|
||||
var isWss = options.protocol === 'wss:';
|
||||
socket.hostIp = resData.ip = port ? ip + ':' + port : ip;
|
||||
@@ -316,7 +316,16 @@ function _handleWebsocket(socket, clientIp, clientPort, callback, wss) {
|
||||
port: port,
|
||||
servername: options.hostname
|
||||
}, pipeData);
|
||||
abortIfUnavailable(reqSocket);
|
||||
if (err) {
|
||||
abortIfUnavailable(reqSocket);
|
||||
} else {
|
||||
reqSocket.on('error', function(e) {
|
||||
if (util.checkTlsHandUp(socket, ip, e)) {
|
||||
options.protocol = null;
|
||||
}
|
||||
connectServer(hostIp, hostPort, e);
|
||||
});
|
||||
}
|
||||
}, hostIp, hostPort);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user