diff --git a/index.js b/index.js index 9785e2f..25b525f 100644 --- a/index.js +++ b/index.js @@ -2,6 +2,7 @@ require("dotenv").config() const express = require("express") const codes = require("./codes.json"); const app = express() +const fs = require("fs"); const port = process.env.SERVER_PORT || 3000; app.use(express.json()); app.set("trust proxy", 1); @@ -11,6 +12,23 @@ app.use((req, res, next) => { next(); }) +// if blacklist doesnt exist, make the file +if (!fs.existsSync("./blacklist.json")) { + fs.writeFileSync("./blacklist.json", "[]"); +} + +app.use((req, res, next) => { // Blacklist handler + let blacklist = require("./blacklist.json"); // Get it every time to update it + if (blacklist.includes(req.ip)) { + return res.status(403).json({ + code: 403, + message: codes[403].message, + additional: codes[403].description + }); + } + next(); +}) + var rateLimits = {}; @@ -72,7 +90,6 @@ app.post("/", async (req, res) => { assetId, requestId: assetId, status: "failure", - url: "", additional: "Missing assetId." }; } diff --git a/static/index.html b/static/index.html index 9294763..3d82f7b 100644 --- a/static/index.html +++ b/static/index.html @@ -58,7 +58,7 @@

- +