From 42400a2a58cc74cdcc5a8d583a767e5a17b9478c Mon Sep 17 00:00:00 2001 From: Hamidreza Eqbal Date: Sun, 27 Oct 2019 11:54:44 +0330 Subject: [PATCH] Check that secret is a valid hex number --- mtproxy.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mtproxy.js b/mtproxy.js index a82c6d9..794627a 100644 --- a/mtproxy.js +++ b/mtproxy.js @@ -29,6 +29,9 @@ for (let i = 0; i < telegram_servers.length; i++) { } var configObj = JSON.parse(fs.readFileSync('config.json', 'utf8')); +if (Buffer.from(configObj.secret, 'hex').toString('hex') !== configObj.secret) { + return console.log('Secret is invalid: Secret must be a hex number'); +} function reverseInplace (buffer) { for (var i = 0, j = buffer.length - 1; i < j; ++i, --j) {