Skip to content

Commit

Permalink
增加 Socket链接开启Keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
Srar committed Dec 3, 2019
1 parent ec70e08 commit dafbad8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Socks5SSProxyTcpProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ export default class Socks5SSProxyProcess extends events.EventEmitter {
constructor(private processConfig: Socks5SSProxyProcessConfig) {
super();
this.clientSocket = processConfig.clientSocket;
this.clientSocket.setNoDelay(false);
this.clientSocket.setNoDelay(true);
this.clientSocket.setKeepAlive(true);
this.clientSocket.on("data", this.onClientSocketData.bind(this));
this.clientSocket.on("close", this.onClientSocketClose.bind(this));
this.clientSocket.on("error", this.onClientSocketError.bind(this));

this.targetSocket = new net.Socket();
this.targetSocket.setNoDelay(true);
this.targetSocket.setKeepAlive(true);
this.targetSocket.on("error", this.onTargetSocketError.bind(this));
}

Expand All @@ -47,7 +49,6 @@ export default class Socks5SSProxyProcess extends events.EventEmitter {
this.targetSocket.write(new Buffer([0x05, 0x01, 0x00]));
}


private onTargetSocketData(data: Buffer) {
try {
if (this.socks5HandSetup == 0) {
Expand Down

0 comments on commit dafbad8

Please sign in to comment.