Initial commit

This commit is contained in:
2023-11-03 21:12:55 +01:00
parent a4afe6cc85
commit 57362e7520
39 changed files with 3505 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
const crypto = require('crypto');
module.exports = {
name:"banHandler",
check: async function(req){
return new Promise(async (resolve,reject) => {
let hash = req.headers["cf-connecting-ip"] == undefined ? crypto.createHash('md5').update("localhost").digest('hex') : crypto.createHash('md5').update(req.headers["cf-connecting-ip"]).digest('hex')
let ban = await commands.get("query").function("SELECT idBan from tbl_bans WHERE dtIpHash = ?",[hash])
if(ban.length == 0){
resolve()
return
}else{
reject()
return
}
})
},
ban: async function(req){
if(req.headers["cf-connecting-ip"] != undefined){
if(config.banhandler.whitelisted.includes(req.headers["cf-connecting-ip"]))
return
}
let hash = req.headers["cf-connecting-ip"] == undefined ? crypto.createHash('md5').update("localhost").digest('hex') : crypto.createHash('md5').update(req.headers["cf-connecting-ip"]).digest('hex')
await commands.get("query").function("INSERT INTO tbl_bans (dtIpHash,dtTimestamp) VALUES (?,?)",[hash, new Date().getTime()])
ignorelist[hash] = hash
},
unban: async function(hash){
await commands.get("query").function("DELETE FROM tbl_bans WHERE dtIpHash = ?",[hash])
delete ignorelist[hash]
}
}