diff --git a/.gitignore b/.gitignore index 1c5100d..f19fa10 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules _youtube/* !_youtube/.empty cyp.service +passwords.json diff --git a/README.md b/README.md index df17381..69f23b8 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,18 @@ docker run --network=host -v "$(pwd)"/_youtube:/cyp/_youtube cyp docker run --network=host -e PORT=12345 cyp ``` +## Password-protected MPD + +Create a `passwords.json` file in CYPs home directory. Specify passwords for available MPD servers: + +```json +{ + "localhost:6600": "my-pass-1", + "some.other.server.or.ip:12345": "my-pass-2 +} +``` + +Make sure that hostnames and ports match those specified via the `server` querystring argument (defaults to `localhost:6600`). ## Technology - Connected to MPD via WebSockets (using the [ws2mpd](https://github.com/ondras/ws2mpd/) bridge) diff --git a/index.js b/index.js index af49d39..7fdbf84 100644 --- a/index.js +++ b/index.js @@ -124,5 +124,12 @@ function requestValidator(request) { } let httpServer = require("http").createServer(onRequest).listen(port); -require("ws2mpd").ws2mpd(httpServer, requestValidator); +let passwords = {}; +try { + passwords = require("./passwords.json"); + console.log("loaded passwords.json file"); +} catch (e) { + console.log("no passwords.json found"); +} +require("ws2mpd").ws2mpd(httpServer, requestValidator, passwords); require("ws2mpd").logging(false); diff --git a/package.json b/package.json index f34b783..7fe206a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "custom-range": "^1.1.0", "node-static": "^0.7.11", - "ws2mpd": "^2.2.1" + "ws2mpd": "^2.3.0" }, "devDependencies": { "less": "^3.9.0",