diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f52b751 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +APP_ENV=local +APP_TOKEN=$2y$10$9z/ch9hTc5rNQF9ks7cQoui5ISEeTCa73Ixm3c2UiJawY33WrnuuG + +SERVER_PORT=25053 +SERVER_IP=127.0.0.1 +DEFAULT_PONG_INTERVAL=3000 diff --git a/.gitignore b/.gitignore index 07e6e47..dc150eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +.env diff --git a/app.js b/app.js index 3613d42..c2b4951 100644 --- a/app.js +++ b/app.js @@ -1,9 +1,11 @@ -const net = require("net"); +require('dotenv').config(); + +const net = require('net'); const client = new net.Socket(); -const token = '$2y$10$9z/ch9hTc5rNQF9ks7cQoui5ISEeTCa73Ixm3c2UiJawY33WrnuuG'; +const token = process.env.APP_TOKEN; -client.connect(25053, "127.0.0.1", () => { +client.connect(process.env.SERVER_PORT, process.env.SERVER_IP, () => { console.log("Connected"); client.write("AUTHENTICATION=" + token, "utf8"); }); @@ -20,4 +22,4 @@ setInterval(() => { let sent = "Pong ..."; client.write(sent); console.log("Send: " + sent); -}, 3000); +}, process.env.DEFAULT_PONG_INTERVAL);