You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] The FAQ doesn't contain a resolution to my issue
Versions
minecraft-protocol: 1.51.0
node: v22.11.0
Detailed description of a problem
A clear and concise description of what the problem is.
Current code
constmc=require('minecraft-protocol');conststates=mc.states;varSocks=require("socks5-client");const{ exec }=require('child_process');functionprintHelpAndExit(exitCode){console.log('usage: node proxy.js <target_srv> <version>');process.exit(exitCode);}if(process.argv.length<4){console.log('Too few arguments!');printHelpAndExit(1);}process.argv.forEach(function(val){if(val==='-h'){printHelpAndExit(0);}});constargs=process.argv.slice(2);lethost;letport=25565;letversion;(function(){leti=0;for(i=0;i<args.length;i++){constoption=args[i];if(!/^-/.test(option))break;i++;}if(!(i+2<=args.length&&args.length<=i+4))printHelpAndExit(1);host=args[i++];version=args[i++];})();if(host.indexOf(':')!==-1){port=host.substring(host.indexOf(':')+1);host=host.substring(0,host.indexOf(':'));}constsrv=mc.createServer({'online-mode': false,port: 25566,keepAlive: false,
version
});// Array to store the connected clientsletclients=[];lettargetClients=[];// Track target clientssrv.on('login',function(client){constaddr=client.socket.remoteAddress;console.log('Incoming connection','('+addr+')');// Add the new client to the clients arrayclients.push(client);letendedClient=false;letendedTargetClient=false;lettargetClient;client.on('end',function(){endedClient=true;console.log('Connection closed by client','('+addr+')');// Remove client from the array when they disconnectclients=clients.filter(c=>c!==client);if(!endedTargetClient){targetClient.end('End');}});client.on('error',function(err){endedClient=false;console.log('Connection error by client','('+addr+')');console.log(err.stack);});functiongenerateRandomUsername(){constcharacters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';letusername='';constlength=12;for(leti=0;i<length;i++){constrandomIndex=Math.floor(Math.random()*characters.length);username+=characters[randomIndex];}returnusername;}// Function to set up the target clientfunctionsetupTargetClient(){// Close all previously connected target clientstargetClients.forEach((tc)=>{tc.end('End');});// Create new target clienttargetClient=mc.createClient({host: host,port: port,username: generateRandomUsername(),keepAlive: false,version: '1.8.9'});// Store the new target clienttargetClients=[targetClient];// Forwarding packets between client and target serverclient.on('packet',function(data,meta){if(targetClient.state===states.PLAY&&meta.state===states.PLAY){// Check if the packet is not a kick packetif(meta.name==='kick_disconnect'){// Do nothing to prevent the kick packet from being processedreturn;}targetClient.write(meta.name,data);}});targetClient.on('packet',function(data,meta){if(meta.state===states.PLAY&&client.state===states.PLAY){// Check if the packet is not a kick packetif(meta.name==='kick_disconnect'){// Do nothing to prevent the kick packet from being processedreturn;}client.write(meta.name,data);if(meta.name==='set_compression'){client.compressionThreshold=data.threshold;}}});lethasRegistered=false;functiondelay(ms){returnnewPromise(resolve=>setTimeout(resolve,ms));}targetClient.on('chat',async(message)=>{if(String(message).includes('register')||hasRegistered){return;}awaitdelay(2000);targetClient.chat('/register 123123 123123');hasRegistered=true;});targetClient.on('end',function(){endedTargetClient=true;console.log('Target client disconnected from server','('+addr+')');// // Run the 'resetip.bat' command first// exec('resetip.bat', (error, stdout, stderr) => {// if (error) {// console.error(`exec error: ${error}`);// return;// }// if (stderr) {// console.error(`stderr: ${stderr}`);// return;// }// console.log(`stdout: ${stdout}`);// });// -- deleted the ip resetter temporarily (in the video it isn't used)// delay(3350).then(() => {setupTargetClient();// Reconnect to the target serverconsole.log('Reconnected with new target client');// });});}// Call the function initiallysetupTargetClient();});
Expected behavior
After reconnecting from a kick, everything should work normally, and I shouldn't be kicked, in the moment where I got kicked in the video.
Additional context
I am trying to make a code that would automatically reconnect when I get kicked from a server, also without kicking me from the localhost server, I am playing on.
extremeheat
changed the title
[Random client.ends?]
proxy example: Random client.ends
Dec 14, 2024
xeonise
changed the title
proxy example: Random client.ends
proxy example: anticheat flags for actions that wouldn't get you kicked on the first time, before recreating the target client.
Dec 15, 2024
so I've done some debugging, and realized that the second client.end is actually by the server's anticheat, I don't know what the issue can really be, but probably, there are too many packets sent, or duplications after I rejoin.
anyways, I'd be grateful for any help here.
[ ] The FAQ doesn't contain a resolution to my issue
Versions
Detailed description of a problem
A clear and concise description of what the problem is.
Current code
Expected behavior
After reconnecting from a kick, everything should work normally, and I shouldn't be kicked, in the moment where I got kicked in the video.
Additional context
I am trying to make a code that would automatically reconnect when I get kicked from a server, also without kicking me from the localhost server, I am playing on.
What happens:
https://streamable.com/ufbfu5 (uploading here, since the file is too big).
The text was updated successfully, but these errors were encountered: