29 lines
840 B
JavaScript
29 lines
840 B
JavaScript
/*
|
|
This is not a server file, but a command to clear broken files on the database.
|
|
|
|
Usage (in the root of the folder): node ./scripts/unblock-ip.js <ip>
|
|
*/
|
|
|
|
const ip = process.argv.slice(2).join(" ");
|
|
|
|
const config = require("../config.json")
|
|
const {MongoClient} = require("mongodb");
|
|
const client = new MongoClient(config["db-url"], {useUnifiedTopology: true});
|
|
|
|
|
|
(async function() {
|
|
console.log("Connecting to DB...");
|
|
await client.connect();
|
|
console.log("- Connected to DB.");
|
|
let db = await client.db("mediahost");
|
|
let files = await db.collection("uploads");
|
|
let blocks = db.collection("blockedIPs");
|
|
let block = await blocks.findOneAndDelete({ip: ip});
|
|
if (block.ok == 1) {
|
|
console.log("Successfully removed.");
|
|
process.exit();
|
|
} else {
|
|
console.log("Could not remove.")
|
|
process.exit(1);
|
|
}
|
|
})(); |