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

If You Use Proxy And Try To Connect To A Non Cracked Server I'll Not Work #781

Closed
ElectroYModz opened this issue Dec 1, 2020 · 5 comments
Labels

Comments

@ElectroYModz
Copy link

[ ] The FAQ doesn't contain a resolution to my issue

Versions

  • minecraft-protocol: 1.19.0
  • server: vanilla/spigot/paper 1.12.2
  • node: v14.5.0.

Detailed description of a problem

ok so when i use a proxy on a non cracked server it cannot connect/auth because it tries to connect to localhost since you call connect instead of host and port

Current code

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;
var mc = require('minecraft-protocol');
var tokens = require('prismarine-tokens');
const socks = require('socks').SocksClient
const ProxyAgent = require('proxy-agent')
const config = require("./config.json")

var options = {
  connect: client => {
    socks.createConnection({
      proxy: {
        host: config.proxy_ip,
        port: parseInt(config.proxy_port),
        type: 5,
        userId: config.proxy_username,
        password: config.proxy_password
      },
      command: 'connect',
      destination: {
        host: config.server_ip,
        port: parseInt(config.server_port)
      }
    }, (err, info) => {
      if (err) {
        console.log(err)
        return
      }
      client.setSocket(info.socket)
      client.emit('connect')
    })
  },
  agent: new ProxyAgent({ protocol: 'socks5:', host: config.proxy_ip, port: parseInt(config.proxy_port), userId: config.proxy_username, password: config.proxy_password}),
  username: config.email,
  password: config.password,
  //Location of the file to store and read tokens for this bot
  //You can use the same file for all your bots
  tokensLocation: `tokens/${config.email}_token.json`,
  //Set to true if you want debug informations
  tokensDebug: true
};


tokens.use(options, function(_err, _opts){

  if (_err) throw _err;

  var bot = mc.createClient(_opts);

  bot.once('spawn', () => {
    console.log(`Connected ${bot.username} To ${config.server_ip}:${config.server_port} With ${config.proxy_ip}:${config.proxy_port}`)
})
bot.on('connect', function() {
    console.info(`Connected ${bot.username} To ${config.server_ip}:${config.server_port} With ${config.proxy_ip}:${config.proxy_port}`);
});
bot.on('chat', function (username, message) {
if (username == "queue") {
    console.log(`${bot.username} -> ${message} in queue! ${config.proxy_ip}:${config.proxy_port}}`);
} else console.log(`${bot.username} -> ${message}`)
})

});

Expected behavior

be able to join servers

@ElectroYModz
Copy link
Author

is there a way to spoof the ip in the login packet?
or change it without the proxy not working?

@ElectroYModz
Copy link
Author

this is the error i get "reason": "{"text":"§cUnknown Server: §flocalhost\n§7Please use the server domain to connect."}"

@ad1tya2
Copy link

ad1tya2 commented Mar 5, 2021

I also want to know this,
if there is a way to spoof the ip in the login packet

@u9g
Copy link
Member

u9g commented Mar 29, 2021

yes, of course there is a way to spoof the packet. Here:

client.write(meta.name, data)
add an if statement before this line to check whether the packet is the login packet, then change the packet's data to suit your needs

@u9g
Copy link
Member

u9g commented Mar 29, 2021

this can be closed

@rom1504 rom1504 closed this as completed Mar 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants