Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data lost for accept(true) #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Server.prototype._onConnection = function(socket) {
if (intercept) {
socket.write(BUF_REP_INTR_SUCCESS);
socket.removeListener('error', onErrorNoop);
process.nextTick(function() {
socket.resume();
});
//process.nextTick(function() {
//socket.resume();
//});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you set up a listener socket.on('data', ...) right after calling accept(true)?

If not, you can pause the socket again with:

socket = accept(true);
process.nextTick(function() {
  socket.pause();
});

return socket;
} else
proxySocket(socket, reqInfo);
Expand Down
23 changes: 14 additions & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var net = require('net'),
ipv6 = require('ipv6').v6;
var net = require('net');

exports.ipbytes = function(str) {
var type = net.isIP(str),
Expand All @@ -15,15 +14,21 @@ exports.ipbytes = function(str) {
throw new Error('Error parsing IP: ' + str);
}
} else if (type === 6) {
var addr = new ipv6.Address(str),
b = 0,
group;
if (!addr.valid)
throw new Error('Error parsing IP: ' + str);
nums = addr.parsedAddress;
var addr = str.split(':'),
b = 0,
group;
if(addr.length != 8){
var index = addr.findIndex(function (value) {
return value == '';
});
var expand = new Array(8-addr.length+1);
expand.fill('0');
addr[index]=expand;
addr.flat();
}
bytes = new Array(16);
for (i = 0; i < 8; ++i, b += 2) {
group = parseInt(nums[i], 16);
group = parseInt(addr[i], 16);
bytes[b] = group >>> 8;
bytes[b + 1] = group & 0xFF;
}
Expand Down
6 changes: 0 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"scripts": {
"test": "node test/test.js"
},
"dependencies": {
"ipv6": "*"
},
"bundledDependencies": [
"ipv6"
],
"engines": { "node": ">=0.10.0" },
"keywords": [ "socks", "socks5", "socksv5", "proxy" ],
"licenses": [ { "type": "MIT", "url": "http://github.com/mscdex/socksv5/raw/master/LICENSE" } ],
Expand Down