Fix up client to work in all cases (UDS and TCP)

This commit is contained in:
Mark Cavage 2011-08-26 16:33:49 -07:00
parent ae0aeee761
commit ff7aed39fd
3 changed files with 7 additions and 6 deletions

View File

@ -122,9 +122,9 @@ function Client(options) {
this.numConnections = Math.abs(options.numConnections) || 1; this.numConnections = Math.abs(options.numConnections) || 1;
this.connections = []; this.connections = [];
this.currentConnection = 0; this.currentConnection = 0;
this.connectOptions = options.socketPath ? options.socketPath : { this.connectOptions = {
port: self.url.port, port: self.url ? self.url.port : options.socketPath,
host: self.url.hostname host: self.url ? self.url.hostname : undefined
}; };
this.shutdown = false; this.shutdown = false;
@ -141,7 +141,8 @@ function Client(options) {
if (self.secure) { if (self.secure) {
c = tls.connect(self.connectOptions.port, self.connectOptions.host); c = tls.connect(self.connectOptions.port, self.connectOptions.host);
} else { } else {
c = net.createConnection(self.connectOptions.port, self.connectOptions.host); c = net.createConnection(self.connectOptions.port,
self.connectOptions.host);
} }
assert.ok(c); assert.ok(c);

View File

@ -3,7 +3,7 @@
"name": "ldapjs", "name": "ldapjs",
"homepage": "http://ldapjs.org", "homepage": "http://ldapjs.org",
"description": "LDAP client and server APIs", "description": "LDAP client and server APIs",
"version": "0.1.0", "version": "0.1.1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/mcavage/node-ldapjs.git" "url": "git://github.com/mcavage/node-ldapjs.git"

View File

@ -20,7 +20,7 @@ test('setup', function(t) {
server = ldap.createServer(); server = ldap.createServer();
t.ok(server); t.ok(server);
server.listen(SOCKET, function() { server.listen(SOCKET, function() {
client = client = ldap.createClient({ client = ldap.createClient({
socketPath: SOCKET socketPath: SOCKET
}); });
t.ok(client); t.ok(client);