socks
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -450,3 +450,4 @@ "use strict"; | ||
buff.writeUInt8(constants_1.Socks5Auth.UserPass); | ||
this._nextRequiredPacketBufferSize = 2; // Need 2 bytes back | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5InitialHandshakeResponse; | ||
this._socket.write(buff.toBuffer()); | ||
@@ -538,3 +539,3 @@ this.state = constants_1.SocksClientState.SentInitialHandshake; | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5Response; | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; | ||
this._socket.write(buff.toBuffer()); | ||
@@ -561,9 +562,8 @@ this.state = constants_1.SocksClientState.SentFinalHandshake; | ||
// Check if data is available. | ||
if (this._receiveBuffer.length < | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4) { | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; | ||
if (this._receiveBuffer.length < dataNeeded) { | ||
this._nextRequiredPacketBufferSize = dataNeeded; | ||
return; | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(10)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); | ||
remoteHost = { | ||
@@ -580,4 +580,4 @@ host: ip.fromLong(buff.readUInt32BE()), | ||
else if (addressType === constants_1.Socks5HostType.Hostname) { | ||
const hostLength = buff.readUInt8(); | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + port | ||
const hostLength = header[4]; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + host + port | ||
// Check if data is available. | ||
@@ -588,3 +588,4 @@ if (this._receiveBuffer.length < dataNeeded) { | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(5) // Slice at 5 to skip host length | ||
); | ||
remoteHost = { | ||
@@ -598,9 +599,8 @@ host: buff.readString(hostLength), | ||
// Check if data is available. | ||
if (this._receiveBuffer.length < | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6) { | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; | ||
if (this._receiveBuffer.length < dataNeeded) { | ||
this._nextRequiredPacketBufferSize = dataNeeded; | ||
return; | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(24)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); | ||
remoteHost = { | ||
@@ -624,3 +624,3 @@ host: ip.toString(buff.readBuffer(16)), | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5Response; | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHeader; | ||
this.emit('bound', { socket: this._socket, remoteHost }); | ||
@@ -656,9 +656,8 @@ /* | ||
// Check if data is available. | ||
if (this._receiveBuffer.length < | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4) { | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv4; | ||
if (this._receiveBuffer.length < dataNeeded) { | ||
this._nextRequiredPacketBufferSize = dataNeeded; | ||
return; | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(10)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); | ||
remoteHost = { | ||
@@ -675,3 +674,3 @@ host: ip.fromLong(buff.readUInt32BE()), | ||
else if (addressType === constants_1.Socks5HostType.Hostname) { | ||
const hostLength = buff.readUInt8(); | ||
const hostLength = header[4]; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseHostname(hostLength); // header + host length + port | ||
@@ -683,3 +682,4 @@ // Check if data is available. | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(5) // Slice at 5 to skip host length | ||
); | ||
remoteHost = { | ||
@@ -693,9 +693,8 @@ host: buff.readString(hostLength), | ||
// Check if data is available. | ||
if (this._receiveBuffer.length < | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6) { | ||
this._nextRequiredPacketBufferSize = | ||
constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; | ||
const dataNeeded = constants_1.SOCKS_INCOMING_PACKET_SIZES.Socks5ResponseIPv6; | ||
if (this._receiveBuffer.length < dataNeeded) { | ||
this._nextRequiredPacketBufferSize = dataNeeded; | ||
return; | ||
} | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(24)); | ||
buff = smart_buffer_1.SmartBuffer.fromBuffer(this._receiveBuffer.get(dataNeeded).slice(4)); | ||
remoteHost = { | ||
@@ -702,0 +701,0 @@ host: ip.toString(buff.readBuffer(16)), |
@@ -38,8 +38,8 @@ "use strict"; | ||
// Command response + incoming connection (bind) | ||
Socks5Response: 5, | ||
Socks5ResponseHeader: 5, | ||
Socks5ResponseIPv4: 10, | ||
Socks5ResponseIPv6: 24, | ||
Socks5ResponseHostname: (hostNameLength) => hostNameLength + 6, | ||
Socks5ResponseIPv6: 22, | ||
Socks5ResponseHostname: (hostNameLength) => hostNameLength + 7, | ||
// Command response + incoming connection (bind) | ||
Socks4Response: 8 | ||
Socks4Response: 8 // 2 header + 2 port + 4 ip | ||
}; | ||
@@ -46,0 +46,0 @@ exports.SOCKS_INCOMING_PACKET_SIZES = SOCKS_INCOMING_PACKET_SIZES; |
{ | ||
"name": "socks", | ||
"private": false, | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"description": "Fully featured SOCKS proxy client supporting SOCKSv4, SOCKSv4a, and SOCKSv5. Includes Bind and Associate functionality.", | ||
@@ -6,0 +6,0 @@ "main": "build/index.js", |
@@ -35,3 +35,3 @@ /// <reference types="node" /> | ||
Socks5UserPassAuthenticationResponse: number; | ||
Socks5Response: number; | ||
Socks5ResponseHeader: number; | ||
Socks5ResponseIPv4: number; | ||
@@ -38,0 +38,0 @@ Socks5ResponseIPv6: number; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
201217
1310