From 8305494915f4ecf9e456dc475c8d13efd5bce5cd Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Mon, 28 Apr 2025 17:44:07 -0400 Subject: [PATCH] Imrpoved IP Ban Messages --- src/app/channel/channelManager.js | 16 ++++++++-- .../api/account/registerController.js | 32 +++++++++++++++---- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/app/channel/channelManager.js b/src/app/channel/channelManager.js index 52ae732..c4a623f 100644 --- a/src/app/channel/channelManager.js +++ b/src/app/channel/channelManager.js @@ -101,8 +101,20 @@ module.exports = class{ //If this ip is randy bobandy if(ipBanDB != null){ - //tell it to fuck off - socket.emit("kick", {type: "kicked", reason: "The IP address you are trying to connect from has been banned!"}); + //Make the number a little prettier despite the lack of precision since we're not doing calculations here :P + const expiration = ipBanDB.getDaysUntilExpiration() < 1 ? 0 : ipBanDB.getDaysUntilExpiration(); + + //If the ban is permanent + if(ipBanDB.permanent){ + //tell it to fuck off + socket.emit("kick", {type: "kicked", reason: `The IP address you are trying to connect from has been permanently banned. Your cleartext IP has been saved to the database. Any associated accounts will be nuked in ${expiration} day(s).`}); + //Otherwise + }else{ + //tell it to fuck off + socket.emit("kick", {type: "kicked", reason: `The IP address you are trying to connect from has been temporarily banned. Your cleartext IP has been saved to the database until the ban expires in ${expiration} day(s).`}); + } + + return false; } diff --git a/src/controllers/api/account/registerController.js b/src/controllers/api/account/registerController.js index 43ba037..cbd7951 100644 --- a/src/controllers/api/account/registerController.js +++ b/src/controllers/api/account/registerController.js @@ -61,12 +61,32 @@ module.exports.post = async function(req, res){ //If this ip is randy bobandy if(ipBanDB != null){ - //Make the code and message look pretty (kinda) at the same time - const banMsg = [ - 'The IP address you are trying to register an account from has been banned.', - 'If you beleive this to be an error feel free to reach out to your server administrator.', - 'Otherwise, fuck off :)' - ]; + + //Make the number a little prettier despite the lack of precision since we're not doing calculations here :P + const expiration = ipBanDB.getDaysUntilExpiration() < 1 ? 0 : ipBanDB.getDaysUntilExpiration(); + let banMsg = []; + + //If the ban is permanent + if(ipBanDB.permanent){ + //tell it to fuck off + //Make the code and message look pretty (kinda) at the same time + banMsg = [ + 'The IP address you are trying to register an account from has been permanently banned.', + 'Your cleartext IP has been saved to the database.', + `Any associated accounts will be nuked in ${expiration} day(s).`, + 'If you beleive this to be an error feel free to reach out to your server administrator.', + 'Otherwise, fuck off :)' + ]; + }else{ + //tell it to fuck off + //Make the code and message look pretty (kinda) at the same time + banMsg = [ + 'The IP address you are trying to register an account from has been temporarily banned.', + `Your cleartext IP has been saved to the database until the ban expires in ${expiration} day(s).`, + 'If you beleive this to be an error feel free to reach out to your server administrator.', + 'Otherwise, fuck off :)' + ]; + } //tell it to fuck off return errorHandler(res, banMsg.join('
'), 'unauthorized');