socks5server
Advanced tools
Comparing version 4.3.2 to 4.4.0
{ | ||
"name": "socks5server", | ||
"version": "4.3.2", | ||
"version": "4.4.0", | ||
"description": "A simple SOCKS 5/4/4a implementation and demo proxy", | ||
@@ -22,4 +22,5 @@ "author": "luojia <luojia@luojia.me>", | ||
"commander": "^8.3.0", | ||
"ip-address": "^8.1.0" | ||
"ip-address": "^8.1.0", | ||
"pump": "^3.0.0" | ||
} | ||
} |
@@ -57,8 +57,4 @@ | ||
//example for modify data | ||
relay.inStream=(source)=>{ | ||
return source;//return another Readable stream to modify the stream | ||
} | ||
relay.outStream=(source)=>{ | ||
return source;//return another Readable stream to modify the stream | ||
} | ||
relay.outModifier=null;//give a readable stream here to modify outgoing data | ||
relay.inModifier=null;//give a readable stream here to modify incoming data | ||
} | ||
@@ -65,0 +61,0 @@ |
@@ -8,2 +8,3 @@ 'use strict' | ||
stream=require('stream'), | ||
pump = require('pump'), | ||
ipAddress=require('ip-address'); | ||
@@ -463,2 +464,5 @@ | ||
this.emit('close'); | ||
setImmediate(()=>{ | ||
this.relaySocket=null; | ||
}); | ||
} | ||
@@ -550,3 +554,2 @@ } | ||
}); | ||
} | ||
@@ -588,2 +591,6 @@ /** | ||
} | ||
close(){ | ||
super.close(); | ||
this.packetHandler=null; | ||
} | ||
/** | ||
@@ -619,2 +626,4 @@ *check socks5 UDP head | ||
remotePort; | ||
outModifier;//a readable stream for modifying outgoing stream | ||
inModifier;//a readable stream for modifying incoming stream | ||
/** | ||
@@ -639,9 +648,13 @@ * Creates an instance of TCPRelay. | ||
localPort:localPort||undefined | ||
},CMD_REPLY); | ||
}); | ||
relaySocket.on('connect',()=>{ | ||
CMD_REPLY(SOCKS_REPLY.SUCCEEDED,this.localAddress,this.localPort); | ||
this.inStream(relaySocket).pipe(socket); | ||
this.outStream(socket).pipe(relaySocket); | ||
this.emit('connection',this.inStream(socket),relaySocket); | ||
let outChain=[socket,relaySocket]; | ||
if(this.outModifier)outChain.splice(1,0,this.outModifier); | ||
pump(outChain); | ||
let inChain=[relaySocket,socket]; | ||
if(this.inModifier)inChain.splice(1,0,this.inModifier); | ||
pump(inChain); | ||
this.emit('connection',socket,relaySocket); | ||
}).once('error',err=>{ | ||
@@ -658,2 +671,3 @@ let rep=SOCKS_REPLY.SERVER_FAILURE; | ||
this.emit('proxy_error',err,socket,relaySocket); | ||
this.close(); | ||
}).once('close',()=>{ | ||
@@ -663,20 +677,9 @@ this.close(); | ||
} | ||
/** | ||
*get incoming stream and return a stream, can be used to modify incoming stream | ||
* | ||
* @param {stream.Readable} source | ||
* @returns {stream.Readable} | ||
*/ | ||
inStream(source){ | ||
return source; | ||
close(){ | ||
super.close(); | ||
this.inModifier=null; | ||
this.outModifier=null; | ||
this.packetHandler=null; | ||
this.socket=null; | ||
} | ||
/** | ||
*get out going stream and return a stream, can be used to modify out going stream | ||
* | ||
* @param {stream.Readable} source | ||
* @returns {stream.Readable} | ||
*/ | ||
outStream(source){ | ||
return source; | ||
} | ||
} | ||
@@ -683,0 +686,0 @@ |
31992
3
+ Addedpump@^3.0.0
+ Addedend-of-stream@1.4.4(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedwrappy@1.0.2(transitive)