Treat cookie as password box
Add blacklist functionality
This commit is contained in:
		
							parent
							
								
									1fdfad1946
								
							
						
					
					
						commit
						b7f279f03c
					
				
							
								
								
									
										19
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								index.js
									
									
									
									
									
								
							| 
						 | 
					@ -2,6 +2,7 @@ require("dotenv").config()
 | 
				
			||||||
const express = require("express")
 | 
					const express = require("express")
 | 
				
			||||||
const codes = require("./codes.json");
 | 
					const codes = require("./codes.json");
 | 
				
			||||||
const app = express()
 | 
					const app = express()
 | 
				
			||||||
 | 
					const fs = require("fs");
 | 
				
			||||||
const port = process.env.SERVER_PORT || 3000;
 | 
					const port = process.env.SERVER_PORT || 3000;
 | 
				
			||||||
app.use(express.json());
 | 
					app.use(express.json());
 | 
				
			||||||
app.set("trust proxy", 1);
 | 
					app.set("trust proxy", 1);
 | 
				
			||||||
| 
						 | 
					@ -11,6 +12,23 @@ app.use((req, res, next) => {
 | 
				
			||||||
	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 = {};
 | 
					var rateLimits = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -72,7 +90,6 @@ app.post("/", async (req, res) => {
 | 
				
			||||||
				assetId,
 | 
									assetId,
 | 
				
			||||||
				requestId: assetId,
 | 
									requestId: assetId,
 | 
				
			||||||
				status: "failure",
 | 
									status: "failure",
 | 
				
			||||||
				url: "",
 | 
					 | 
				
			||||||
				additional: "Missing assetId."
 | 
									additional: "Missing assetId."
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@
 | 
				
			||||||
			<br>
 | 
								<br>
 | 
				
			||||||
			<label for="cookie">Cookie:</label>
 | 
								<label for="cookie">Cookie:</label>
 | 
				
			||||||
			<br>
 | 
								<br>
 | 
				
			||||||
			<input type="text" id="cookie" name="cookie">
 | 
								<input type="password" id="cookie" name="cookie">
 | 
				
			||||||
			<br>
 | 
								<br>
 | 
				
			||||||
			<button type="submit">Submit</button>
 | 
								<button type="submit">Submit</button>
 | 
				
			||||||
		</form>
 | 
							</form>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue