mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-29 14:13:45 -04:00
fix gamemode3 in proxy : fix #146
* correctly generate the same uuidv3 than the vanilla server does in offline mode : fix #282 * remove "one player online mode" in the proxy : it doesn't make sense to identify all players as the user/passwd given in the cli. Now both servers in offline mode.
This commit is contained in:
parent
23b077b76f
commit
787f8d3423
@ -2,7 +2,7 @@ var mc = require('../../');
|
|||||||
|
|
||||||
var states = mc.states;
|
var states = mc.states;
|
||||||
function printHelpAndExit(exitCode) {
|
function printHelpAndExit(exitCode) {
|
||||||
console.log("usage: node proxy.js [<options>...] <target_srv> <user> [<password>] [<version>]");
|
console.log("usage: node proxy.js [<options>...] <target_srv> [<version>]");
|
||||||
console.log("options:");
|
console.log("options:");
|
||||||
console.log(" --dump name");
|
console.log(" --dump name");
|
||||||
console.log(" print to stdout messages with the specified name.");
|
console.log(" print to stdout messages with the specified name.");
|
||||||
@ -35,8 +35,6 @@ process.argv.forEach(function(val, index, array) {
|
|||||||
var args = process.argv.slice(2);
|
var args = process.argv.slice(2);
|
||||||
var host;
|
var host;
|
||||||
var port = 25565;
|
var port = 25565;
|
||||||
var user;
|
|
||||||
var passwd;
|
|
||||||
var version;
|
var version;
|
||||||
|
|
||||||
var printAllNames = false;
|
var printAllNames = false;
|
||||||
@ -62,8 +60,6 @@ var printNameBlacklist = {};
|
|||||||
}
|
}
|
||||||
if(!(i + 2 <= args.length && args.length <= i + 4)) printHelpAndExit(1);
|
if(!(i + 2 <= args.length && args.length <= i + 4)) printHelpAndExit(1);
|
||||||
host = args[i++];
|
host = args[i++];
|
||||||
user = args[i++];
|
|
||||||
passwd = args[i++];
|
|
||||||
version = args[i++];
|
version = args[i++];
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -98,9 +94,7 @@ srv.on('login', function(client) {
|
|||||||
var targetClient = mc.createClient({
|
var targetClient = mc.createClient({
|
||||||
host: host,
|
host: host,
|
||||||
port: port,
|
port: port,
|
||||||
username: user,
|
username: client.username,
|
||||||
password: passwd,
|
|
||||||
'online-mode': passwd != null ? true : false,
|
|
||||||
keepAlive:false,
|
keepAlive:false,
|
||||||
version:version
|
version:version
|
||||||
});
|
});
|
||||||
|
@ -46,12 +46,13 @@
|
|||||||
"minecraft-data": "^0.13.0",
|
"minecraft-data": "^0.13.0",
|
||||||
"node-uuid": "~1.4.1",
|
"node-uuid": "~1.4.1",
|
||||||
"prismarine-nbt": "0.0.1",
|
"prismarine-nbt": "0.0.1",
|
||||||
|
"protodef": "0.2.0",
|
||||||
"readable-stream": "^1.1.0",
|
"readable-stream": "^1.1.0",
|
||||||
"superagent": "~0.10.0",
|
"superagent": "~0.10.0",
|
||||||
"ursa-purejs": "0.0.3",
|
"ursa-purejs": "0.0.3",
|
||||||
"uuid": "^2.0.1",
|
"uuid": "^2.0.1",
|
||||||
"yggdrasil": "0.1.0",
|
"uuid-1345": "^0.99.6",
|
||||||
"protodef":"0.2.0"
|
"yggdrasil": "0.1.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"ursa": "~0.9.1"
|
"ursa": "~0.9.1"
|
||||||
|
@ -4,6 +4,7 @@ var yggserver = require('yggdrasil').server({});
|
|||||||
var states = require("./states");
|
var states = require("./states");
|
||||||
var bufferEqual = require('buffer-equal');
|
var bufferEqual = require('buffer-equal');
|
||||||
var Server = require('./server');
|
var Server = require('./server');
|
||||||
|
var UUID = require('uuid-1345');
|
||||||
|
|
||||||
module.exports=createServer;
|
module.exports=createServer;
|
||||||
|
|
||||||
@ -194,10 +195,27 @@ function createServer(options) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// https://github.com/openjdk-mirror/jdk7u-jdk/blob/f4d80957e89a19a29bb9f9807d2a28351ed7f7df/src/share/classes/java/util/UUID.java#L163
|
||||||
|
function javaUUID(s)
|
||||||
|
{
|
||||||
|
var hash = crypto.createHash("md5");
|
||||||
|
hash.update(s, 'utf8');
|
||||||
|
var buffer = hash.digest();
|
||||||
|
buffer[6] = (buffer[6] & 0x0f) | 0x30;
|
||||||
|
buffer[8] = (buffer[8] & 0x3f) | 0x80;
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nameToMcOfflineUUID(name)
|
||||||
|
{
|
||||||
|
return (new UUID(javaUUID("OfflinePlayer:"+name))).toString();
|
||||||
|
}
|
||||||
|
|
||||||
function loginClient() {
|
function loginClient() {
|
||||||
var isException = !!server.onlineModeExceptions[client.username.toLowerCase()];
|
var isException = !!server.onlineModeExceptions[client.username.toLowerCase()];
|
||||||
if(onlineMode == false || isException) {
|
if(onlineMode == false || isException) {
|
||||||
client.uuid = "0-0-0-0-0";
|
client.uuid = nameToMcOfflineUUID(client.username);
|
||||||
}
|
}
|
||||||
client.write('compress', { threshold: 256 }); // Default threshold is 256
|
client.write('compress', { threshold: 256 }); // Default threshold is 256
|
||||||
client.compressionThreshold = 256;
|
client.compressionThreshold = 256;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user