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/.empty
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
```
## 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)

View File

@ -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);

View File

@ -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",