Skip to content

Commit

Permalink
Add XUID field for client offline mode client chain (#203)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
extremeheat authored Apr 30, 2022
1 parent f2d39a0 commit 52156a0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/handshake/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/serverPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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')

Expand Down Expand Up @@ -190,7 +191,6 @@ async function requestChunks (version, x, z, radius) {
blobs: [],
payload: cbuf
})
// console.log('Ht',cc.sectionsLen,cc.sections)
}
}

Expand All @@ -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 }
2 changes: 1 addition & 1 deletion test/vanilla.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
11 changes: 10 additions & 1 deletion tools/startVanillaServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

0 comments on commit 52156a0

Please sign in to comment.