mirror of
https://github.com/nodejs/node.git
synced 2026-12-03 18:03:02 -05:00
net, http, https: add localAddress option
Binds to a local address before making the outgoing connection.
This commit is contained in:
1 parent
9ea5a4c468
commit
1e9bcf26ce
8 files changed
+186
-20
No files matched your search
+21
-3
@@ -51,12 +51,30 @@ exports.createServer = function(opts, requestListener) {
|
||||
|
||||
// HTTPS agents.
|
||||
|
||||
function createConnection(port, host, options) {
|
||||
options.port = port;
|
||||
options.host = host;
|
||||
function createConnection(/* [port, host, options] */) {
|
||||
var options = {};
|
||||
|
||||
if (typeof arguments[0] === 'object') {
|
||||
options = arguments[0];
|
||||
} else if (typeof arguments[1] === 'object') {
|
||||
options = arguments[1];
|
||||
options.port = arguments[0];
|
||||
} else if (typeof arguments[2] === 'object') {
|
||||
options = arguments[2];
|
||||
options.port = arguments[0];
|
||||
options.host = arguments[1];
|
||||
} else {
|
||||
if (typeof arguments[0] === 'number') {
|
||||
options.port = arguments[0];
|
||||
}
|
||||
if (typeof arguments[1] === 'string') {
|
||||
options.host = arguments[1];
|
||||
}
|
||||
}
|
||||
return tls.connect(options);
|
||||
}
|
||||
|
||||
|
||||
function Agent(options) {
|
||||
http.Agent.call(this, options);
|
||||
this.createConnection = createConnection;
|
||||
|
||||
Reference in new issue
Block a user