Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cueball

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cueball - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

148

lib/agent.js

@@ -33,2 +33,4 @@ /*

'options.resolvers');
mod_assert.optionalArrayOfString(options.initialDomains,
'options.initialDomains');
mod_assert.optionalNumber(options.tcpKeepAliveInitialDelay,

@@ -71,2 +73,9 @@ 'options.tcpKeepAliveInitialDelay');

this.cba_errOnEmpty = options.errorOnEmpty;
if (options.initialDomains !== undefined) {
var self = this;
options.initialDomains.forEach(function (host) {
self.addPool(host, {});
});
}
}

@@ -84,2 +93,73 @@ mod_util.inherits(CueBallAgent, EventEmitter);

CueBallAgent.prototype.addPool = function (host, options) {
var self = this;
mod_assert.string(host, 'hostname');
var poolOpts = {
defaultPort: this.defaultPort,
resolvers: this.resolvers,
service: this.service,
domain: host,
constructor: constructSocket,
maximum: this.maximum,
spares: this.spares,
log: this.log,
recovery: this.cba_recovery
};
function constructSocket(backend) {
var opts = {
host: backend.address || backend.name,
port: backend.port || self.defaultPort,
servername: backend.name || host
};
PASS_FIELDS.forEach(function (k) {
if (options.hasOwnProperty(k))
opts[k] = options[k];
});
var nsock;
if (self.protocol === 'https:') {
nsock = mod_tls.connect(opts);
/*
* In older versions of node, TLS sockets don't
* quite obey the socket interface -- they emit
* the event 'secureConnect' instead of
* 'connect' and they don't support ref/unref.
*
* We polyfill these here.
*/
if (USE_SECURECONNECT) {
nsock.on('secureConnect',
nsock.emit.bind(nsock, 'connect'));
}
if (nsock.unref === undefined) {
nsock.unref = function () {
nsock.socket.unref();
};
nsock.ref = function () {
nsock.socket.ref();
};
}
} else {
nsock = mod_net.createConnection(opts);
}
if (self.tcpKAID !== undefined) {
nsock.on('connect', function () {
if (USE_SECURECONNECT &&
self.protocol === 'https:') {
nsock.socket.setKeepAlive(true,
self.tcpKAID);
} else {
nsock.setKeepAlive(true,
self.tcpKAID);
}
});
}
return (nsock);
}
if (this.cba_ping !== undefined) {
poolOpts.checkTimeout = this.cba_pingInterval || 30000;
poolOpts.checker = this.checkSocket.bind(this, host);
}
this.pools[host] = new Pool(poolOpts);
};
/*

@@ -94,3 +174,2 @@ * Sets up a duplex stream to be used for the given HTTP request.

CueBallAgent.prototype.addRequest = function (req, optionsOrHost, port) {
var self = this;
var options;

@@ -109,68 +188,3 @@ mod_assert.object(req, 'req');

if (this.pools[host] === undefined) {
var poolOpts = {
defaultPort: this.defaultPort,
resolvers: this.resolvers,
service: this.service,
domain: host,
constructor: constructSocket,
maximum: this.maximum,
spares: this.spares,
log: this.log,
recovery: this.cba_recovery
};
function constructSocket(backend) {
var opts = {
host: backend.address || backend.name,
port: backend.port || self.defaultPort,
servername: backend.name || host
};
PASS_FIELDS.forEach(function (k) {
if (options.hasOwnProperty(k))
opts[k] = options[k];
});
var nsock;
if (self.protocol === 'https:') {
nsock = mod_tls.connect(opts);
/*
* In older versions of node, TLS sockets don't
* quite obey the socket interface -- they emit
* the event 'secureConnect' instead of
* 'connect' and they don't support ref/unref.
*
* We polyfill these here.
*/
if (USE_SECURECONNECT) {
nsock.on('secureConnect',
nsock.emit.bind(nsock, 'connect'));
}
if (nsock.unref === undefined) {
nsock.unref = function () {
nsock.socket.unref();
};
nsock.ref = function () {
nsock.socket.ref();
};
}
} else {
nsock = mod_net.createConnection(opts);
}
if (self.tcpKAID !== undefined) {
nsock.on('connect', function () {
if (USE_SECURECONNECT &&
self.protocol === 'https:') {
nsock.socket.setKeepAlive(true,
self.tcpKAID);
} else {
nsock.setKeepAlive(true,
self.tcpKAID);
}
});
}
return (nsock);
}
if (this.cba_ping !== undefined) {
poolOpts.checkTimeout = this.cba_pingInterval || 30000;
poolOpts.checker = this.checkSocket.bind(this, host);
}
this.pools[host] = new Pool(poolOpts);
this.addPool(host, options);
}

@@ -177,0 +191,0 @@ var pool = this.pools[host];

{
"name": "cueball",
"version": "1.0.3",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -78,2 +78,4 @@ cueball

- `maximum` -- optional Number, maximum number of connections per host
- `initialDomains` -- optional Array of String, initial domains to create
connections to at startup (to pre-seed the Agent for quick user later)
- `tcpKeepAliveInitialDelay` -- optional Number, if supplied, enable TCP

@@ -80,0 +82,0 @@ level keep-alives with the given initial delay (in milliseconds)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc