+ Adding commandline parameter parser for specifying wss-hmac and api-hmac
The respective flags are -w|--wss-hmac and -H|--hmac Default values are wss-hmac.secre hmac.secrett respectively
This commit is contained in:
parent
61a3f1d4f5
commit
2a1881db20
@ -4,8 +4,13 @@ const IncomingMessage = require('http').IncomingMessage
|
|||||||
const url = require('url')
|
const url = require('url')
|
||||||
const query = require('querystring')
|
const query = require('querystring')
|
||||||
|
|
||||||
const SERVER_HMAC = fs.readFileSync('wss-hmac.secret')
|
const SERVER_HMAC = (process.env['WSS_HMAC'])
|
||||||
const USER_HMAC = fs.readFileSync('hmac.secret')
|
? fs.readFileSync(process.env['WSS_HMAC'])
|
||||||
|
: fs.readFileSync('./wss-hmac.secret')
|
||||||
|
|
||||||
|
const USER_HMAC = (process.env['HMAC'])
|
||||||
|
? fs.readFileSync(process.env['HMAC'])
|
||||||
|
: fs.readFileSync('./hmac.secret')
|
||||||
|
|
||||||
|
|
||||||
exports.verify = function(token) {
|
exports.verify = function(token) {
|
||||||
|
19
rtc-server/cmdline.js
Normal file
19
rtc-server/cmdline.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const argparse = require('argparse')
|
||||||
|
|
||||||
|
// Command line parsing first
|
||||||
|
const parser = new argparse.ArgumentParser({
|
||||||
|
description: 'RTC Server Component for freechat'
|
||||||
|
})
|
||||||
|
parser.add_argument('-w', '--wss-hmac', { help: 'Set the path for the websocket hmac'})
|
||||||
|
parser.add_argument('-H', '--hmac', { help: 'Set the path for the API-server hmac'})
|
||||||
|
const args = parser.parse_args()
|
||||||
|
|
||||||
|
// hmac paths are set/overridden through the commandline parameters
|
||||||
|
console.log(args)
|
||||||
|
if(args['wss_hmac'] != undefined) {
|
||||||
|
process.env['WSS_HMAC'] = args['wss_hmac']
|
||||||
|
}
|
||||||
|
if(args['hmac'] != undefined) {
|
||||||
|
process.env['HMAC'] = args['hmac']
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
|||||||
const ws = require('ws')
|
const ws = require('ws')
|
||||||
|
const _ = require('./cmdline.js') // initializing the command line params first
|
||||||
const auth = require('./auth.js')
|
const auth = require('./auth.js')
|
||||||
|
|
||||||
const server = new ws.Server({
|
const server = new ws.Server({
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node main.js",
|
"start": "node main.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"autotest": "node main.js -H ../hmac.secret -w ../wss-hmac.secret"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
Loading…
Reference in New Issue
Block a user