diff --git a/.env.sample b/.env.sample
index 84414cd..c3f32c2 100644
--- a/.env.sample
+++ b/.env.sample
@@ -1,2 +1 @@
AUDIO_FILES_ARRAY=["24Tracks2.ogg", "24TracksShouldBeEnoughForAnybody.ogg", "DesmillahHi-VariousVocalEffects-Guitar-AnyoneCanSee.ogg", "Guitar-VocalEffects-Accents.ogg", "HgInt-Desmillah-Etc-Guitar-Hi.ogg", "HgIntHi-GottaGetOut-VariousVocalEffects-Guitar-NothingMatters.ogg", "HgOpenYourEyesIDontWannaDie-Skaramoush-Drums-NoNoNo.ogg", "HgWhatever.ogg", "HiVocalEffects.ogg", "Mix-5.ogg", "Mix-6.ogg", "Mix-Bass.ogg", "Mix-DrumKit.ogg", "Mix-Harmonizing.ogg", "Mix-Piano.ogg"]
-ADMIN_PASSWORD=3L6rsLFeTTRDPo1hpCHi0rjq9lBSBTie
diff --git a/config.js b/config.js
index 4af874c..fa9cf06 100644
--- a/config.js
+++ b/config.js
@@ -1,4 +1,3 @@
module.exports = {
files: JSON.parse(process.env.AUDIO_FILES_ARRAY),
- password: process.env.ADMIN_PASSWORD,
};
diff --git a/frontend/src/controller/simulator.js b/frontend/src/controller/simulator.js
index 8e28e1f..658fc08 100644
--- a/frontend/src/controller/simulator.js
+++ b/frontend/src/controller/simulator.js
@@ -65,8 +65,8 @@ function getProps (render) {
sources: [],
realPosition: 0,
clientId: 0,
- x: 0,
- y: 0,
+ x: Math.floor(Math.random() * 400),
+ y: Math.floor(Math.random() * 400),
onDrag: (evt, data) => {
updateX(data.x);
updateY(data.y);
diff --git a/frontend/src/view/admin.js b/frontend/src/view/admin.js
index fa58552..ad71e3b 100644
--- a/frontend/src/view/admin.js
+++ b/frontend/src/view/admin.js
@@ -181,10 +181,13 @@ class Admin extends React.Component {
This interface allows you to control the state of connected clients; which tracks are playing as well as the pan and gain for each track.
+
+ The password for this interface is echoed to the command line. Look for the text "ADMIN PASSWORD" surrounded by equals signs.
+
{!this.state.passwordSubmitted
? (
- Enter password: this.changePassword(evt.target.value) } />
+ Enter admin password: this.changePassword(evt.target.value) } />
diff --git a/package.json b/package.json
index 2fee042..5da4c24 100755
--- a/package.json
+++ b/package.json
@@ -7,7 +7,6 @@
"debug": "npm-run-all --parallel debug-frontend debug-server",
"debug-server": "nodemon --inspect-brk=0.0.0.0:9229 ./index.js",
"debug-frontend": "cd ./frontend && yarn install && yarn run start",
-
"start": "npm-run-all --parallel frontend server",
"frontend": "cd ./frontend && yarn install && yarn run build && npx static-html-server -p 3000 -r ./build -f index.html",
"server": "node ./index.js"
@@ -21,6 +20,7 @@
"music-metadata": "^1.1.0",
"node-storage": "^0.0.7",
"npm-run-all": "^4.1.2",
+ "password-generator": "^2.2.0",
"q": "^1.5.1",
"serve": "^6.5.7",
"ws": "^4.0.0"
diff --git a/ws.js b/ws.js
index 97f2576..85f297b 100644
--- a/ws.js
+++ b/ws.js
@@ -6,19 +6,21 @@ const fs = require('fs');
const cors = require('cors');
const execFile = q.denodeify(require('child_process').execFile);
const path = require('path');
+const statSync = require('fs').statSync;
const lowdb = require('lowdb');
const FileSync = require('lowdb/adapters/FileSync');
const readFile = q.denodeify(fs.readFile);
+const passwordGenerator = require('password-generator');
-let PASSWORD = require('./config').password;
+const storagePath = path.join(__dirname, 'storage.json');
-let storage = lowdb(new FileSync(path.join(__dirname, 'storage.json')));
+let storage = lowdb(new FileSync(storagePath));
let _savedSources = storage.get('savedSources').value();
const savedSources = (set) => {
if(set) {
- _savedSources = set
+ _savedSources = set;
storage.set('savedSources', _savedSources).write();
}
@@ -27,6 +29,34 @@ const savedSources = (set) => {
_savedSources = _savedSources || savedSources({});
+let _adminPassword = storage.get('adminPassword').value();
+
+const adminPassword = (set) => {
+ if(set) {
+ _adminPassword = set;
+ storage.set('adminPassword', _adminPassword).write();
+ }
+
+ return _adminPassword;
+};
+
+_adminPassword = _adminPassword || adminPassword(passwordGenerator(32));
+
+const logAdminPassword = () => {
+ let adminLogLine = 'ADMIN PASSWORD: ' + adminPassword();
+ let formatLine = Array(adminLogLine.length).join('=');
+
+ console.log();
+ console.log(formatLine);
+ console.log();
+ console.log(adminLogLine);
+ console.log();
+ console.log(formatLine);
+ console.log();
+}
+
+let adminPasswordRepeated = false;
+
let poller;
let startTime;
let audioLength;
@@ -110,6 +140,12 @@ const initServer = () => {
});
wsServer.on('connection', (client, req) => {
+ // Only repeat the password once.
+ if(!adminPasswordRepeated) {
+ logAdminPassword();
+ adminPasswordRepeated = true;
+ }
+
client.admin = false;
client.sources = [];
client.id = Math.floor(Math.random() * 1000000);
@@ -148,11 +184,15 @@ const initServer = () => {
}
else if(data.type == 'hello_admin') {
// Gecting the password wrong shouldn't cause a disconnect.
- if(data.password == PASSWORD) {
+ if(data.password == adminPassword()) {
wsSend(client, data);
client.hello = client.admin = true;
}
+ else {
+ console.log();
+ console.log('An invalid password was entered!');
+ }
}
else if(!client.hello) {
client.close();
@@ -270,7 +310,6 @@ module.exports = {
savedSources(_savedSources);
}
-
if(!wsServer) {
initServer();
}
diff --git a/yarn.lock b/yarn.lock
index b435a95..597d37e 100755
--- a/yarn.lock
+++ b/yarn.lock
@@ -280,7 +280,7 @@ camelcase@^1.0.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"
-camelcase@^4.0.0:
+camelcase@^4.0.0, camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
@@ -1733,6 +1733,12 @@ parseurl@~1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3"
+password-generator@^2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/password-generator/-/password-generator-2.2.0.tgz#fc75cff795110923e054a5a71623433240bf5e49"
+ dependencies:
+ yargs-parser "^8.0.0"
+
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
@@ -2544,6 +2550,12 @@ yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
+yargs-parser@^8.0.0:
+ version "8.1.0"
+ resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-8.1.0.tgz#f1376a33b6629a5d063782944da732631e966950"
+ dependencies:
+ camelcase "^4.1.0"
+
yargs@~3.10.0:
version "3.10.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1"