Commit 052f06ec authored by Ahmad Nemati's avatar Ahmad Nemati

init

parent e962c8e2
......@@ -7,7 +7,7 @@ const cronOne = require('node-cron');
const cronSpeed = require('node-cron');
const shellExec = require('shell-exec')
var decimalPointRegex = /\-?\d+\.\d+/g;
let fs=require('fs')
let fs = require('fs')
let port = 5
......@@ -58,34 +58,32 @@ app.listen(3000, () => console.log(`Example app listening on port 3000!`))
async function run() {
let whiteIp=await getWhiteIp()
let whiteIp = await getWhiteIp()
doIptable(whiteIp)
let portRes = await getPort()
if (portRes === '0' || portRes === '443')
port = randomInt(4000, 60000)
else
port=parseInt(portRes)
port = parseInt(portRes)
let a = await shell.exec('cd .. && cd mt && sudo ./server1.sh ' + port, {silent: true}).stdout;
console.log('Reset Proxy')
}
async function doIptable(whiteIp)
{
let command=''
for (let i=0;i<whiteIp.length;i++)
{
command +='iptables -A INPUT -p tcp -s '+whiteIp[i]+' --dport 3000 -j ACCEPT'
command+='\n'
command +='iptables -A INPUT -p tcp -s '+whiteIp[i]+' --dport 22 -j ACCEPT'
command+='\n'
async function doIptable(whiteIp) {
let command = ''
for (let i = 0; i < whiteIp.length; i++) {
command += 'iptables -A INPUT -p tcp -s ' + whiteIp[i] + ' --dport 3000 -j ACCEPT'
command += '\n'
command += 'iptables -A INPUT -p tcp -s ' + whiteIp[i] + ' --dport 22 -j ACCEPT'
command += '\n'
}
command+='iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 3000 -j DROP'
command+='\n'
command+='iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 22 -j DROP'
await createfile(command)
command += 'iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 3000 -j DROP'
command += '\n'
command += 'iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 22 -j DROP'
await createfile(command)
await execLast()
return true
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment