Skip to content

Commit 508686b

Browse files
committed
Updated proxy.
1 parent 3c8d5dd commit 508686b

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

utils.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -638,28 +638,30 @@ function request_proxy(options, callback) {
638638

639639
var req = Http.request(proxy);
640640

641+
req.setTimeout(2000);
642+
641643
req.on('error', function(e) {
642644
options.callback(new Error('Proxy error: ' + e.toString()), '', 0, EMPTYOBJECT, proxy.hostname, EMPTYOBJECT);
643645
options.callback = null;
644646
});
645647

646648
req.on('connect', function(res, socket) {
649+
647650
if (res.statusCode === 200) {
648651

649652
PROXYTLS.servername = options.uri.hostname;
650653
PROXYTLS.headers = options.uri.headers || {};
651654
PROXYTLS.headers.host = options.uri.hostname + ':' + (options.uri.port || '443');
652655
PROXYTLS.socket = socket;
653656

654-
var tls = Tls.connect(443, PROXYTLS);
657+
var tls = Tls.connect(0, PROXYTLS);
658+
659+
options.proxy.tls = tls;
660+
req.agent.defaultPort = 443;
661+
req.onSocket(tls);
655662

656663
tls.on('secureConnect', function() {
657-
var a = options.uri.agent = new Https.Agent();
658-
a.defaultPort = 443;
659-
a.reuseSocket(tls, req);
660-
req.onSocket(tls);
661-
options.socket = tls;
662-
options.proxy.tls = tls;
664+
tls.end();
663665
callback(options.uri, options);
664666
});
665667

0 commit comments

Comments
 (0)