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

agentx

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

agentx - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

51

lib/agent.js

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

var Agent = function (config) {
this.logger = config.logger || console;
// 是否以 lib 模式被使用,如果是,则不主动调用 process.exit
this.libMode = config.libMode === true;
this.conn = null;

@@ -140,10 +143,19 @@ this.server = 'ws://' + config.server + '/';

var type = message.type;
var params = message.params;
var params = message.params || {};
var signature = message.signature;
var err;
// 如果server返回错误,不带签名,说明agent发注册消息的时候签名验证失败
if (!signature) {
if (type === 'error') {
console.log(params.error, 'process exit~~~~~');
process.send({type: 'suicide'});
process.exit(-3);
if (this.libMode) {
this.logger.info('[agentx] signature error: %s', params.error);
err = new Error(String(params.error || 'signature unknow error'));
err.name = 'AlinodeAgentxSignatureError';
this.logger.error(err);
} else {
this.logger.info('[agentx] signature error: %s, process exit~~~~~', params.error);
process.send({type: 'suicide'});
process.exit(-3);
}
return;
}

@@ -156,3 +168,3 @@ }

if (signature !== this.signature(message)) {
debug('签名错误,忽略。message id: %s', message.id);
debug('签名错误,忽略。message id: %s, %j', message.id, message);
return;

@@ -170,5 +182,12 @@ }

this.stopRegister();
console.log('register failed, process exit.');
process.send({type: 'suicide'});
process.exit(-2);
if (this.libMode) {
this.logger.info('[agentx] register failed: %s, stop now.', params.result);
err = new Error('agentx register failed: ' + params.result);
err.name = 'AlinodeAgentxRegisterError';
this.logger.error(err);
} else {
this.logger.info('[agentx] register failed: %s, process exit.', params.result);
process.send({type: 'suicide'});
process.exit(-2);
}
} else if (params.result === 'HEARTBEAT_ACK') {

@@ -184,5 +203,12 @@ this.heartbeatMissCount = 0;

case 'error':
console.log(params.error, 'process exit~');
process.send({type: 'suicide'});
process.exit(-1);
if (this.libMode) {
this.logger.info('[agentx] get error message: %s', params.error);
err = new Error(String(params.error || 'unknow error message'));
err.name = 'AlinodeAgentxMessageError';
this.logger.error(err);
} else {
this.logger.info('[agentx] %s, process exit~', params.error);
process.send({type: 'suicide'});
process.exit(-1);
}
break;

@@ -300,3 +326,4 @@

if (err) {
console.log(utils.formatError(err));
this.logger.info(utils.formatError(err));
this.logger.error(err);
return;

@@ -303,0 +330,0 @@ }

{
"name": "agentx",
"version": "1.5.1",
"version": "1.5.2",
"description": "agentx is powered by alinode",
"scripts": {
"test": "make test"
"test": "make test",
"test-cov": "make test-cov"
},

@@ -15,3 +16,3 @@ "bin": {

"dependencies": {
"ws": "^1.0.1",
"ws": "^1.1.1",
"nounou": "1.0.1",

@@ -18,0 +19,0 @@ "debug": "*",

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