diff --git a/main.js b/main.js index cff7eb0..dd39ed2 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,5 @@ const net = require("net") -const {spawn} = require("child_process"); +const {spawn,exec} = require("child_process"); const portlist = [21,1433,7777] const host = "0.0.0.0"; servermap = new Map() @@ -19,8 +19,22 @@ portlist.forEach(i => { // Handle banning ip - const output = spawn("echo", [`-A INPUT -s ${a.remoteAddress} -j DROP`]); - output.stdout.on("data", () => {console.log(data);}) + // const output = spawn("echo", [`-A INPUT -s ${a.remoteAddress} -j DROP`]); + // output.stdout.on("data", () => {console.log(data);}) + + + + exec(`echo -A INPUT -s ${a.remoteAddress} -j DROP`, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + console.log(`stdout: ${stdout}`); + }); }) servermap.set(i, server) })