mirror of
https://github.com/misskey-dev/SyslogPro.git
synced 2025-04-29 02:37:18 +09:00
add rejectUnauthorized option
This commit is contained in:
parent
f8a7322d31
commit
8c53acf3f4
7
index.ts
7
index.ts
@ -94,6 +94,7 @@ type SyslogOptions = {
|
||||
leef?: LEEF | LEEFOptions;
|
||||
port?: number;
|
||||
protocol?: string;
|
||||
rejectUnauthorized?: boolean;
|
||||
rfc3164?: RFC3164 | RFC3164Options;
|
||||
rfc5424?: RFC5424 | RFC5424Options;
|
||||
target?: string;
|
||||
@ -120,6 +121,7 @@ export class Syslog {
|
||||
leef: any;
|
||||
port: number;
|
||||
protocol: string;
|
||||
rejectUnauthorized: boolean;
|
||||
rfc3164: any;
|
||||
rfc5424: any;
|
||||
target: string;
|
||||
@ -155,6 +157,8 @@ export class Syslog {
|
||||
* @param {string} [options.tlsClientKey] - Client TLS key file
|
||||
* location that this client should use, this option if set will take
|
||||
* 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
|
||||
* @param {string} [options.format='none'] - Valid syslog format options for
|
||||
* this module are 'none', 'rfc3164', 'rfc5424', 'leef', 'cef'
|
||||
@ -197,6 +201,7 @@ export class Syslog {
|
||||
/** @type {string} */
|
||||
this.tlsClientKey = options.tlsClientKey;
|
||||
}
|
||||
this.rejectUnauthorized = options.rejectUnauthorized !== false;
|
||||
// Syslog Format
|
||||
if (typeof options.format === 'string') {
|
||||
/** @type {string} */
|
||||
@ -385,8 +390,8 @@ export class Syslog {
|
||||
tlsOptionsCerts.push(cert);
|
||||
}
|
||||
tlsOptions.ca = tlsOptionsCerts;
|
||||
tlsOptions.rejectUnauthorized = true;
|
||||
}
|
||||
tlsOptions.rejectUnauthorized = this.rejectUnauthorized;
|
||||
const client = tls.connect(tlsOptions, () => {
|
||||
// Turn msg in to a UTF8 buffer
|
||||
let msgBuffer = Buffer.from(msg, 'utf8');
|
||||
|
@ -852,6 +852,15 @@ describe('Base Syslog Class tests', () => {
|
||||
const result = await syslog.send('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 () => {
|
||||
let syslog = new SyslogPro.Syslog({
|
||||
target: 'noteareal.dns',
|
||||
|
Loading…
x
Reference in New Issue
Block a user