@@ -313,28 +313,28 @@ function Server (options) {
313
313
return c
314
314
}
315
315
316
- function newConnection ( c ) {
317
- setupConnection ( c )
318
- log . trace ( 'new connection from %s' , c . ldap . id )
316
+ function newConnection ( conn ) {
317
+ setupConnection ( conn )
318
+ log . trace ( 'new connection from %s' , conn . ldap . id )
319
319
320
320
dtrace . fire ( 'server-connection' , function ( ) {
321
- return [ c . remoteAddress ]
321
+ return [ conn . remoteAddress ]
322
322
} )
323
323
324
- c . parser = new Parser ( {
324
+ conn . parser = new Parser ( {
325
325
log : options . log
326
326
} )
327
- c . parser . on ( 'message' , function ( req ) {
328
- req . connection = c
329
- req . logId = c . ldap . id + '::' + req . messageID
327
+ conn . parser . on ( 'message' , function ( req ) {
328
+ req . connection = conn
329
+ req . logId = conn . ldap . id + '::' + req . messageID
330
330
req . startTime = new Date ( ) . getTime ( )
331
331
332
- log . debug ( '%s: message received: req=%j' , c . ldap . id , req . json )
332
+ log . debug ( '%s: message received: req=%j' , conn . ldap . id , req . json )
333
333
334
334
const res = getResponse ( req )
335
335
if ( ! res ) {
336
336
log . warn ( 'Unimplemented server method: %s' , req . type )
337
- c . destroy ( )
337
+ conn . destroy ( )
338
338
return false
339
339
}
340
340
@@ -368,18 +368,18 @@ function Server (options) {
368
368
}
369
369
}
370
370
371
- res . connection = c
371
+ res . connection = conn
372
372
res . logId = req . logId
373
373
res . requestDN = req . dn
374
374
375
375
const chain = self . _getHandlerChain ( req , res )
376
376
377
377
let i = 0
378
378
return ( function messageIIFE ( err ) {
379
- function sendError ( err ) {
380
- res . status = err . code || errors . LDAP_OPERATIONS_ERROR
379
+ function sendError ( sendErr ) {
380
+ res . status = sendErr . code || errors . LDAP_OPERATIONS_ERROR
381
381
res . matchedDN = req . suffix ? req . suffix . toString ( ) : ''
382
- res . errorMessage = err . message || ''
382
+ res . errorMessage = sendErr . message || ''
383
383
return res . end ( )
384
384
}
385
385
@@ -388,8 +388,8 @@ function Server (options) {
388
388
389
389
function next ( ) { } // stub out next for the post chain
390
390
391
- self . _postChain . forEach ( function ( c ) {
392
- c . call ( self , req , res , next )
391
+ self . _postChain . forEach ( function ( cb ) {
392
+ cb . call ( self , req , res , next )
393
393
} )
394
394
}
395
395
@@ -404,7 +404,7 @@ function Server (options) {
404
404
const next = messageIIFE
405
405
if ( chain . handlers [ i ] ) { return chain . handlers [ i ++ ] . call ( chain . backend , req , res , next ) }
406
406
407
- if ( req . protocolOp === Protocol . LDAP_REQ_BIND && res . status === 0 ) { c . ldap . bindDN = req . dn }
407
+ if ( req . protocolOp === Protocol . LDAP_REQ_BIND && res . status === 0 ) { conn . ldap . bindDN = req . dn }
408
408
409
409
return after ( )
410
410
} catch ( e ) {
@@ -415,23 +415,23 @@ function Server (options) {
415
415
} ( ) )
416
416
} )
417
417
418
- c . parser . on ( 'error' , function ( err , message ) {
419
- self . emit ( 'error' , new VError ( err , 'Parser error for %s' , c . ldap . id ) )
418
+ conn . parser . on ( 'error' , function ( err , message ) {
419
+ self . emit ( 'error' , new VError ( err , 'Parser error for %s' , conn . ldap . id ) )
420
420
421
- if ( ! message ) { return c . destroy ( ) }
421
+ if ( ! message ) { return conn . destroy ( ) }
422
422
423
423
const res = getResponse ( message )
424
- if ( ! res ) { return c . destroy ( ) }
424
+ if ( ! res ) { return conn . destroy ( ) }
425
425
426
426
res . status = 0x02 // protocol error
427
427
res . errorMessage = err . toString ( )
428
- return c . end ( res . toBer ( ) )
428
+ return conn . end ( res . toBer ( ) )
429
429
} )
430
430
431
- c . on ( 'data' , function ( data ) {
432
- log . trace ( 'data on %s: %s' , c . ldap . id , util . inspect ( data ) )
431
+ conn . on ( 'data' , function ( data ) {
432
+ log . trace ( 'data on %s: %s' , conn . ldap . id , util . inspect ( data ) )
433
433
434
- c . parser . write ( data )
434
+ conn . parser . write ( data )
435
435
} )
436
436
} // end newConnection
437
437
0 commit comments