Skip to content

Commit bd02375

Browse files
committed
Merge pull request brianc#249 from booo/unix_sockets
fixing support for Unix sockets in native binding (rebased)
2 parents ff77458 + d55d145 commit bd02375

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/utils.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,19 @@ var getLibpgConString = function(config, callback) {
7575
params.push("dbname='" + config.database + "'");
7676
}
7777
if(config.host) {
78-
if(config.host != 'localhost' && config.host != '127.0.0.1') {
79-
//do dns lookup
80-
return require('dns').lookup(config.host, function(err, address) {
81-
if(err) return callback(err, null);
82-
params.push("hostaddr="+address)
83-
callback(null, params.join(" "))
84-
})
78+
if (!config.host.indexOf("/")) {
79+
params.push("host=" + config.host);
80+
} else {
81+
if(config.host != 'localhost' && config.host != '127.0.0.1') {
82+
//do dns lookup
83+
return require('dns').lookup(config.host, function(err, address) {
84+
if(err) return callback(err, null);
85+
params.push("hostaddr="+address)
86+
callback(null, params.join(" "))
87+
})
88+
}
89+
params.push("hostaddr=127.0.0.1 ");
8590
}
86-
params.push("hostaddr=127.0.0.1 ");
8791
}
8892
callback(null, params.join(" "));
8993
} else {

0 commit comments

Comments
 (0)