forked from adsr/irslackd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathirslackd.js
More file actions
executable file
·32 lines (28 loc) · 1.37 KB
/
irslackd.js
File metadata and controls
executable file
·32 lines (28 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node
'use strict';
const os = require('os');
const fs = require('fs');
const irslackd = require('../lib/irslackd.js');
const DEFAULT_HOST = '127.0.0.1';
const DEFAULT_PORT = 6697;
const DEFAULT_TLS_PKEY = os.homedir() + '/.irslackd/pkey.pem';
const DEFAULT_TLS_CERT = os.homedir() + '/.irslackd/cert.pem';
const DEFAULT_RTM_CLIENT_LOG_LEVEL = 'info';
const opt = require('node-getopt').create([
[ 'h', 'help', 'Show this help' ],
[ 'p', 'port=PORT', 'Set listen port (default: ' + DEFAULT_PORT + ')' ],
[ 'a', 'host=ADDR', 'Set listen address (default: ' + DEFAULT_HOST + ')' ],
[ 'k', 'privkey=PATH', 'Set TLS private key path (default: ' + DEFAULT_TLS_PKEY + ')' ],
[ 'c', 'cert=PATH', 'Set TLS cert path (default: ' + DEFAULT_TLS_CERT + ')' ],
[ 'L', 'rtmLogLvl=LEVEL', 'Set RTM Client log level (default: ' + DEFAULT_RTM_CLIENT_LOG_LEVEL + ')' ],
[ 'i', 'insecure', 'Do not use TLS encryption (not recommended)' ],
]).bindHelp().parseSystem();
new irslackd.Irslackd({
host: opt.options.host || DEFAULT_HOST,
port: opt.options.port || DEFAULT_PORT,
tlsOpts: opt.options.insecure ? false : {
key: fs.readFileSync(opt.options.privkey || DEFAULT_TLS_PKEY),
cert: fs.readFileSync(opt.options.cert || DEFAULT_TLS_CERT),
},
rtmClientLogLevel: opt.options.rtmLogLvl || DEFAULT_RTM_CLIENT_LOG_LEVEL,
}).listen();