Добавлена возможность доступа по паролю
This commit is contained in:
@@ -13,6 +13,9 @@ class WebSocketController {
|
||||
constructor(wss, config) {
|
||||
this.config = config;
|
||||
this.isDevelopment = (config.branch == 'development');
|
||||
this.accessToken = '';
|
||||
if (config.accessPassword)
|
||||
this.accessToken = utils.getBufHash(config.accessPassword, 'sha256', 'hex');
|
||||
|
||||
this.workerState = new WorkerState();
|
||||
this.webWorker = new WebWorker(config);
|
||||
@@ -59,6 +62,11 @@ class WebSocketController {
|
||||
//pong for WebSocketConnection
|
||||
this.send({_rok: 1}, req, ws);
|
||||
|
||||
if (this.accessToken && req.accessToken !== this.accessToken) {
|
||||
await utils.sleep(1000);
|
||||
throw new Error('need_access_token');
|
||||
}
|
||||
|
||||
switch (req.action) {
|
||||
case 'test':
|
||||
await this.test(req, ws); break;
|
||||
|
||||
Reference in New Issue
Block a user