diff --git a/package-lock.json b/package-lock.json index 9466d57..2d286f8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "moxyjs", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "moxyjs", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "dependencies": { "@nestjs/common": "^10.2.10", diff --git a/package.json b/package.json index a6849a9..0abfa40 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moxyjs", - "version": "0.0.4", + "version": "0.0.5", "description": "Distributed transparent proxy with traffic control facilities", "author": "Pooyan Khanjankhani ", "license": "MIT", diff --git a/src/proxy.ts b/src/proxy.ts index 9686d62..afe6b01 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -39,9 +39,7 @@ class TcpProxy implements Proxy { public listen() { return new Promise((res, rej) => { const server = this.server.listen(this.listeningPort, () => { - this.logger.log( - `Started tcp proxy` - ); + this.logger.log("Started tcp proxy"); res(); }); server.on("error", rej); @@ -52,9 +50,7 @@ class TcpProxy implements Proxy { return new Promise((res, rej) => { this.server.close((err) => { if (err) rej(err); - this.logger.log( - `Destroyed tcp proxy` - ); + this.logger.log("Destroyed tcp proxy"); res(); }); }); @@ -67,7 +63,7 @@ class TcpProxy implements Proxy { this.forwardingPort, this.forwardingAddress, () => { - this.logger.log(`Connected to forward port`); + this.logger.log("Connected to forward port"); const upCounter = createCounterStream( this.eventEmmiter, @@ -92,12 +88,17 @@ class TcpProxy implements Proxy { ); clientSocket.on("close", () => { - this.logger.log(`Client disconnected`); + this.logger.log("Client disconnected"); forwardSocket.end(); }); clientSocket.on("error", (err) => { this.logger.error(`Client socket error: ${err}`); + clientSocket.destroy(); + }); + + forwardSocket.on("close", () => { + this.logger.log("Forward disconnected"); }); forwardSocket.on("error", (err) => {