Skip to content

Commit

Permalink
TCP TLS Support, closes #26
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Feb 26, 2017
1 parent d9ca500 commit 3a42b39
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ node-gelf - Graylog2 client library for Node.js. Pro - because of code-quality.
## Installation
```
"dependencies": {
"gelf-pro": "~1.0" // see the "releases" section
"gelf-pro": "~1.1" // see the "releases" section
}
```
```npm install gelf-pro``` (**ALL** node.js versions are supported :)
Expand All @@ -32,13 +32,24 @@ log.setConfig({
transform: [], // optional; transformers for a message
broadcast: [], // optional; listeners of a message
levels: {}, // optional; default: see the levels section below
adapterName: 'udp', // optional; currently supported "udp" and "tcp"; default: udp
adapterOptions: {
protocol: 'udp4', // udp only; optional; udp adapter: udp4, udp6; default: udp4
adapterName: 'udp', // optional; currently supported "udp", "tcp" and "tcp-tls"; default: udp
adapterOptions: { // this object is passed to the adapter.connect() method
// common
host: '127.0.0.1', // optional; default: 127.0.0.1
port: 12201, // optional; default: 12201
// ... and so on, for :
// tcp adapter example
family: 4, // tcp only; optional; version of IP stack; default: 4
timeout: 1000, // tcp only; optional; default: 10000 (10 sec)
host: '127.0.0.1', // optional; default: 127.0.0.1
port: 12201 // optional; default: 12201
// udp adapter example
protocol: 'udp4', // udp only; optional; udp adapter: udp4, udp6; default: udp4
// tcp-tls adapter example
key: fs.readFileSync('client-key.pem'), // tcp-tls only; optional; only if using the client certificate authentication
cert: fs.readFileSync('client-cert.pem'), // tcp-tls only; optional; only if using the client certificate authentication
ca: [fs.readFileSync('server-cert.pem')] // tcp-tls only; optional; only for the self-signed certificate
}
});
```
Expand Down Expand Up @@ -119,6 +130,7 @@ log.setConfig({

- UDP (with deflation and chunking)
- TCP
- TCP via TLS(SSL)

### Tests
#### Cli
Expand Down
2 changes: 1 addition & 1 deletion lib/adapter/tcp-tls.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var adapter = Object.create(tcp);

/**
* @param {Object} options
* @returns {net.Socket}
* @returns {tls.TLSSocket}
* @access private
*/
adapter._instance = function (options) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "gelf-pro",
"version": "1.0.0",
"version": "1.1.0",
"main": "./lib/gelf-pro.js",
"types": "./lib/definition.d.ts",
"author": "Kanstantsin Kamkou <kkamkou@gmail.com>",
"description": "The Graylog Extended Log Format for the Node.js",
"keywords": ["graylog", "gelf", "logging", "udp", "tcp"],
"keywords": ["graylog", "gelf", "logging", "udp", "tcp", "tls", "ssl"],
"repository" : {
"type" : "git",
"url" : "https://github.com/kkamkou/node-gelf-pro.git"
Expand All @@ -25,7 +25,7 @@
"istanbul": "~0.4.3",
"should": "~11.1",
"mocha": "~3.2.0",
"mocha-lcov-reporter": "~1.2.0",
"mocha-lcov-reporter": "~1.3.0",
"coveralls": "~2.11",
"sinon": "2.0.0-pre.4"
}
Expand Down
8 changes: 8 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,13 @@ module.exports = {

this.eventEmitter.emit('error', new Error('err1'));
}
},

'Adapter TCP(TLS)': {
'Abstract functionality': function () {
var tls = require('tls'),
adapter = getAdapter('tcp-tls');
adapter._instance().should.be.instanceOf(tls.TLSSocket);
}
}
};

0 comments on commit 3a42b39

Please sign in to comment.