Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const testRoot = path.resolve(process.env.NODE_TEST_DIR ||
path.dirname(__filename));
exports.testDir = path.dirname(__filename);
exports.fixturesDir = path.join(exports.testDir, 'fixtures');
exports.libDir = path.join(exports.testDir, '../lib');
exports.tmpDirName = 'tmp';
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
exports.isWindows = process.platform === 'win32';
exports.isWOW64 = exports.isWindows &&
(process.env['PROCESSOR_ARCHITEW6432'] !== undefined);
exports.isAix = process.platform === 'aix';
exports.isLinuxPPCBE = (process.platform === 'linux') &&
(process.arch === 'ppc64') &&
(os.endianness() === 'BE');
exports.isSunOS = process.platform === 'sunos';
exports.isFreeBSD = process.platform === 'freebsd';
exports.enoughTestMem = os.totalmem() > 0x20000000; /* 512MB */
function rimrafSync(p) {
try {
var st = fs.lstatSync(p);
} catch (e) {
if (e.code === 'ENOENT')
return;
}
try {
if (st && st.isDirectory())
rmdirSync(p, null);
const f = require('util').format;
const ReadPreference = require('./read_preference');
/**
* Emit event if it exists
* @method
*/
function emitSDAMEvent(self, event, description) {
if (self.listeners(event).length > 0) {
self.emit(event, description);
}
}
// Get package.json variable
var driverVersion = require('../../package.json').version;
var nodejsversion = f('Node.js %s, %s', process.version, os.endianness());
var type = os.type();
var name = process.platform;
var architecture = process.arch;
var release = os.release();
function createClientInfo(options) {
// Build default client information
var clientInfo = options.clientInfo
? clone(options.clientInfo)
: {
driver: {
name: 'nodejs-core',
version: driverVersion
},
os: {
type: type,
/* Copyright 2015-present Facebook, Inc.
* Licensed under the Apache License, Version 2.0 */
var EE = require('events').EventEmitter;
var util = require('util');
var os = require('os');
var assert = require('assert');
var Int64 = require('node-int64');
// BSER uses the local endianness to reduce byte swapping overheads
// (the protocol is expressly local IPC only). We need to tell node
// to use the native endianness when reading various native values.
var isBigEndian = os.endianness() == 'BE';
// Find the next power-of-2 >= size
function nextPow2(size) {
return Math.pow(2, Math.ceil(Math.log(size) / Math.LN2));
}
// Expandable buffer that we can provide a size hint for
function Accumulator(initsize) {
this.buf = new Buffer(nextPow2(initsize || 8192));
this.readOffset = 0;
this.writeOffset = 0;
}
// For testing
exports.Accumulator = Accumulator
// How much we can write into this buffer without allocating
setup_get_property(this, 'hasAggregationCursor', aggregationCursor);
setup_get_property(this, 'hasWriteCommands', writeCommands);
setup_get_property(this, 'hasTextSearch', textSearch);
setup_get_property(this, 'hasAuthCommands', authCommands);
setup_get_property(this, 'hasListCollectionsCommand', listCollections);
setup_get_property(this, 'hasListIndexesCommand', listIndexes);
setup_get_property(this, 'minWireVersion', ismaster.minWireVersion);
setup_get_property(this, 'maxWireVersion', ismaster.maxWireVersion);
setup_get_property(this, 'maxNumberOfDocsInBatch', maxNumberOfDocsInBatch);
setup_get_property(this, 'commandsTakeWriteConcern', commandsTakeWriteConcern);
setup_get_property(this, 'commandsTakeCollation', commandsTakeCollation);
};
// Get package.json variable
const driverVersion = require('../../package.json').version,
nodejsversion = f('Node.js %s, %s', process.version, os.endianness()),
type = os.type(),
name = process.platform,
architecture = process.arch,
release = os.release();
class TopologyBase extends EventEmitter {
constructor() {
super();
// Build default client information
this.clientInfo = {
driver: {
name: 'nodejs',
version: driverVersion
},
os: {
, Cursor = require('./cursor')
, AggregationCursor = require('./aggregation_cursor')
, CommandCursor = require('./command_cursor')
, Define = require('./metadata')
, Server = require('./server')
, Store = require('./topology_base').Store
, MAX_JS_INT = require('./utils').MAX_JS_INT
, translateOptions = require('./utils').translateOptions
, filterOptions = require('./utils').filterOptions
, mergeOptions = require('./utils').mergeOptions
, getReadPreference = require('./utils').getReadPreference
, os = require('os');
// Get package.json variable
var driverVersion = require('../package.json').version;
var nodejsversion = f('Node.js %s, %s', process.version, os.endianness());
var type = os.type();
var name = process.platform;
var architecture = process.arch;
var release = os.release();
/**
* @fileOverview The **Mongos** class is a class that represents a Mongos Proxy topology and is
* used to construct connections.
*
* **Mongos Should not be used, use MongoClient.connect**
* @example
* var Db = require('mongodb').Db,
* Mongos = require('mongodb').Mongos,
* Server = require('mongodb').Server,
* test = require('assert');
* // Connect using Mongos
, Cursor = require('./cursor')
, AggregationCursor = require('./aggregation_cursor')
, CommandCursor = require('./command_cursor')
, Define = require('./metadata')
, Server = require('./server')
, Store = require('./topology_base').Store
, MAX_JS_INT = require('./utils').MAX_JS_INT
, translateOptions = require('./utils').translateOptions
, filterOptions = require('./utils').filterOptions
, mergeOptions = require('./utils').mergeOptions
, getReadPreference = require('./utils').getReadPreference
, os = require('os');
// Get package.json variable
var driverVersion = require('../package.json').version;
var nodejsversion = f('Node.js %s, %s', process.version, os.endianness());
var type = os.type();
var name = process.platform;
var architecture = process.arch;
var release = os.release();
/**
* @fileOverview The **Mongos** class is a class that represents a Mongos Proxy topology and is
* used to construct connections.
*
* **Mongos Should not be used, use MongoClient.connect**
* @example
* var Db = require('mongodb').Db,
* Mongos = require('mongodb').Mongos,
* Server = require('mongodb').Server,
* test = require('assert');
* // Connect using Mongos
* db.close();
* });
*/
// Allowed parameters
var legalOptionNames = ['ha', 'haInterval', 'replicaSet', 'rs_name', 'secondaryAcceptableLatencyMS'
, 'connectWithNoPrimary', 'poolSize', 'ssl', 'checkServerIdentity', 'sslValidate'
, 'sslCA', 'sslCert', 'sslKey', 'sslPass', 'socketOptions', 'bufferMaxEntries'
, 'store', 'auto_reconnect', 'autoReconnect', 'emitError'
, 'keepAlive', 'noDelay', 'connectTimeoutMS', 'socketTimeoutMS', 'strategy', 'debug'
, 'loggerLevel', 'logger', 'reconnectTries', 'appname', 'domainsEnabled'
, 'servername', 'promoteLongs', 'promoteValues', 'promoteBuffers'];
// Get package.json variable
var driverVersion = require(__dirname + '/../package.json').version;
var nodejsversion = f('Node.js %s, %s', process.version, os.endianness());
var type = os.type();
var name = process.platform;
var architecture = process.arch;
var release = os.release();
/**
* Creates a new ReplSet instance
* @class
* @deprecated
* @param {Server[]} servers A seedlist of servers participating in the replicaset.
* @param {object} [options=null] Optional settings.
* @param {booelan} [options.ha=true] Turn on high availability monitoring.
* @param {number} [options.haInterval=10000] Time between each replicaset status check.
* @param {string} [options.replicaSet] The name of the replicaset to connect to.
* @param {number} [options.secondaryAcceptableLatencyMS=15] Sets the range of servers to pick when using NEAREST (lowest ping ms + the latency fence, ex: range of 1 to (1 + 15) ms)
* @param {boolean} [options.connectWithNoPrimary=false] Sets if the driver should connect even if no primary is available
'use strict';
const assert = require('assert');
const inspect = require('util').inspect;
const debug = require('debug')('ref');
const os = require('os');
exports = module.exports = require('bindings')('binding');
exports.endianness = os.endianness();
/**
* A `Buffer` that references the C NULL pointer. That is, its memory address
* points to 0. Its `length` is 0 because accessing any data from this buffer
* would cause a _segmentation fault_.
*
* ```
* console.log(ref.NULL);
*
* ```
*
* @name NULL
* @type Buffer
*/
/**
data: {
loadavg: os.loadavg(),
platform: os.platform(),
tmpdir: os.tmpdir(),
uptime: os.uptime()
}
};
var config = context.client.config;
if (config.includeMachineName) {
environmentInfo.machine_name = os.hostname();
}
if (config.includeIpAddress) {
environmentInfo.ip_address = getIpAddresses();
}
if (os.endianness) {
environmentInfo.data.endianness = os.endianness();
}
return environmentInfo;
};
return NodeEnvironmentInfoCollector;