Merge branch 'master' of git://github.com/mcavage/node-ldapjs

Latest changes from mcavage.
This commit is contained in:
Matti Kononen 2013-05-20 16:45:50 +03:00
commit 47e9368769
9 changed files with 69 additions and 36 deletions

View File

@ -9,13 +9,11 @@ var url = require('url');
var nopt = require('nopt');
var ldap = require('../lib/index');
var Logger = require('bunyan');
///--- Globals
var log4js = ldap.log4js;
nopt.typeDefs.DN = {
type: ldap.DN,
validate: function(data, k, val) {
@ -78,7 +76,7 @@ function perror(err) {
///--- Mainline
log4js.setGlobalLogLevel('INFO');
var logLevel = 'info';
var parsed;
try {
@ -112,7 +110,7 @@ if (!parsed.file)
usage(1, 'either -f or stdin must be used for adding objects');
if (parsed.debug)
log4js.setGlobalLogLevel(parsed.debug > 1 ? 'TRACE' : 'DEBUG');
logLevel = (parsed.debug > 1 ? 'trace' : 'debug');
if (!parsed.url)
parsed.url = 'ldap://127.0.0.1:389';
if (!parsed.binddn)
@ -120,9 +118,16 @@ if (!parsed.binddn)
if (!parsed.password)
parsed.password = '';
var log = new Logger({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: logLevel
});
var client = ldap.createClient({
url: parsed.url,
log4js: log4js
log: log
});
client.on('error', function(err) {

View File

@ -9,13 +9,11 @@ var url = require('url');
var nopt = require('nopt');
var ldap = require('../lib/index');
var Logger = require('bunyan');
///--- Globals
var log4js = ldap.log4js;
nopt.typeDefs.DN = {
type: ldap.DN,
validate: function(data, k, val) {
@ -82,7 +80,7 @@ function perror(err) {
///--- Mainline
log4js.setGlobalLogLevel('INFO');
var logLevel = 'info';
var parsed;
try {
@ -108,7 +106,7 @@ if (!parsed.attribute || typeof(parsed.value) !== 'string')
usage(1, 'attribute and value required');
if (parsed.debug)
log4js.setGlobalLogLevel(parsed.debug > 1 ? 'TRACE' : 'DEBUG');
logLevel = (parsed.debug > 1 ? 'trace' : 'debug');
if (!parsed.url)
parsed.url = 'ldap://127.0.0.1:389';
if (!parsed.binddn)
@ -116,9 +114,16 @@ if (!parsed.binddn)
if (!parsed.password)
parsed.password = '';
var log = new Logger({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: logLevel
});
var client = ldap.createClient({
url: parsed.url,
log4js: log4js
log: log
});
client.on('error', function(err) {

View File

@ -9,13 +9,11 @@ var url = require('url');
var nopt = require('nopt');
var ldap = require('../lib/index');
var Logger = require('bunyan');
///--- Globals
var log4js = ldap.log4js;
nopt.typeDefs.DN = {
type: ldap.DN,
validate: function(data, k, val) {
@ -76,7 +74,7 @@ function perror(err) {
///--- Mainline
log4js.setGlobalLogLevel('INFO');
var logLevel = 'info';
var parsed;
try {
@ -98,7 +96,7 @@ try {
}
if (parsed.debug)
log4js.setGlobalLogLevel(parsed.debug > 1 ? 'TRACE' : 'DEBUG');
logLevel = (parsed.debug > 1 ? 'trace' : 'debug');
if (!parsed.url)
parsed.url = 'ldap://127.0.0.1:389';
if (!parsed.binddn)
@ -106,9 +104,16 @@ if (!parsed.binddn)
if (!parsed.password)
parsed.password = '';
var log = new Logger({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: logLevel
});
var client = ldap.createClient({
url: parsed.url,
log4js: log4js
log: log
});
client.on('error', function(err) {

View File

@ -9,13 +9,11 @@ var url = require('url');
var nopt = require('nopt');
var ldap = require('../lib/index');
var Logger = require('bunyan');
///--- Globals
var log4js = ldap.log4js;
nopt.typeDefs.DN = {
type: ldap.DN,
validate: function(data, k, val) {
@ -84,7 +82,7 @@ function perror(err) {
///--- Mainline
log4js.setGlobalLogLevel('INFO');
var logLevel = 'info';
var parsed;
try {
@ -112,7 +110,7 @@ if (!parsed.attribute || !Array.isArray(parsed.value))
usage(1, 'attribute and value required');
if (parsed.debug)
log4js.setGlobalLogLevel(parsed.debug > 1 ? 'TRACE' : 'DEBUG');
logLevel = (parsed.debug > 1 ? 'trace' : 'debug');
if (!parsed.url)
parsed.url = 'ldap://127.0.0.1:389';
if (!parsed.binddn)
@ -120,9 +118,16 @@ if (!parsed.binddn)
if (!parsed.password)
parsed.password = '';
var log = new Logger({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: logLevel
});
var client = ldap.createClient({
url: parsed.url,
log4js: log4js
log: log
});
client.on('error', function(err) {

View File

@ -8,13 +8,11 @@ var url = require('url');
var nopt = require('nopt');
var ldap = require('../lib/index');
var Logger = require('bunyan');
///--- Globals
var log4js = ldap.log4js;
nopt.typeDefs.DN = {
type: ldap.DN,
validate: function(data, k, val) {
@ -114,9 +112,10 @@ try {
usage(1, e.message);
}
var logLevel = 'info';
if (parsed.debug)
log4js.setGlobalLogLevel(parsed.debug > 1 ? 'TRACE' : 'DEBUG');
logLevel = (parsed.debug > 1 ? 'trace' : 'debug');
if (!parsed.url)
parsed.url = 'ldap://127.0.0.1:389';
if (!parsed.binddn)
@ -130,9 +129,16 @@ if (!parsed.control)
if (!parsed.persistent)
parsed.persistent = false;
var log = new Logger({
name: 'ldapjs',
component: 'client',
stream: process.stderr,
level: logLevel
});
var client = ldap.createClient({
url: parsed.url,
log4js: log4js,
log: log,
timeout: parsed.timeout || false
});

View File

@ -31,6 +31,7 @@ client is:
||timeout||How long the client should let operations live for before timing out. Default is Infinity.||
||connectTimeout||How long the client should wait before timing out on TCP connections. Default is up to the OS.||
||maxConnections||Whether or not to enable connection pooling, and if so, how many to maintain.||
||tlsOptions||Additional [options](http://nodejs.org/api/tls.html#tls_tls_connect_port_host_options_callback) passed to the TLS connection layer when connecting via `ldaps://`||
If using connection pooling, you can additionally pass in:

View File

@ -231,6 +231,7 @@ function Client(options) {
this.log = options.log.child({clazz: 'Client'}, true);
this.port = _url ? _url.port : false;
this.secure = _url ? _url.secure : false;
this.tlsOptions = options.tlsOptions;
this.socketPath = options.socketPath || false;
this.timeout = parseInt((options.timeout || 0), 10);
this.url = _url;
@ -690,6 +691,9 @@ Client.prototype.unbind = function unbind(callback) {
return callback();
var req = new UnbindRequest();
if (this.socket.listeners('error').length === 0) {
this.socket.once('error', function(){});
}
return this._send(req, 'unbind', null, callback);
};
@ -721,7 +725,7 @@ Client.prototype._connect = function _connect() {
self.emit('connect', socket);
}
socket = proto.connect((this.port || this.socketPath), this.host);
socket = proto.connect((this.port || this.socketPath), this.host, this.secure ? this.tlsOptions : null);
socket.once('connect', onConnect);
socket.once('secureConnect', onConnect);

View File

@ -76,12 +76,12 @@ function createPool(options) {
return callback(err);
res.on('error', function (e) {
client.removeAllListeners('end');
res.removeAllListeners('end');
callback(e);
});
res.on('end', function () {
client.removeAllListeners('error');
res.removeAllListeners('error');
callback(null);
});
@ -115,7 +115,8 @@ function ClientPool(options) {
log: options.log,
socketPath: options.socketPath,
timeout: (options.timeout || 0),
url: options.url
url: options.url,
tlsOptions: options.tlsOptions
};
this.pool = createPool(options);
}

View File

@ -6,7 +6,8 @@
"Mathieu Lecarme <mathieu@garambrogne.net>>",
"Trent Mick <trentm@gmail.com>",
"Yunong Xiao <yunong@joyent.com>",
"Denis Vuyka <denis.vuyka@gmail.com>"
"Denis Vuyka <denis.vuyka@gmail.com>",
"Pedro Palazón <kusorbox@gmail.com>"
],
"name": "ldapjs",
"homepage": "http://ldapjs.org",
@ -28,10 +29,10 @@
"asn1": "0.1.11",
"assert-plus": "0.1.2",
"buffertools": "1.1.0",
"bunyan": "0.18.2",
"bunyan": "0.21.1",
"dtrace-provider": "0.2.8",
"nopt": "2.1.1",
"pooling": "0.4.1"
"pooling": "0.4.4"
},
"devDependencies": {
"tap": "0.4.0",