ip-whitelist

This commit is contained in:
Flummi 2016-08-18 10:17:23 +02:00
parent 5ab7713f97
commit 06c9ab5411

View File

@ -165,7 +165,7 @@ var loadUser = (cb) => {
}).on('error', () => { }).on('error', () => {
cb(false); cb(false);
});; });;
} };
var dl = (url, dest, cb) => { var dl = (url, dest, cb) => {
var request = (url.match(/^https/)?https:http).get(url, (response) => { // type:1=post,type:2=stfu var request = (url.match(/^https/)?https:http).get(url, (response) => { // type:1=post,type:2=stfu
@ -231,6 +231,7 @@ var getCheckSum = (file, cbcs) => {
// Webserver // Webserver
http.createServer((req, res) => { http.createServer((req, res) => {
if(cfg.wlip.hasOwnProperty(req.connection.remoteAddress)) {
var filePath = '.' + req.url; var filePath = '.' + req.url;
var url = req.url.split("/")[1]; var url = req.url.split("/")[1];
if(filePath == './') if(filePath == './')
@ -404,6 +405,11 @@ http.createServer((req, res) => {
res.writeHead(404); res.writeHead(404);
res.end('404 - f0ck you', 'utf-8'); res.end('404 - f0ck you', 'utf-8');
} }
}
else {
res.writeHead(403);
res.end('403 - forbidden');
}
}).listen(cfg.webserver.port); }).listen(cfg.webserver.port);
var getTpls = () => { var getTpls = () => {
@ -415,12 +421,6 @@ var getTpls = () => {
"scripts": fs.readFileSync("./s/scripts.tpl.html", "utf-8") "scripts": fs.readFileSync("./s/scripts.tpl.html", "utf-8")
}; };
}; };
getTpls();
// Thumbnailbackgroundworker
setInterval(()=>{generateThumbs();}, 60000); // 1 minute
setTimeout(()=>{generateThumbs();}, 5000); // 5 seconds (start)
var generateThumbs = () => { var generateThumbs = () => {
var outdir = './t/'; var outdir = './t/';
@ -441,4 +441,7 @@ var generateThumbs = () => {
}); });
}; };
loadUser((cb)=>{}); loadUser((cb)=>{
console.log((cb)?"Admins wurden geladen":"Admins konnten nicht geladen werden");
});
getTpls();