New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@axah/eureka

Package Overview
Dependencies
Maintainers
5
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axah/eureka - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

3

lib/config.js

@@ -10,5 +10,2 @@ "use strict";

preferredNetworks: process.env.EUREKA_PREFERRED_NETWORKS ? process.env.EUREKA_PREFERRED_NETWORKS.split(';') : ['127.0.0'],
instance: {
app: 'partner-service'
},
host: process.env.EUREKA_HOST || '127.0.0.1',

@@ -15,0 +12,0 @@ port: process.env.EUREKA_PORT || '8761'

110

lib/index.js

@@ -6,3 +6,2 @@ "use strict";

});
exports.getInstancesByVipAddress = getInstancesByVipAddress;
exports.register = register;

@@ -25,61 +24,57 @@

const log = (0, _log.default)('eureka');
let doNotUseEurekaClient;
function getClient() {
if (!doNotUseEurekaClient) {
const ifaces = _os.default.networkInterfaces();
function createClient(app) {
const ifaces = _os.default.networkInterfaces();
log.info('Eureka preferred networks are %j', _config.default.preferredNetworks);
let ipAddr = '';
Object.keys(ifaces).find(ifaceName => {
const iface = ifaces[ifaceName];
return iface.find(addr => {
if (_config.default.preferredNetworks.find(preferredNetwork => addr.address.startsWith(`${preferredNetwork}.`))) {
ipAddr = addr.address;
log.info('Using address %s of interface %s for eureka registration', addr.address, ifaceName);
return true;
}
log.info('Eureka preferred networks are %j', _config.default.preferredNetworks);
let ipAddr = '';
Object.keys(ifaces).find(ifaceName => {
const iface = ifaces[ifaceName];
return iface.find(addr => {
if (_config.default.preferredNetworks.find(preferredNetwork => addr.address.startsWith(`${preferredNetwork}.`))) {
ipAddr = addr.address;
log.info('Using address %s of interface %s for eureka registration', addr.address, ifaceName);
return true;
}
return false;
});
return false;
});
});
if (!ipAddr) {
log.error('Could not find preferred ip address for eureka. preferredNetworks %j, interfaces: %j', _config.default.preferredNetworks, ifaces);
process.exit(-1);
}
if (!ipAddr) {
log.error('Could not find preferred ip address for eureka. preferredNetworks %j, interfaces: %j', _config.default.preferredNetworks, ifaces);
process.exit(-1);
}
doNotUseEurekaClient = new _eurekaJsClient.default({
// application instance information
instance: {
instanceId: `${ipAddr}:${_config.default.instance.app}:${_config.default.port}`,
app: _config.default.instance.app,
hostName: ipAddr,
ipAddr,
port: {
$: parseInt(_config.default.port, 10),
'@enabled': true
},
vipAddress: _config.default.instance.app,
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
name: 'MyOwn'
}
return new _eurekaJsClient.default({
// application instance information
instance: {
instanceId: `${ipAddr}:${app}:${_config.default.port}`,
app,
hostName: ipAddr,
ipAddr,
port: {
$: parseInt(_config.default.port, 10),
'@enabled': true
},
eureka: {
// eureka server host / port
host: _config.default.host,
port: _config.default.port,
preferIpAddress: true,
servicePath: '/eureka/apps/',
fetchRegistry: false // we do not use registry to quiry infos, using docker LB directly
vipAddress: app,
dataCenterInfo: {
'@class': 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
name: 'MyOwn'
}
});
}
},
eureka: {
// eureka server host / port
host: _config.default.host,
port: _config.default.port,
preferIpAddress: true,
servicePath: '/eureka/apps/',
fetchRegistry: false // we do not use registry to quiry infos, using docker LB directly
return doNotUseEurekaClient;
}
});
}
function unregister() {
function unregister(client) {
// eslint-disable-line flowtype/no-weak-types
return Promise.race([new Promise((resolve, reject) => {

@@ -93,3 +88,3 @@ // after some seconds we force quit

log.info('unregistering eureka instance');
getClient().stop(() => {
client.stop(() => {
log.info('Eureka unregister done');

@@ -100,11 +95,9 @@ resolve();

})]);
}
} // eslint-disable-next-line import/prefer-default-export
function getInstancesByVipAddress(appId) {
return getClient().getInstancesByVipAddress(appId);
}
function register() {
function register(app) {
if (_config.default && _config.default.register === true) {
getClient().start((err, ...other) => {
const client = createClient(app);
client.start((err, ...other) => {
if (err) {

@@ -117,4 +110,7 @@ log.error(err, 'Failed to register eureka instance %j', other);

});
cleanup.addListener(unregister);
cleanup.addListener(unregister.bind(null, client));
return client;
}
return null;
}
{
"name": "@axah/eureka",
"version": "1.0.1",
"version": "1.0.2",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "license": "UNLICENSED",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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