mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
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:
parent
ff77458ba6
commit
d55d145378
20
lib/utils.js
20
lib/utils.js
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user