Add XUID field for client offline mode client chain (#203)

* Add XUID field for client offline mode client chain

* Update serverPlayer.js

handle alternative casing

* test/internal.js: randomize test port

* fix

* test server starting retry
This commit is contained in:
extremeheat 2022-04-30 19:02:56 -04:00 committed by GitHub
commit 52156a0024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 7 deletions

View file

@ -15,7 +15,8 @@ module.exports = (client, server, options) => {
extraData: {
displayName: client.username,
identity: client.profile.uuid,
titleId: '89692877'
titleId: '89692877',
XUID: '0'
},
certificateAuthority: true,
identityPublicKey: client.clientX509

View file

@ -69,7 +69,7 @@ class Player extends Connection {
this.profile = {
name: userData.extraData?.displayName,
uuid: userData.extraData?.identity,
xuid: userData.extraData?.xuid
xuid: userData.extraData?.xuid || userData.extraData?.XUID
}
this.version = clientVer
this.emit('login', { user: userData.extraData }) // emit events for user

View file

@ -14,7 +14,7 @@ function prepare (version) {
async function startTest (version = CURRENT_VERSION, ok) {
await prepare(version)
const Item = require('../types/Item')(version)
const port = 19130
const port = 19130 + Math.floor(Math.random() * 100)
const server = new Server({ host: '0.0.0.0', port, version, offline: true })
function getPath (packetPath) {
@ -25,6 +25,7 @@ async function startTest (version = CURRENT_VERSION, ok) {
return require(getPath('sample/' + packetPath))
}
console.log('Starting internal server')
server.listen()
console.log('Started server')
@ -190,7 +191,6 @@ async function requestChunks (version, x, z, radius) {
blobs: [],
payload: cbuf
})
// console.log('Ht',cc.sectionsLen,cc.sections)
}
}
@ -207,5 +207,5 @@ async function timedTest (version, timeout = 1000 * 220) {
console.info('✔ ok')
}
// if (!module.parent) timedTest('1.18.11')
// if (!module.parent) timedTest('1.16.210')
module.exports = { startTest, timedTest, requestChunks }

View file

@ -7,7 +7,7 @@ async function test (version) {
const ChunkColumn = require('bedrock-provider').chunk('bedrock_' + version)
// Start the server, wait for it to accept clients, throws on timeout
const handle = await vanillaServer.startServerAndWait(version, 1000 * 220)
const handle = await vanillaServer.startServerAndWait2(version, 1000 * 220)
console.log('Started server')
const client = new Client({

View file

@ -110,9 +110,18 @@ async function startServerAndWait (version, withTimeout, options) {
return handle
}
async function startServerAndWait2 (version, withTimeout, options) {
try {
return await startServerAndWait(version, withTimeout, options)
} catch (e) {
console.log(e, 'tring once more to start server...')
return await startServerAndWait(version, withTimeout, options)
}
}
if (!module.parent) {
// if (process.argv.length < 3) throw Error('Missing version argument')
startServer(process.argv[2] || '1.17.10', null, process.argv[3] ? { 'server-port': process.argv[3], 'online-mode': !!process.argv[4] } : undefined)
}
module.exports = { fetchLatestStable, startServer, startServerAndWait }
module.exports = { fetchLatestStable, startServer, startServerAndWait, startServerAndWait2 }