diff --git a/.gitignore b/.gitignore index 780b07e..b04906c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules .git client.exe server.exe -cfg.json \ No newline at end of file +cfg.json +.gitignore \ No newline at end of file diff --git a/tcp-client/index.js b/tcp-client/index.js index f4b7bc2..e576112 100644 --- a/tcp-client/index.js +++ b/tcp-client/index.js @@ -194,7 +194,7 @@ try { * @returns */ nameVerificator(input="") { - let _verfrx = /[`~!@#$%^&*()_+={}\[\]|\\:;“’<,>.?๐฿]+/gmi + let _verfrx = /[`'"~!@#$%^&*()_+={}\[\]|\\:;“’<,>.?๐฿\s]+/gmi if(!_verfrx.test(input)) { return false } else { @@ -244,8 +244,9 @@ try { */ async function listener(d=new Buffer()) { NAME = d.toString().trim().slice(0,12) - if(clnt.nameVerificator(NAME)) { - process.stdout.moveCursor(-d?.length, -2) + if(clnt.nameVerificator(NAME) || NAME.length < 1) { + process.stdout.moveCursor(-d?.length, -3) + process.stdout.clearScreenDown() process.stdout.write("Your username contain disallowed special characters.\n") return; } @@ -296,6 +297,10 @@ try { if(a !== true) { return false } + if(d.toString().trim().length < 1) { + process.stdout.moveCursor(0, -2) + return false + } // New payload const pl = new Payload(d.toString("utf-8").trim(), clnt.getUUID()) if(pl.content === "\u0003") { // If raw mode was true, this is going to be useed @@ -304,6 +309,12 @@ try { process.stdout.moveCursor(-d.length, -2) // Stay in place, move to the very left process.stdout.clearLine() // Clear line clnt.send(pl) // Send payload to the server. It seem to be impossible to send a class, right? + }) + process.on("beforeExit", (_) => { + clnt.getCurrSocketInterface().destroySoon() + }) + process.on("exit", (_) => { + clnt.getCurrSocketInterface().destroySoon() }) }); } catch(e) { diff --git a/tcp-client/nothing.txt b/tcp-client/nothing.txt deleted file mode 100644 index 8a393af..0000000 --- a/tcp-client/nothing.txt +++ /dev/null @@ -1,27 +0,0 @@ -// var client = net.createConnection(55674, '0.0.0.0', () => { -// console.log("Connected to server.") -// client.setKeepAlive(5000) -// }) -// client.on("timeout", () => { -// client.end(() => { -// console.log("Ended connection due to timeout.") -// client.destroy() -// }) -// }) -// client.once("close", () => { -// console.log("The server closed the connection.") -// }) -// client.once("end", () => { -// console.log("The server ended the connection.") -// }) -// client.on("ready", () => { -// console.log("Connection ready!") -// rl.prompt() -// }) -// client.once("error", (e) => { -// console.log("We can't reach to the destination server. Please try again!\nPress ctrl+c to exit!") -// }) -// client.on("data", (data) => { -// const str = JSON.parse(data.toString("utf-8").replace(/\n/, "")).content -// process.stdout.write(str) -// }) \ No newline at end of file diff --git a/tcp-client/tasks/build.cmd b/tcp-client/tasks/build.cmd new file mode 100644 index 0000000..ef5345a --- /dev/null +++ b/tcp-client/tasks/build.cmd @@ -0,0 +1,5 @@ +@echo off +cd ../ +pkg index.js -t node18-win -o client +echo Sucessful build! +pause \ No newline at end of file diff --git a/tcp-server/index.js b/tcp-server/index.js index 63f2d6b..5c55484 100644 --- a/tcp-server/index.js +++ b/tcp-server/index.js @@ -92,7 +92,7 @@ Parsing packets according to TTELCP (TCP Toolkit Exclusively Live Communication // Referrence only! try { let data = d.toString("utf-8") - let InvalidCharsRegEx = /[`~!@#$%^&*()_+={}\[\]|\\:;“’<,>.?๐฿]+/gmi + let InvalidCharsRegEx = /[`'"~!@#$%^&*()_+={}\[\]|\\:;“’<,>.?๐฿\s]+/gmi let UUIDValidateRegEx = /([a-f]|[0-9]){8}-([a-f]|[0-9]){4}-([a-f]|[0-9]){4}-([a-f]|[0-9]){8}/gm if(!JSON.parse(data).name || !!InvalidCharsRegEx.test(JSON.parse(data).name) || JSON.parse(data).name.length > 12) { socket.end(() => {console.log("Ended %s", socket.address)}) diff --git a/tcp-server/tasks/build.cmd b/tcp-server/tasks/build.cmd new file mode 100644 index 0000000..754349f --- /dev/null +++ b/tcp-server/tasks/build.cmd @@ -0,0 +1,5 @@ +@echo off +cd ../ +pkg index.js -t node18-win -o server +echo Sucessful build! +pause \ No newline at end of file