mirror of
https://github.com/misskey-dev/SyslogPro.git
synced 2025-04-29 02:37:18 +09:00
Merge pull request #7 from zeit/reject-authorized
Add rejectUnauthorized option
This commit is contained in:
commit
58365cc98c
7
index.ts
7
index.ts
@ -94,6 +94,7 @@ type SyslogOptions = {
|
|||||||
leef?: LEEF | LEEFOptions;
|
leef?: LEEF | LEEFOptions;
|
||||||
port?: number;
|
port?: number;
|
||||||
protocol?: string;
|
protocol?: string;
|
||||||
|
rejectUnauthorized?: boolean;
|
||||||
rfc3164?: RFC3164 | RFC3164Options;
|
rfc3164?: RFC3164 | RFC3164Options;
|
||||||
rfc5424?: RFC5424 | RFC5424Options;
|
rfc5424?: RFC5424 | RFC5424Options;
|
||||||
target?: string;
|
target?: string;
|
||||||
@ -120,6 +121,7 @@ export class Syslog {
|
|||||||
leef: any;
|
leef: any;
|
||||||
port: number;
|
port: number;
|
||||||
protocol: string;
|
protocol: string;
|
||||||
|
rejectUnauthorized: boolean;
|
||||||
rfc3164: any;
|
rfc3164: any;
|
||||||
rfc5424: any;
|
rfc5424: any;
|
||||||
target: string;
|
target: string;
|
||||||
@ -155,6 +157,8 @@ export class Syslog {
|
|||||||
* @param {string} [options.tlsClientKey] - Client TLS key file
|
* @param {string} [options.tlsClientKey] - Client TLS key file
|
||||||
* location that this client should use, this option if set will take
|
* location that this client should use, this option if set will take
|
||||||
* presidents over any certificates set in a formatting object
|
* presidents over any certificates set in a formatting object
|
||||||
|
* @param {string} [options.rejectUnauthorized] - If not false, the server
|
||||||
|
* certificate is verified against the list of supplied CAs.
|
||||||
* >>>Syslog Format Settings
|
* >>>Syslog Format Settings
|
||||||
* @param {string} [options.format='none'] - Valid syslog format options for
|
* @param {string} [options.format='none'] - Valid syslog format options for
|
||||||
* this module are 'none', 'rfc3164', 'rfc5424', 'leef', 'cef'
|
* this module are 'none', 'rfc3164', 'rfc5424', 'leef', 'cef'
|
||||||
@ -197,6 +201,7 @@ export class Syslog {
|
|||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
this.tlsClientKey = options.tlsClientKey;
|
this.tlsClientKey = options.tlsClientKey;
|
||||||
}
|
}
|
||||||
|
this.rejectUnauthorized = options.rejectUnauthorized !== false;
|
||||||
// Syslog Format
|
// Syslog Format
|
||||||
if (typeof options.format === 'string') {
|
if (typeof options.format === 'string') {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
@ -385,8 +390,8 @@ export class Syslog {
|
|||||||
tlsOptionsCerts.push(cert);
|
tlsOptionsCerts.push(cert);
|
||||||
}
|
}
|
||||||
tlsOptions.ca = tlsOptionsCerts;
|
tlsOptions.ca = tlsOptionsCerts;
|
||||||
tlsOptions.rejectUnauthorized = true;
|
|
||||||
}
|
}
|
||||||
|
tlsOptions.rejectUnauthorized = this.rejectUnauthorized;
|
||||||
const client = tls.connect(tlsOptions, () => {
|
const client = tls.connect(tlsOptions, () => {
|
||||||
// Turn msg in to a UTF8 buffer
|
// Turn msg in to a UTF8 buffer
|
||||||
let msgBuffer = Buffer.from(msg, 'utf8');
|
let msgBuffer = Buffer.from(msg, 'utf8');
|
||||||
|
@ -852,6 +852,15 @@ describe('Base Syslog Class tests', () => {
|
|||||||
const result = await syslog.send('test');
|
const result = await syslog.send('test');
|
||||||
expect(result).toBe('test');
|
expect(result).toBe('test');
|
||||||
});
|
});
|
||||||
|
test('Syslog Send TLS without rejectUnauthorized', async () => {
|
||||||
|
let syslog = new SyslogPro.Syslog({
|
||||||
|
protocol: 'tls',
|
||||||
|
port: global.tlsBasicServerPort,
|
||||||
|
rejectUnauthorized: false
|
||||||
|
});
|
||||||
|
const result = await syslog.send('test');
|
||||||
|
expect(result).toBe('test');
|
||||||
|
});
|
||||||
test('Syslog Send TCP with DNS Error', async () => {
|
test('Syslog Send TCP with DNS Error', async () => {
|
||||||
let syslog = new SyslogPro.Syslog({
|
let syslog = new SyslogPro.Syslog({
|
||||||
target: 'noteareal.dns',
|
target: 'noteareal.dns',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user