implement whitelist

This commit is contained in:
Moritz 2019-09-19 20:23:48 +02:00
parent b9ebac85c1
commit 1d5aa96e72
2 changed files with 18 additions and 8 deletions

View file

@ -5,16 +5,21 @@ var docker = require('../bin/dockerode');
router.get('/:id', (req, res, next) => {
getContainer(id).then(data => {
res.send(data);
});
if (req.params.id.startsWith("mc") == true) {
startContainer(req.params.id).then(data => {
res.send(data);
});
}
else {
res.send("not whitelisted");
}
});
function getContainer(containername) {
function startContainer(containername) {
return new Promise((resolve, reject) => {
const container = docker.getContainer(containername);
container.inspect((err, data) => {
container.start((err, data) => {
resolve({ err, data });
});
})

View file

@ -5,9 +5,14 @@ var docker = require('../bin/dockerode');
router.get('/:id', (req, res, next) => {
getContainer(id).then(data => {
res.send(data);
});
if (req.params.id.startsWith("mc") == true) {
getContainer(req.params.id).then(data => {
res.send(data);
});
}
else {
res.send("not whitelisted");
}
});