fixing support for Unix sockets in native binding

Binding natively connections to Unix sockets failed due to DNS lookups applied on pathname to Unix socket's folder.
This commit is contained in:
soletan 2012-08-24 19:06:26 +03:00 committed by Philipp Borgers
parent ff77458ba6
commit d55d145378

View File

@ -75,15 +75,19 @@ var getLibpgConString = function(config, callback) {
params.push("dbname='" + config.database + "'");
}
if(config.host) {
if(config.host != 'localhost' && config.host != '127.0.0.1') {
//do dns lookup
return require('dns').lookup(config.host, function(err, address) {
if(err) return callback(err, null);
params.push("hostaddr="+address)
callback(null, params.join(" "))
})
if (!config.host.indexOf("/")) {
params.push("host=" + config.host);
} else {
if(config.host != 'localhost' && config.host != '127.0.0.1') {
//do dns lookup
return require('dns').lookup(config.host, function(err, address) {
if(err) return callback(err, null);
params.push("hostaddr="+address)
callback(null, params.join(" "))
})
}
params.push("hostaddr=127.0.0.1 ");
}
params.push("hostaddr=127.0.0.1 ");
}
callback(null, params.join(" "));
} else {