fix socks proxy using a socks module that actually works and provide a proper node stream

This commit is contained in:
Romain Beaumont 2017-07-19 17:24:51 +02:00
parent cab5a329bf
commit 6279ae9afe
No known key found for this signature in database
GPG Key ID: DB60E388B3BCF286
2 changed files with 40 additions and 28 deletions

View File

@ -1,5 +1,5 @@
const mc = require('minecraft-protocol');
const Socks = require("socks5-client");
const socks = require("socks");
if(process.argv.length < 6 || process.argv.length > 8) {
console.log("Usage : node client_socks_proxy.js <host> <port> <proxyHost> <proxyPort> [<name>] [<password>]");
@ -9,13 +9,23 @@ if(process.argv.length < 6 || process.argv.length > 8) {
const proxyHost=process.argv[4];
const proxyPort=process.argv[5];
const client = mc.createClient({
stream: Socks.createConnection({
socks.createConnection({
proxy: {
ipaddress: proxyHost,
port: proxyPort,
type: 5
},
target: {
host: process.argv[2],
port: parseInt(process.argv[3]),
socksHost: proxyHost,
socksPort: proxyPort
}),
port: parseInt(process.argv[3])
},
}, function(err, socket) {
if (err) {
console.log(err);
return;
}
const client = mc.createClient({
stream: socket,
username: process.argv[6] ? process.argv[6] : "echo",
password: process.argv[7]
});
@ -38,3 +48,5 @@ client.on('chat', function(packet) {
client.write('chat', {message: msg});
}
});
});

View File

@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"dependencies": {
"socks5-client": "^1.2.5"
"socks": "^1.1.10"
},
"description": "A node-minecraft-protocol example"
}