passwords.json support

This commit is contained in:
Ondřej Žára 2020-09-20 18:43:38 +02:00
parent 6bdfb00b69
commit 4b652590b3
4 changed files with 22 additions and 2 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ node_modules
_youtube/* _youtube/*
!_youtube/.empty !_youtube/.empty
cyp.service cyp.service
passwords.json

View file

@ -57,6 +57,18 @@ docker run --network=host -v "$(pwd)"/_youtube:/cyp/_youtube cyp
docker run --network=host -e PORT=12345 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 ## Technology
- Connected to MPD via WebSockets (using the [ws2mpd](https://github.com/ondras/ws2mpd/) bridge) - Connected to MPD via WebSockets (using the [ws2mpd](https://github.com/ondras/ws2mpd/) bridge)

View file

@ -124,5 +124,12 @@ function requestValidator(request) {
} }
let httpServer = require("http").createServer(onRequest).listen(port); 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); require("ws2mpd").logging(false);

View file

@ -6,7 +6,7 @@
"dependencies": { "dependencies": {
"custom-range": "^1.1.0", "custom-range": "^1.1.0",
"node-static": "^0.7.11", "node-static": "^0.7.11",
"ws2mpd": "^2.2.1" "ws2mpd": "^2.3.0"
}, },
"devDependencies": { "devDependencies": {
"less": "^3.9.0", "less": "^3.9.0",