Socket
Socket
Sign inDemoInstall

gelf-pro

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gelf-pro - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

lib/compatibility/buffer.js

5

lib/adapter/tcp-tls.js

@@ -12,5 +12,4 @@ /**

// required stuff
var path = require('path'),
tls = require('tls'),
tcp = require(path.join(__dirname, 'tcp'));
var tls = require('tls'),
tcp = require('./tcp');

@@ -17,0 +16,0 @@ // the class itself

@@ -13,6 +13,8 @@ /**

var _ = require('lodash'),
path = require('path'),
net = require('net'),
abstract = require(path.join(__dirname, 'abstract'));
abstract = require('./abstract');
// compatibility
var buffer = require('../compatibility/buffer');
// the class itself

@@ -44,4 +46,4 @@ var adapter = Object.create(abstract);

// @todo #37:60m add deflation with GELF 2.0
var msg = new Buffer(message.replace(/\x00/g, '')), // eslint-disable-line
packet = new Buffer(Array.prototype.slice.call(msg, 0, msg.length).concat(0x00));
var msg = buffer.from(message.replace(/\x00/g, '')), // eslint-disable-line
packet = buffer.from(Array.prototype.slice.call(msg, 0, msg.length).concat(0x00));
client.end(packet, function () {

@@ -48,0 +50,0 @@ cb(null, packet.length);

48

lib/adapter/udp.js

@@ -12,8 +12,10 @@ /**

var _ = require('lodash'),
path = require('path'),
abstract = require(path.join(__dirname, 'abstract')),
async = require('async'),
crypto = require('crypto'),
dgram = require('dgram');
dgram = require('dgram'),
abstract = require('./abstract');
// compatibility
var buffer = require('../compatibility/buffer');
/**

@@ -63,11 +65,23 @@ * [1] /src/main/java/org/graylog2/inputs/codecs/gelf/GELFMessageChunk.java

* Sends a chunk to the server
* @param {Object} packet
* @param {Function} cb
* @param {Object} message
* @param {Function} callback
* @returns {adapter}
*/
adapter.send = function (message, callback) {
var client = this._createSocket(),
bytesSentTotal = 0,
var bytesSentTotal = 0,
client = this._createSocket(),
isInterrupted = false,
self = this;
var callbackOnce = _.once(callback),
cbResults = function (err, result) {
client.close();
return callbackOnce(err, result);
};
client.on('error', function (err) {
isInterrupted = true;
cbResults(err, bytesSentTotal);
});
async.waterfall(

@@ -97,6 +111,11 @@ [

chunks.forEach(function (chunk, idx) {
var packet = new Buffer(
self.specification.magicBytes.concat(packetId, idx, chunksCount, chunk)
);
for (var idx in chunks) {
if (isInterrupted) {
break;
}
var chunk = chunks[idx],
packet = buffer.from(
self.specification.magicBytes.concat(packetId, idx, chunksCount, chunk)
);
client.send(

@@ -113,9 +132,6 @@ packet, 0, packet.length, self.options.port, self.options.host,

);
});
}
}
],
function (err, result) {
client.close();
return callback(err, result);
}
cbResults
);

@@ -122,0 +138,0 @@ return this;

{
"name": "gelf-pro",
"version": "1.2.2",
"version": "1.3.0",
"main": "./lib/gelf-pro.js",
"types": "./lib/definition.d.ts",
"author": "Kanstantsin Kamkou <kkamkou@gmail.com>",

@@ -29,7 +28,7 @@ "description": "The Graylog Extended Log Format for the Node.js",

"dependencies": {
"async": "2.6.0",
"lodash": "4.17.5"
"async": "2.6.1",
"lodash": "4.17.11"
},
"devDependencies": {
"coveralls": "^3.0.1",
"coveralls": "^3.0.2",
"eslint": "^4.19.1",

@@ -39,5 +38,5 @@ "istanbul": "^0.4.5",

"mocha-lcov-reporter": "^1.3.0",
"should": "^13.2.1",
"should": "^13.2.3",
"sinon": "^3.3.0"
}
}

@@ -12,3 +12,3 @@ node-gelf pro

"dependencies": {
"gelf-pro": "~1.2" // see the "releases" section
"gelf-pro": "~1.3" // see the "releases" section
}

@@ -35,3 +35,3 @@ ```

// simple
log.setConfig({host: 'my.glog-server.net'});
log.setConfig({adapterOptions: {host: 'my.glog-server.net'}});

@@ -170,3 +170,2 @@ // advanced

- [corbinu](https://github.com/corbinu)
- [jucrouzet](https://github.com/jucrouzet)

@@ -173,0 +172,0 @@ ## License

@@ -5,9 +5,13 @@ 'use strict';

var path = require('path'),
sinon = require('sinon'),
var dns = require('dns'),
events = require('events'),
path = require('path'),
should = require('should'),
sinon = require('sinon'),
_ = require('lodash'),
gelfOriginal = require(path.join(PATH_LIB, 'gelf-pro'));
// compatibility
var buffer = require(path.join(PATH_LIB, 'compatibility', 'buffer'));
// helper functions

@@ -291,3 +295,3 @@ var getLongMessage = function (len) {

msgTmp = '',
message = new Buffer(msgOriginal),
message = buffer.from(msgOriginal),
result = adapter.getArrayFromBuffer(message, 100);

@@ -297,3 +301,3 @@

result.forEach(function (chunk) {
msgTmp += (new Buffer(chunk)).toString();
msgTmp += (buffer.from(chunk)).toString();
});

@@ -319,3 +323,5 @@

var adapter = getAdapter('udp'),
msg = getLongMessage(10000);
msg = getLongMessage(10000),
sandbox = sinon.sandbox.create();
adapter.setOptions({

@@ -329,3 +335,3 @@ host: 'aUnresolvableAddressMaybeBecauseOfATypo.com',

sinon.stub(client, 'send').yields(new Error('Random fail'));
sinon.stub(adapter, '_createSocket').returns(client);
sandbox.stub(adapter, '_createSocket').returns(client);

@@ -335,5 +341,27 @@ adapter.send(msg, function (err, bytesSent) {

should.not.exist(bytesSent);
sandbox.restore();
done();
});
},
done();
'DNS exception': function (done) {
var adapter = getAdapter('udp'),
msg = getLongMessage(10000),
sandbox = sinon.sandbox.create();
adapter.setOptions({
host: 'aUnresolvableAddressMaybeBecauseOfATypo.com',
port: 1234,
protocol: 'udp4'
});
sandbox.stub(dns, 'lookup').yields(new Error('DNS lookup exception'));
adapter.send(msg, function (err, bytesSent) {
err.should.be.an.instanceof(Error);
err.message.should.equal('DNS lookup exception');
bytesSent.should.equal(0);
sandbox.restore();
done();
});
},

@@ -393,3 +421,3 @@

this.eventEmitter.end.withArgs(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00])).callsArg(1);
this.eventEmitter.end.withArgs(buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00])).callsArg(1);

@@ -409,3 +437,3 @@ this.adapter.setOptions(options);

'Remove null byte': function (done) {
this.eventEmitter.end.withArgs(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00])).callsArg(1);
this.eventEmitter.end.withArgs(buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00])).callsArg(1);
this.adapter.send("\x00he\x00llo\x00", function (err, result) {

@@ -412,0 +440,0 @@ should.not.exists(err);

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