From 4fdd0a72582ed0e2c3ff50a51225af18d9311d90 Mon Sep 17 00:00:00 2001 From: Emily Date: Mon, 11 Mar 2024 17:49:36 +0100 Subject: [PATCH] added whitelist functionality --- main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.js b/main.js index 202929d..11a2c30 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,10 @@ +const whitelist = [ + "127.0.0.1" +] + const net = require("net") const {exec} = require("child_process"); +const { ReadableStreamDefaultController } = require("node:stream/web"); const portlist = [21,1433] const host = "0.0.0.0"; var ipSet = new Set() @@ -14,6 +19,9 @@ portlist.forEach(i => { }) // defining connection event server.on("connection", a => { + // if the ip is in the whitelist, ignore the connection (this is to prevent manually crafted packets to) + if(whitelist.includes(a.remoteAddress)) return + console.log(`incomming connection from : ${a.remoteAddress} on port ${i}`) // handle error even on socket instance (prevents the econnreset error) a.on("error", () => {})