Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vault-high-availability

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vault-high-availability - npm Package Compare versions

Comparing version 1.0.31 to 1.0.32

2

package.json
{
"name": "vault-high-availability",
"version": "1.0.31",
"version": "1.0.32",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,2 +15,3 @@ 'use strict';

var findActiveIp = function () {

@@ -39,6 +40,8 @@ log.info("will look for active ip only if isResolving is false");

var newIp = null;
async.each(addresses, function (address, callbackAsync) {
addresses.forEach(function (address) {
return new Promise(function (resolvePromise, reject) {
var urlWithIpObject = extend({}, urlObject);
urlWithIpObject.host = undefined;
urlWithIpObject.hostname = address.address;
request.get((urlLib.format(urlWithIpObject)) + "v1/sys/leader", {

@@ -48,9 +51,9 @@ timeout: 500,

}, function (error, response, body) {
if(error) {
log.error("An error happened while trying to get the leader",error);
callbackAsync(error);
if (error) {
log.error("An error happened while trying to get the leader", error);
return reject(error);
}
else if(response.statusCode !== 200){
else if (response.statusCode !== 200) {
log.error("Got not good response when try to get the leader");
callbackAsync(new error("Got not good response while trying to get the leader: " + response.statusCode + ": " + JSON.stringify(response.body) ));
return reject("Got not good response while trying to get the leader: " + response.statusCode + ": " + JSON.stringify(response.body));
}

@@ -72,25 +75,82 @@ else {

}
callbackAsync();
return resolvePromise();
}
});
},
function (err) {
if(err){
log.error("An error happened while trying to get vault leader",err);
process.exit(0);
}else{
if (newIp) {
that.ip = newIp;
that.isResolving = false;
log.info("active node set", id, new Date(), newIp);
} else {
log.info("No active node was found.");
log.error("No active node was found.");
tryAgainOrAbort();
}
}
})
})
});
Promise.all(addresses).then(function (response) {
log.debug("Succeed to call all vault nodes");
if (newIp) {
that.ip = newIp;
that.isResolving = false;
log.info("active node set", id, new Date(), newIp);
} else {
log.info("No active node was found.");
log.error("No active node was found.");
tryAgainOrAbort();
}
);
}).catch(function () {
log.error("An error happened while trying to get vault leader", err);
process.exit(0);
})
};
// var findTheLeader = function (addresses) {
// var newIp = null;
// async.each(addresses, function (address, callbackAsync) {
// var urlWithIpObject = extend({}, urlObject);
// urlWithIpObject.host = undefined;
// urlWithIpObject.hostname = address.address;
// request.get((urlLib.format(urlWithIpObject)) + "v1/sys/leader", {
// timeout: 500,
// gzip: true
// }, function (error, response, body) {
// if(error) {
// log.error("An error happened while trying to get the leader",error);
// callbackAsync(error);
// }
// else if(response.statusCode !== 200){
// log.error("Got not good response when try to get the leader");
// callbackAsync(new error("Got not good response while trying to get the leader: " + response.statusCode + ": " + JSON.stringify(response.body) ));
// }
// else {
// log.debug("leader response for ip: ", address, "body: ", body, "error: ", error);
// var jsonBody = null;
// try {
// jsonBody = JSON.parse(body);
// } catch (e) {
// log.debug("response wasn't in json format", body)
// }
//
// if (response && response.statusCode === 200 && jsonBody && jsonBody.is_self === true) {
// log.info("leader found: ", address);
// newIp = address.address;
// } else {
// log.debug("not the leader: ", address);
// }
// callbackAsync();
// }
// });
// },
// function (err) {
// if(err){
// log.error("An error happened while trying to get vault leader",err);
// process.exit(0);
// }else{
// if (newIp) {
// that.ip = newIp;
// that.isResolving = false;
// log.info("active node set", id, new Date(), newIp);
// } else {
// log.info("No active node was found.");
// log.error("No active node was found.");
// tryAgainOrAbort();
// }
// }
// }
// );
// };
var resolve = function () {

@@ -97,0 +157,0 @@ dns.lookup(urlObject.hostname, {all: true, family: 4}, function (err, addresses) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc