diff --git a/config.js b/config.js new file mode 100644 index 0000000..8b96908 --- /dev/null +++ b/config.js @@ -0,0 +1,4 @@ +module.exports = { + port: 3069, + token: "hushthisistemporary", +} \ No newline at end of file diff --git a/index.js b/index.js index 50a6a7c..9fd939e 100644 --- a/index.js +++ b/index.js @@ -2,18 +2,18 @@ const express = require("express"); const { spawn } = require("child_process"); +const { port, token } = require("./config"); const app = express(); -const port = 3069; app.use(express.json()); const activeConnections = new Map(); app.get("/start", (req, res) => { - let token = req.query.token; + let tokenParam = req.query.token; - if (!token || token !== "hushthisistemporary") + if (!tokenParam || tokenParam !== token) return res.status(401).send("Unauthorized"); const tcpdumpProcess = spawn("sudo", ["tcpdump", "-l", "-i", "any", "-v"]); @@ -44,5 +44,5 @@ app.get("/start", (req, res) => { }); app.listen(port, () => { - console.log(`Server is running at http://localhost:${port}`); + console.log(`Server is running at :${port}`); });